This commit is contained in:
Jesse Boyd 2017-06-25 13:12:13 +10:00
parent ebdcf1afcd
commit b49a0a35af
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 15 additions and 6 deletions

View File

@ -12,6 +12,7 @@ import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.wrappers.FakePlayer; import com.boydti.fawe.wrappers.FakePlayer;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.EmptyClipboardException;
@ -75,7 +76,7 @@ public abstract class FawePlayer<T> extends Metadatable {
return ((FakePlayer) obj).toFawePlayer(); return ((FakePlayer) obj).toFawePlayer();
} }
if (obj instanceof Player) { if (obj instanceof Player) {
Player actor = (Player) obj; Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj);
if (obj.getClass().getSimpleName().equals("PlayerProxy")) { if (obj.getClass().getSimpleName().equals("PlayerProxy")) {
try { try {
Field fieldBasePlayer = actor.getClass().getDeclaredField("basePlayer"); Field fieldBasePlayer = actor.getClass().getDeclaredField("basePlayer");

View File

@ -347,7 +347,9 @@ public final class CommandManager {
} }
final Set<String> failedPermissions = new LinkedHashSet<>(); final Set<String> failedPermissions = new LinkedHashSet<>();
if (actor instanceof Player) { 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 @Override
public boolean hasPermission(String permission) { public boolean hasPermission(String permission) {
if (!super.hasPermission(permission)) { if (!super.hasPermission(permission)) {
@ -439,21 +441,27 @@ public final class CommandManager {
} }
@Subscribe @Subscribe
public void handleCommand(final CommandEvent event) { public void handleCommand(CommandEvent event) {
Request.reset(); Request.reset();
final FawePlayer<Object> 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<Object> fp = FawePlayer.wrap(actor);
TaskManager.IMP.taskNow(new Runnable() { TaskManager.IMP.taskNow(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!fp.runAction(new Runnable() { if (!fp.runAction(new Runnable() {
@Override @Override
public void run() { public void run() {
handleCommandOnCurrentThread(event); handleCommandOnCurrentThread(finalEvent);
} }
}, true, false)) { }, true, false)) {
BBC.WORLDEDIT_COMMAND_LIMIT.send(fp); BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
} }
event.setCancelled(true); finalEvent.setCancelled(true);
} }
}, Fawe.isMainThread()); }, Fawe.isMainThread());
} }