diff --git a/core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/core/src/main/java/com/boydti/fawe/object/FawePlayer.java index d5840207..9832d902 100644 --- a/core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -12,6 +12,7 @@ import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.WEManager; import com.boydti.fawe.wrappers.FakePlayer; +import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EmptyClipboardException; @@ -75,7 +76,7 @@ public abstract class FawePlayer extends Metadatable { return ((FakePlayer) obj).toFawePlayer(); } if (obj instanceof Player) { - Player actor = (Player) obj; + Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj); if (obj.getClass().getSimpleName().equals("PlayerProxy")) { try { Field fieldBasePlayer = actor.getClass().getDeclaredField("basePlayer"); diff --git a/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index e0bac95a..b44ef9f4 100644 --- a/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -347,7 +347,9 @@ public final class CommandManager { } final Set failedPermissions = new LinkedHashSet<>(); if (actor instanceof Player) { - actor = new LocationMaskedPlayerWrapper((Player) actor, ((Player) actor).getLocation(), true) { + Player player = (Player) actor; + Player unwrapped = LocationMaskedPlayerWrapper.unwrap(player); + actor = new LocationMaskedPlayerWrapper((Player) unwrapped, player.getLocation(), true) { @Override public boolean hasPermission(String permission) { if (!super.hasPermission(permission)) { @@ -439,21 +441,27 @@ public final class CommandManager { } @Subscribe - public void handleCommand(final CommandEvent event) { + public void handleCommand(CommandEvent event) { Request.reset(); - final FawePlayer fp = FawePlayer.wrap(event.getActor()); + Actor actor = event.getActor(); + if (actor instanceof Player) { + actor = LocationMaskedPlayerWrapper.wrap((Player) actor); + } + String args = event.getArguments(); + CommandEvent finalEvent = new CommandEvent(actor, args); + final FawePlayer fp = FawePlayer.wrap(actor); TaskManager.IMP.taskNow(new Runnable() { @Override public void run() { if (!fp.runAction(new Runnable() { @Override public void run() { - handleCommandOnCurrentThread(event); + handleCommandOnCurrentThread(finalEvent); } }, true, false)) { BBC.WORLDEDIT_COMMAND_LIMIT.send(fp); } - event.setCancelled(true); + finalEvent.setCancelled(true); } }, Fawe.isMainThread()); }