diff --git a/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/LegacyPacketHandler.java b/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/LegacyPacketHandler.java index 4b28019b..854b5355 100644 --- a/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/LegacyPacketHandler.java +++ b/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/LegacyPacketHandler.java @@ -45,7 +45,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler { } cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED); - if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input); + if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input); } else return true; for (Field field : Reflection.getFields(packetObj)) { diff --git a/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/ModernPacketHandler.java b/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/ModernPacketHandler.java index 73fde5ce..ce41a6e8 100644 --- a/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/ModernPacketHandler.java +++ b/src/main/java/de/rayzs/pat/api/netty/bukkit/handlers/ModernPacketHandler.java @@ -59,7 +59,7 @@ public class ModernPacketHandler implements BukkitPacketHandler { } cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED); - if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input); + if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input); } if(is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) { diff --git a/src/main/java/de/rayzs/pat/api/netty/proxy/BungeePacketAnalyzer.java b/src/main/java/de/rayzs/pat/api/netty/proxy/BungeePacketAnalyzer.java index 99ad2ccb..15c7f30a 100644 --- a/src/main/java/de/rayzs/pat/api/netty/proxy/BungeePacketAnalyzer.java +++ b/src/main/java/de/rayzs/pat/api/netty/proxy/BungeePacketAnalyzer.java @@ -197,7 +197,8 @@ public class BungeePacketAnalyzer { if(!playerInput.equals("/")) { cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server); - if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", "")); + + if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")); } final String cursor = playerInput; if(cursor.startsWith("/")) { diff --git a/src/main/java/de/rayzs/pat/api/netty/proxy/VelocityPacketAnalyzer.java b/src/main/java/de/rayzs/pat/api/netty/proxy/VelocityPacketAnalyzer.java index 3666c665..24d9db86 100644 --- a/src/main/java/de/rayzs/pat/api/netty/proxy/VelocityPacketAnalyzer.java +++ b/src/main/java/de/rayzs/pat/api/netty/proxy/VelocityPacketAnalyzer.java @@ -194,7 +194,7 @@ public class VelocityPacketAnalyzer { if(!playerInput.equals("/")) { cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server); - if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", "")); + if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")); } final String cursor = playerInput; diff --git a/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomPluginsSection.java b/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomPluginsSection.java index f34a35f0..e9331e25 100644 --- a/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomPluginsSection.java +++ b/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomPluginsSection.java @@ -6,7 +6,7 @@ import java.util.*; public class CustomPluginsSection extends ConfigStorage { - public boolean ENABLED; + public boolean ENABLED, ALWAYS_TAB_COMPLETABLE; public MultipleMessagesHelper MESSAGE, COMMANDS; public CustomPluginsSection() { @@ -17,10 +17,18 @@ public class CustomPluginsSection extends ConfigStorage { public void load() { super.load(); ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); + ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper(this, "always-tab-completable", false).getOrSet(); COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins", "bukkit:pl", "bukkit:plugins")); MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fPlugins (0):")); } + public boolean isTabCompletable(String command) { + if (!isCommand(command)) + return false; + + return ALWAYS_TAB_COMPLETABLE; + } + public boolean isCommand(String command) { if(!ENABLED) return false; diff --git a/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomVersionSection.java b/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomVersionSection.java index b91ce065..b92d8efe 100644 --- a/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomVersionSection.java +++ b/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomVersionSection.java @@ -7,7 +7,7 @@ import java.util.*; public class CustomVersionSection extends ConfigStorage { - public boolean ENABLED; + public boolean ENABLED, ALWAYS_TAB_COMPLETABLE; public MultipleMessagesHelper MESSAGE, COMMANDS; public CustomVersionSection() { @@ -18,10 +18,18 @@ public class CustomVersionSection extends ConfigStorage { public void load() { super.load(); ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); + ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper(this, "always-tab-completable", false).getOrSet(); COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "ver", "version", "bukkit:ver", "bukkit:version")); MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)")); } + public boolean isTabCompletable(String command) { + if (!isCommand(command)) + return false; + + return ALWAYS_TAB_COMPLETABLE; + } + public boolean isCommand(String command) { if(!ENABLED) return false; command = StringUtils.getFirstArg(command); diff --git a/src/main/resources/files/bukkit-config.yml b/src/main/resources/files/bukkit-config.yml index f6d45af5..9b1f0a22 100644 --- a/src/main/resources/files/bukkit-config.yml +++ b/src/main/resources/files/bukkit-config.yml @@ -90,10 +90,13 @@ cancel-blocked-commands: - '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!' #>> HTP (Overwritten) -# Here you can customize your own fake '/plugins' command. -# WARNING: Commands in there are always tab-completable, if it's enabled. custom-plugins: enabled: true + + # If this is set to true, the command will always be tab-completable, + # even if the command is supposed to be blocked + always-tab-completable: false + commands: - pl - plugins @@ -104,9 +107,13 @@ custom-plugins: #>> HTP (Overwritten) # Here you can customize your own fake '/version' command. -# WARNING: Commands in there are always tab-completable, if it's enabled. custom-version: enabled: true + + # If this is set to true, the command will always be tab-completable, + # even if the command is supposed to be blocked + always-tab-completable: false + commands: - version - ver diff --git a/src/main/resources/files/proxy-config.yml b/src/main/resources/files/proxy-config.yml index d6373f8b..991639ed 100644 --- a/src/main/resources/files/proxy-config.yml +++ b/src/main/resources/files/proxy-config.yml @@ -73,9 +73,13 @@ cancel-blocked-commands: - '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!' # Here you can customize your own fake '/plugins' command. -# WARNING: Commands in there are always tab-completable, if it's enabled. custom-plugins: enabled: true + + # If this is set to true, the command will always be tab-completable, + # even if the command is supposed to be blocked + always-tab-completable: false + commands: - pl - plugins @@ -85,9 +89,13 @@ custom-plugins: - '&fPlugins (0):' # Here you can customize your own fake '/version' command. -# WARNING: Commands in there are always tab-completable, if it's enabled. custom-version: enabled: true + + # If this is set to true, the command will always be tab-completable, + # even if the command is supposed to be blocked + always-tab-completable: false + commands: - version - ver