From 5b200092bae133ef3fbf5d2fa61b0829ae3c2a09 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 21 Jan 2011 18:24:38 -0800 Subject: [PATCH] Moved WorldEdit to use Bukkit's command registration. --- plugin.yml | 254 +++++++++++++++++- .../bukkit/WorldEditPlayerListener.java | 14 - .../worldedit/bukkit/WorldEditPlugin.java | 30 ++- 3 files changed, 281 insertions(+), 17 deletions(-) diff --git a/plugin.yml b/plugin.yml index cdab1db3a..1b29d6e1d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,3 +1,255 @@ name: WorldEdit main: com.sk89q.worldedit.bukkit.WorldEditPlugin -version: "WEVERSIONMACRO" \ No newline at end of file +version: "WEVERSIONMACRO" +commands: + /limit: + description: See documentation + usage: / + toggleplace: + description: Toggle placing at pos #1 + usage: / + + /undo: + description: Undo + usage: / + /redo: + description: Redo + usage: / + clearhistory: + description: Clear history + usage: / + + /pos1: + description: Set editing position #1 + usage: / + /pos2: + description: Set editing position #2 + usage: / + /hpos1: + description: Trace editing position #1 + usage: / + /hpos2: + description: Trace editing position #2 + usage: / + /chunk: + description: Select the chunk that you are in + usage: / + /wand: + description: Gives you the edit wand + usage: / + toggleeditwand: + description: Toggles edit wand selection + usage: / + /expand: + description: Expands the selection + usage: / [direction] + /contract: + description: Contracts the selection + usage: / [direction] + /shift: + description: Shift the selection + usage: / [direction] + /size: + description: Get size of selected region + usage: / + /count: + description: Count the number of blocks in the region + usage: / + /distr: + description: Get the top block distribution + usage: / + + /set: + description: Set all blocks inside region + usage: / + /replace: + description: Replace all existing blocks inside region + usage: / [from-id] [to-id] + /overlay: + description: Overlay the area one layer + usage: / + /walls: + description: Build walls + usage: / + /outline: + description: Outline the region with blocks + usage: / + /move: + description: Move the selection + usage: / [count] [dir] [leave-id] + /stack: + description: Stacks the selection + usage: / [count] [dir] + /smooth: + description: Smooth an area's heightmap + usage: / [iterations] + + /copy: + description: Copies the currently selected region + usage: / + /cut: + description: Cuts the currently selected region + usage: / + /paste: + description: Pastes the clipboard + usage: / + /rotate: + description: Rotate the clipboard + usage: / + /flip: + description: Flip the clipboard + usage: / [dir] + /load: + description: Load .schematic into clipboard + usage: / + /save: + description: Save clipboard to .schematic + usage: / + clearclipboard: + description: Clear clipboard + usage: / + + /hcyl: + description: Create a vertical hollow cylinder + usage: / [height] + /cyl: + description: Create a vertical cylinder + usage: / [height] + /sphere: + description: Create a sphere + usage: / [raised?] + /hsphere: + description: Create a hollow sphere + usage: / [raised?] + forestgen: + description: Make Notch tree forest + usage: / [size] [density] + pinegen: + description: Make an ugly pine tree forest + usage: / [size] [density] + pumpkins: + description: Make a pumpkin forest + usage: / [size] + + /fill: + description: Fill a hole + usage: / [depth] + /fillr: + description: Fill a hole fully recursively + usage: / + fixwater: + description: Level nearby pools of water + usage: / + fixlava: + description: Level nearby pools of lava + usage: / + /drain: + description: Drain nearby water/lava pools + usage: / + removeabove: + description: Remove blocks above head + usage: / [size] [height] + removebelow: + description: Remove blocks below position + usage: / [size] [height] + removenear: + description: Remove blocks near you + usage: / [id] [size] + replacenear: + description: Replace all existing blocks nearby + usage: / + snow: + description: Simulate snow cover + usage: / + thaw: + description: Unthaw/remove snow + usage: / + butcher: + description: Kill nearby mobs + usage: / [radius] + ex: + description: Extinguish fires + usage: / [size] + + chunkinfo: + description: Get the filename of the chunk that you are in + usage: / + listchunks: + description: Print a list of used chunks + usage: / + delchunks: + description: Generate a shell script to delete chunks + usage: / + + unstuck: + description: Go up to the first free spot + usage: / + ascend: + description: Go up one level + usage: / + descend: + description: Go down one level + usage: / + jumpto: + description: Jump to the block that you are looking at + usage: / + thru: + description: Go through the wall that you are looking at + usage: / + ceil: + description: Get to the ceiling + usage: / [clearence] + up: + description: Go up some distance + usage: / + + listsnapshots: + description: List the 5 newest snapshots + usage: / [num] + /use: + description: Use a particular snapshot + usage: / + /restore: + description: Restore a particular snapshot + usage: / [snapshot-id] + + /: + description: Toggles super pick axe. + usage: / + single: + description: Switch to single block super pickaxe mode + usage: / + area: + description: Switch to area super pickaxe mode + usage: / + recur: + description: Switch to recursive super pickaxe mode + usage: / + none: + description: Switch to no tool + usage: / + info: + description: Switch to the info tool + usage: / + tree: + description: Switch to the tree tool + usage: / + pinetree: + description: Switch to the pine tree tool + usage: / + bigtree: + description: Switch to the big tree tool + usage: / + repl: + description: Switch to the block replacer tool + usage: / + brush: + description: Switch to the sphere brush tool + usage: / [radius] [no-replace?] + reloadwe: + description: Switch to the replacing sphere brush tool + usage: / [radius] + + reloadwe: + description: Reload WorldEdit's configuration + usage: / \ No newline at end of file diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java b/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java index 793a5b62c..f49530d58 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java @@ -60,20 +60,6 @@ public class WorldEditPlayerListener extends PlayerListener { public void onPlayerCommand(PlayerChatEvent event) { String[] split = event.getMessage().split(" "); - if (split[0].equalsIgnoreCase("/reloadwe") - && plugin.hasPermission(event.getPlayer(), "/reloadwe")) { - try { - plugin.loadConfiguration(); - event.getPlayer().sendMessage("WorldEdit configuration reloaded."); - } catch (Throwable t) { - event.getPlayer().sendMessage("Error while reloading: " - + t.getMessage()); - } - - event.setCancelled(true); - return; - } - if (plugin.controller.handleCommand(wrapPlayer(event.getPlayer()), split)) { event.setCancelled(true); } diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 4330ff5d5..012014a29 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.logging.Logger; import org.bukkit.Server; +import org.bukkit.command.Command; import org.bukkit.entity.Player; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event; @@ -89,10 +90,10 @@ public class WorldEditPlugin extends JavaPlugin { private void registerEvents() { getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, - playerListener, Priority.Normal, this); getServer().getPluginManager().registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal, this); + getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, + playerListener, Priority.Normal, this); getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); getServer().getPluginManager().registerEvent(Event.Type.BLOCK_RIGHTCLICKED, @@ -143,6 +144,27 @@ public class WorldEditPlugin extends JavaPlugin { perms.load(); } + public boolean onCommand(Player player, Command cmd, String commandLabel, String[] args) { + if (cmd.getName().equalsIgnoreCase("reloadwe") + && hasPermission(player, "reloadwe")) { + try { + loadConfiguration(); + player.sendMessage("WorldEdit configuration reloaded."); + } catch (Throwable t) { + player.sendMessage("Error while reloading: " + + t.getMessage()); + } + + return true; + } + + String[] split = new String[args.length + 1]; + System.arraycopy(args, 0, split, 1, args.length); + split[0] = "/" + cmd.getName(); + + return controller.handleCommand(wrapPlayer(player), split); + } + String[] getGroups(Player player) { return perms.getGroups(player.getName()); } @@ -155,6 +177,10 @@ public class WorldEditPlugin extends JavaPlugin { return player.isOp() || perms.hasPermission(player.getName(), perm); } + BukkitPlayer wrapPlayer(Player player) { + return new BukkitPlayer(this, this.server, player); + } + public WorldEditAPI getAPI() { return api; }