Check for the root cause instead of the source when handling the InteractBlockEvent

This commit is contained in:
Wyatt Childers 2016-05-01 13:39:09 -04:00
parent 96798bbb90
commit 2fd5c2f887

View File

@ -149,12 +149,12 @@ public class SpongeWorldEdit {
if (!platform.isHookingEvents()) return; // We have to be told to catch these events if (!platform.isHookingEvents()) return; // We have to be told to catch these events
WorldEdit we = WorldEdit.getInstance(); WorldEdit we = WorldEdit.getInstance();
Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class); Object rootObj = event.getCause().root();
if (!optPlayer.isPresent()) { if (!(rootObj instanceof Player)) {
return; return;
} }
SpongePlayer player = wrapPlayer(optPlayer.get()); SpongePlayer player = wrapPlayer((Player) rootObj);
com.sk89q.worldedit.world.World world = player.getWorld(); com.sk89q.worldedit.world.World world = player.getWorld();
BlockSnapshot targetBlock = event.getTargetBlock(); BlockSnapshot targetBlock = event.getTargetBlock();