From 47076b313e0a47257c572c85cf2c0e4787e24c6b Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 27 Jun 2014 18:28:31 -0700 Subject: [PATCH] Fixed command logging regression caused by merge. --- .../extension/platform/CommandManager.java | 3 +++ .../worldedit/util/CommandLoggingHandler.java | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index 2910fa273..8734071e1 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -144,9 +144,12 @@ public final class CommandManager { // Register log if (!logging || path.isEmpty()) { dynamicHandler.setHandler(null); + logger.setLevel(Level.OFF); } else { File file = new File(config.getWorkingDirectory(), path); + logger.setLevel(Level.ALL); + logger.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath()); try { diff --git a/src/main/java/com/sk89q/worldedit/util/CommandLoggingHandler.java b/src/main/java/com/sk89q/worldedit/util/CommandLoggingHandler.java index f75e02b31..48494a57b 100644 --- a/src/main/java/com/sk89q/worldedit/util/CommandLoggingHandler.java +++ b/src/main/java/com/sk89q/worldedit/util/CommandLoggingHandler.java @@ -23,6 +23,8 @@ import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.worldedit.*; +import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.command.parametric.AbstractInvokeListener; import com.sk89q.worldedit.util.command.parametric.InvokeHandler; import com.sk89q.worldedit.util.command.parametric.ParameterData; @@ -72,11 +74,19 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv logMode = loggingAnnotation.value(); } - LocalPlayer sender = context.getLocals().get(LocalPlayer.class); + Actor sender = context.getLocals().get(Actor.class); + Player player; + if (sender == null) { return; } + if (sender instanceof Player) { + player = (Player) sender; + } else { + return; + } + builder.append("WorldEdit: ").append(sender.getName()); if (sender.isPlayer()) { builder.append(" (in \"" + sender.getWorld().getName() + "\")"); @@ -89,13 +99,13 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv } if (logMode != null && sender.isPlayer()) { - Vector position = sender.getPosition(); - LocalSession session = worldEdit.getSession(sender); + Vector position = player.getPosition(); + LocalSession session = worldEdit.getSessionManager().get(player); switch (logMode) { case PLACEMENT: try { - position = session.getPlacementPosition(sender); + position = session.getPlacementPosition(player); } catch (IncompleteRegionException e) { break; } @@ -110,8 +120,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv /* FALL-THROUGH */ case ORIENTATION_REGION: - builder.append(" - Orientation: " - + sender.getCardinalDirection().name()); + builder.append(" - Orientation: " + player.getCardinalDirection().name()); /* FALL-THROUGH */ case REGION: