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.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<T> 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");

View File

@ -347,7 +347,9 @@ public final class CommandManager {
}
final Set<String> 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<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() {
@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());
}