From 94ab610da75c54dd5e3303eb286575a2ec3ee7d4 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 12 Mar 2011 02:27:43 -0800 Subject: [PATCH] Added greater coverage for CUI for region adjustments. --- plugin.yml | 130 +++++++++--------- src/com/sk89q/worldedit/LocalSession.java | 39 ++++-- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 6 +- .../worldedit/commands/SelectionCommands.java | 12 ++ .../regions/CuboidRegionSelector.java | 11 ++ .../regions/Polygonal2DRegionSelector.java | 3 + .../worldedit/regions/RegionSelector.java | 9 ++ 7 files changed, 129 insertions(+), 81 deletions(-) diff --git a/plugin.yml b/plugin.yml index 450ff2786..48fc682a9 100644 --- a/plugin.yml +++ b/plugin.yml @@ -11,9 +11,6 @@ commands: delchunks: description: Delete chunks that your selection includes usage: / - clearclipboard: - description: Clear your clipboard - usage: / /load: description: Load a schematic into your clipboard usage: / @@ -35,6 +32,12 @@ commands: /paste: description: Paste the clipboard's contents usage: / [-ao] + clearclipboard: + description: Clear your clipboard + usage: / + /limit: + description: Modify block change limit + usage: / we: description: WorldEdit commands usage: / @@ -46,9 +49,6 @@ commands: description: Search for an item usage: / [-bi] aliases: ['/l', 'search'] - /limit: - description: Modify block change limit - usage: / /hcyl: description: Generate a hollow cylinder usage: / [height] @@ -67,17 +67,17 @@ commands: pumpkins: description: Generate pumpkin patches usage: / [size] - clearhistory: - description: Clear your history - usage: / - /redo: - description: Redoes the last action (from history) - usage: / [times] - aliases: ['redo'] /undo: description: Undoes the last action usage: / [times] aliases: ['undo'] + /redo: + description: Redoes the last action (from history) + usage: / [times] + aliases: ['redo'] + clearhistory: + description: Clear your history + usage: / unstuck: description: Escape from being stuck inside a block usage: / @@ -87,18 +87,27 @@ commands: descend: description: Go down a floor usage: / + ceil: + description: Go to the celing + usage: / [clearance] thru: description: Passthrough walls usage: / jumpto: description: Teleport to a location usage: / - ceil: - description: Go to the celing - usage: / [clearance] up: description: Go upwards some distance usage: / + /replace: + description: Replace all blocks in the selection with another + usage: / [from-block] + /stack: + description: Repeat the contents of the selection + usage: / [-a] [count] [direction] + /set: + description: Set all the blocks inside the selection to a block + usage: / /overlay: description: Set a block on top of blocks in the region usage: / @@ -112,24 +121,24 @@ commands: /smooth: description: Smooth the elevation in the selection usage: / [iterations] - /replace: - description: Replace all blocks in the selection with another - usage: / [from-block] - /stack: - description: Repeat the contents of the selection - usage: / [-a] [count] [direction] - /set: - description: Set all the blocks inside the selection to a block - usage: / /move: description: Move the contents of the selection usage: / [count] [direction] [leave-id] - .s: - description: Execute last CraftScript - usage: / [args...] cs: description: Execute a CraftScript usage: / [args...] + .s: + description: Execute last CraftScript + usage: / [args...] + /count: + description: Counts the number of a certain type of block + usage: / + /size: + description: Get information about the selection + usage: / + /shift: + description: Shift the selection area + usage: / [direction] /chunk: description: Set the selection to your current chunk usage: / @@ -151,34 +160,25 @@ commands: toggleeditwand: description: Toggle functionality of the edit wand usage: / + /expand: + description: Expand the selection area + usage: / [reverse-amount] /contract: description: Contract the selection area usage: / [reverse-amount] [direction] /outset: description: Outset the selection area usage: / [-hv] + /inset: + description: Inset the selection area + usage: / [-hv] /distr: description: Get the distribution of blocks in the selection usage: / [-c] - /count: - description: Counts the number of a certain type of block - usage: / - /size: - description: Get information about the selection - usage: / - /shift: - description: Shift the selection area - usage: / [direction] - /expand: - description: Expand the selection area - usage: / [reverse-amount] /sel: description: Choose a region selector usage: / [type] aliases: [','] - /inset: - description: Inset the selection area - usage: / [-hv] snapshot: description: Snapshot commands usage: / @@ -187,6 +187,12 @@ commands: description: Restore the selection from a snapshot usage: / [snapshot] aliases: ['/restore'] + size: + description: Set the brush size + usage: / [pattern] + mask: + description: Set the brush mask + usage: / [mask] /: description: Toggle the super pickaxe pickaxe function usage: / @@ -202,15 +208,15 @@ commands: description: Set the brush material usage: / [pattern] aliases: ['material', 'fill'] - size: - description: Set the brush size - usage: / [pattern] - mask: - description: Set the brush mask - usage: / [mask] + info: + description: Block information tool + usage: / none: description: Turn off all superpickaxe alternate modes usage: / + tree: + description: Tree generator tool + usage: / [type] repl: description: Block replacer tool usage: / @@ -221,15 +227,19 @@ commands: description: Brush tool usage: / aliases: ['br'] - info: - description: Block information tool - usage: / - tree: - description: Tree generator tool - usage: / [type] + remove: + description: Remove all entities of a type + usage: / + aliases: ['rem', 'rement'] + /fill: + description: Fill a hole + usage: / [depth] /fillr: description: Fill a hole recursively usage: / [depth] + /drain: + description: Drain a pool + usage: / fixlava: description: Fix lava to be stationary usage: / @@ -261,13 +271,3 @@ commands: butcher: description: Kill all or nearby mobs usage: / [radius] - remove: - description: Remove all entities of a type - usage: / - aliases: ['rem', 'rement'] - /fill: - description: Fill a hole - usage: / [depth] - /drain: - description: Drain a pool - usage: / diff --git a/src/com/sk89q/worldedit/LocalSession.java b/src/com/sk89q/worldedit/LocalSession.java index 41a4d503d..034416713 100644 --- a/src/com/sk89q/worldedit/LocalSession.java +++ b/src/com/sk89q/worldedit/LocalSession.java @@ -530,21 +530,34 @@ public class LocalSession { } if (selector != null) { - player.dispatchCUIEvent( - new SelectionShapeEvent(selector.getTypeId())); + dispatchCUISelection(player); + } + } + + /** + * Send the selection information. + * + * @param player + */ + public void dispatchCUISelection(LocalPlayer player) { + if (!hasCUISupport) { + return; + } + + player.dispatchCUIEvent( + new SelectionShapeEvent(selector.getTypeId())); + + if (selector instanceof CUIPointBasedRegion) { + Vector[] points = ((CUIPointBasedRegion) selector).getCUIPoints(); + int size = selector.getArea(); - if (selector instanceof CUIPointBasedRegion) { - Vector[] points = ((CUIPointBasedRegion) selector).getCUIPoints(); - int size = selector.getArea(); - - int i = 0; - for (Vector pt : points) { - if (pt != null) { - player.dispatchCUIEvent( - new SelectionPointEvent(i, pt, size)); - } - i++; + int i = 0; + for (Vector pt : points) { + if (pt != null) { + player.dispatchCUIEvent( + new SelectionPointEvent(i, pt, size)); } + i++; } } } diff --git a/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 5734eeedb..3ffb3e0fa 100644 --- a/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -122,15 +122,15 @@ public class BukkitPlayer extends LocalPlayer { String[] params = event.getParameters(); if (params.length > 0) { - printRaw("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId() + player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId() + "|" + StringUtil.joinString(params, "|")); } else { - printRaw("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()); + player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75" + event.getTypeId()); } } @Override public void dispatchCUIHandshake() { - printRaw("\u00A75\u00A76\u00A74\u00A75"); + player.sendRawMessage("\u00A75\u00A76\u00A74\u00A75"); } } diff --git a/src/com/sk89q/worldedit/commands/SelectionCommands.java b/src/com/sk89q/worldedit/commands/SelectionCommands.java index 77fb14318..94daaefb5 100644 --- a/src/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/com/sk89q/worldedit/commands/SelectionCommands.java @@ -160,6 +160,8 @@ public class SelectionCommands { selector.selectPrimary(min); selector.selectSecondary(max); session.setRegionSelector(player.getWorld(), selector); + + session.dispatchCUISelection(player); player.print("Chunk selected: " + min2D.getBlockX() + ", " + min2D.getBlockZ()); @@ -268,6 +270,8 @@ public class SelectionCommands { session.getRegionSelector().learnChanges(); int newSize = region.getArea(); + session.getRegionSelector().explainRegionAdjust(player, session); + player.print("Region expanded " + (newSize - oldSize) + " blocks."); } @@ -315,6 +319,8 @@ public class SelectionCommands { session.getRegionSelector().learnChanges(); int newSize = region.getArea(); + session.getRegionSelector().explainRegionAdjust(player, session); + player.print("Region contracted " + (oldSize - newSize) + " blocks."); } catch (RegionOperationException e) { player.printError(e.getMessage()); @@ -348,6 +354,8 @@ public class SelectionCommands { region.contract(dir.multiply(change)); session.getRegionSelector().learnChanges(); + session.getRegionSelector().explainRegionAdjust(player, session); + player.print("Region shifted."); } catch (RegionOperationException e) { player.printError(e.getMessage()); @@ -385,6 +393,8 @@ public class SelectionCommands { session.getRegionSelector().learnChanges(); + session.getRegionSelector().explainRegionAdjust(player, session); + player.print("Region outset."); } catch (RegionOperationException e) { player.printError(e.getMessage()); @@ -421,6 +431,8 @@ public class SelectionCommands { session.getRegionSelector().learnChanges(); + session.getRegionSelector().explainRegionAdjust(player, session); + player.print("Region inset."); } diff --git a/src/com/sk89q/worldedit/regions/CuboidRegionSelector.java b/src/com/sk89q/worldedit/regions/CuboidRegionSelector.java index 04c06da82..77c59ed49 100644 --- a/src/com/sk89q/worldedit/regions/CuboidRegionSelector.java +++ b/src/com/sk89q/worldedit/regions/CuboidRegionSelector.java @@ -82,6 +82,17 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea())); } + + public void explainRegionAdjust(LocalPlayer player, LocalSession session) { + if (pos1 != null) { + session.dispatchCUIEvent(player, + new SelectionPointEvent(0, pos1, getArea())); + } + if (pos2 != null) { + session.dispatchCUIEvent(player, + new SelectionPointEvent(1, pos2, getArea())); + } + } public BlockVector getPrimaryPosition() throws IncompleteRegionException { if (pos1 == null) { diff --git a/src/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java b/src/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java index 09d87d374..ca49e19e5 100644 --- a/src/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java +++ b/src/com/sk89q/worldedit/regions/Polygonal2DRegionSelector.java @@ -77,6 +77,9 @@ public class Polygonal2DRegionSelector implements RegionSelector { player.print("Added point #" + region.size() + " at " + pos + "."); } + public void explainRegionAdjust(LocalPlayer player, LocalSession session) { + } + public BlockVector getPrimaryPosition() throws IncompleteRegionException { if (pos1 == null) { throw new IncompleteRegionException(); diff --git a/src/com/sk89q/worldedit/regions/RegionSelector.java b/src/com/sk89q/worldedit/regions/RegionSelector.java index 944b63208..a66fa52c3 100644 --- a/src/com/sk89q/worldedit/regions/RegionSelector.java +++ b/src/com/sk89q/worldedit/regions/RegionSelector.java @@ -68,6 +68,15 @@ public interface RegionSelector { public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos); + /** + * The the player information about the region's changes. This may resend + * all the defining region information if needed. + * + * @param player + * @param session + */ + public void explainRegionAdjust(LocalPlayer player, LocalSession session); + /** * Get the primary position. *