From 51515473bc77505eb521e68a59d7ab0be96cc382 Mon Sep 17 00:00:00 2001 From: wizjany Date: Tue, 26 Mar 2013 00:50:45 -0400 Subject: [PATCH] Allow remove command to be used from console --- src/main/java/com/sk89q/worldedit/WorldEdit.java | 2 ++ .../sk89q/worldedit/commands/UtilityCommands.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index d164e55e7..968b4185a 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -1398,6 +1398,8 @@ public class WorldEdit { } catch (CommandUsageException e) { player.printError(e.getMessage()); player.printError(e.getUsage()); + } catch (PlayerNeededException e) { + player.printError(e.getMessage()); } catch (WrappedCommandException e) { throw e.getCause(); } catch (UnhandledCommandException e) { diff --git a/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java b/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java index d77aeea1d..f02d34695 100644 --- a/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java @@ -450,6 +450,7 @@ public class UtilityCommands { ) @CommandPermissions("worldedit.remove") @Logging(PLACEMENT) + @Console public void remove(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { @@ -491,8 +492,15 @@ public class UtilityCommands { return; } - Vector origin = session.getPlacementPosition(player); - int removed = player.getWorld().removeEntities(type, origin, radius); + int removed = 0; + if (player.isPlayer()) { + Vector origin = session.getPlacementPosition(player); + removed = player.getWorld().removeEntities(type, origin, radius); + } else { + for (LocalWorld world : we.getServer().getWorlds()) { + removed += world.removeEntities(type, new Vector(), radius); + } + } player.print("Marked " + removed + " entit(ies) for removal."); }