From eba91cac5fd5f0eb2d4c424c11b858211622f585 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sat, 18 Aug 2018 19:42:45 +1000 Subject: [PATCH] Added a config option to entirely disable server side cui. --- worldedit-bukkit/src/main/resources/defaults/config.yml | 1 + .../src/main/java/com/sk89q/worldedit/LocalConfiguration.java | 1 + .../src/main/java/com/sk89q/worldedit/LocalSession.java | 4 ++++ .../java/com/sk89q/worldedit/command/GeneralCommands.java | 4 ++++ .../com/sk89q/worldedit/util/PropertiesConfiguration.java | 1 + .../main/java/com/sk89q/worldedit/util/YAMLConfiguration.java | 1 + .../worldedit/sponge/config/ConfigurateConfiguration.java | 1 + 7 files changed, 13 insertions(+) diff --git a/worldedit-bukkit/src/main/resources/defaults/config.yml b/worldedit-bukkit/src/main/resources/defaults/config.yml index fd931081f..a01430cfd 100644 --- a/worldedit-bukkit/src/main/resources/defaults/config.yml +++ b/worldedit-bukkit/src/main/resources/defaults/config.yml @@ -143,3 +143,4 @@ no-double-slash: false no-op-permissions: false debug: false show-help-on-first-use: true +server-side-cui: true \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 2d931f91f..81b4d892a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -134,6 +134,7 @@ public abstract class LocalConfiguration { public int butcherDefaultRadius = -1; public int butcherMaxRadius = -1; public boolean allowSymlinks = false; + public boolean serverSideCUI = true; /** * Load the configuration. 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 ff3118d34..aa09fbe0e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -636,6 +636,10 @@ public class LocalSession { return; // This is for players only. } + if (!config.serverSideCUI) { + return; // Disabled in config. + } + Player player = (Player) actor; if (!useServerCUI || hasCUISupport) { 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 cb8a33644..862b4398d 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 @@ -31,6 +31,7 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.input.DisallowedUsageException; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.util.command.parametric.Optional; @@ -124,6 +125,9 @@ public class GeneralCommands { @CommandPermissions("worldedit.drawsel") public void drawSelection(Player player, LocalSession session, CommandContext args) throws WorldEditException { + if (!WorldEdit.getInstance().getConfiguration().serverSideCUI) { + throw new DisallowedUsageException("This functionality is disabled in the configuration!"); + } String newState = args.getString(0, null); if (session.shouldUseServerCUI()) { if ("on".equals(newState)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 472796c4a..65f44c691 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -114,6 +114,7 @@ public class PropertiesConfiguration extends LocalConfiguration { butcherDefaultRadius = getInt("butcher-default-radius", butcherDefaultRadius); butcherMaxRadius = getInt("butcher-max-radius", butcherMaxRadius); allowSymlinks = getBool("allow-symbolic-links", allowSymlinks); + serverSideCUI = getBool("server-side-cui", serverSideCUI); LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index c6ab2b7db..84e0fc34e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -112,6 +112,7 @@ public class YAMLConfiguration extends LocalConfiguration { SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000; showHelpInfo = config.getBoolean("show-help-on-first-use", true); + serverSideCUI = config.getBoolean("server-side-cui", true); String snapshotsDir = config.getString("snapshots.directory", ""); if (!snapshotsDir.isEmpty()) { diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index e38140bb4..d824e0a8f 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -120,6 +120,7 @@ public class ConfigurateConfiguration extends LocalConfiguration { SessionManager.EXPIRATION_GRACE = node.getNode("history", "expiration").getInt(10) * 60 * 1000; showHelpInfo = node.getNode("show-help-on-first-use").getBoolean(true); + serverSideCUI = node.getNode("server-side-cui").getBoolean(true); String snapshotsDir = node.getNode("snapshots", "directory").getString(""); if (!snapshotsDir.isEmpty()) {