From 20b67db48d0a55ec4b4b4c9244f4913536be918d Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sat, 18 Aug 2018 16:34:32 +1000 Subject: [PATCH] Added a command to turn it on/off --- .../com/sk89q/worldedit/LocalSession.java | 16 ++++++++-- .../worldedit/command/GeneralCommands.java | 32 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 18e1d40c6..ff3118d34 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -618,6 +618,14 @@ public class LocalSession { public void tellVersion(Actor player) { } + public boolean shouldUseServerCUI() { + return this.useServerCUI; + } + + public void setUseServerCUI(boolean useServerCUI) { + this.useServerCUI = useServerCUI; + } + /** * Update server-side WorldEdit CUI. * @@ -628,12 +636,16 @@ public class LocalSession { return; // This is for players only. } + Player player = (Player) actor; + if (!useServerCUI || hasCUISupport) { + if (cuiTemporaryBlock != null) { + player.sendFakeBlock(cuiTemporaryBlock, null); + cuiTemporaryBlock = null; + } return; // If it's not enabled, ignore this. } - Player player = (Player) actor; - // Remove the old block. if (cuiTemporaryBlock != null) { player.sendFakeBlock(cuiTemporaryBlock, null); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 3e1ecec7b..cb8a33644 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -114,6 +114,38 @@ public class GeneralCommands { } } + @Command( + aliases = { "/drawsel" }, + usage = "[on|off]", + desc = "Toggle drawing the current selection", + min = 0, + max = 1 + ) + @CommandPermissions("worldedit.drawsel") + public void drawSelection(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + String newState = args.getString(0, null); + if (session.shouldUseServerCUI()) { + if ("on".equals(newState)) { + player.printError("Server CUI already enabled."); + return; + } + + session.setUseServerCUI(false); + session.updateServerCUI(player); + player.print("Server CUI disabled."); + } else { + if ("off".equals(newState)) { + player.printError("Server CUI already disabled."); + return; + } + + session.setUseServerCUI(true); + session.updateServerCUI(player); + player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32."); + } + } + @Command( aliases = { "/gmask", "gmask" }, usage = "[mask]",