From 527b5e6f99323b5520379ad6dd6c40f69119a9f8 Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 1 Sep 2018 07:53:36 +0100 Subject: [PATCH] Allow disabling of auto-complete in 1.13 via disable-1_13-auto-complete in config #891 --- .../ViaVersion/bukkit/platform/BukkitConfigAPI.java | 5 +++++ .../ViaVersion/bungee/platform/BungeeConfigAPI.java | 5 +++++ .../us/myles/ViaVersion/api/ViaVersionConfig.java | 11 +++++++++-- .../protocol1_13to1_12_2/Protocol1_13To1_12_2.java | 4 ++++ .../src/main/resources/assets/viaversion/config.yml | 2 ++ .../ViaVersion/sponge/platform/SpongeConfigAPI.java | 5 +++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java index c46b0e21d..9df2c3112 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java @@ -209,4 +209,9 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig { public boolean isSuppress1_13ConversionErrors() { return getBoolean("suppress-1_13-conversion-errors", false); } + + @Override + public boolean isDisable1_13AutoComplete() { + return getBoolean("disable-1_13-auto-complete", false); + } } diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java index 768dd7887..b2f71c6e4 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java @@ -262,4 +262,9 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig { public boolean isSuppress1_13ConversionErrors() { return getBoolean("suppress-1_13-conversion-errors", false); } + + @Override + public boolean isDisable1_13AutoComplete() { + return getBoolean("disable-1_13-auto-complete", false); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java index cfba9fc1c..7ea5febe0 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -216,14 +216,14 @@ public interface ViaVersionConfig { * @return True if enabled */ boolean is1_13TeamColourFix(); - + /** * Should we fix shift quick move action for 1.12 clients * * @return True if enabled */ boolean is1_12QuickMoveActionFix(); - + /** * Get the blocked protocols * @@ -252,4 +252,11 @@ public interface ViaVersionConfig { * @return True if enabled */ boolean isSuppress1_13ConversionErrors(); + + /** + * Should we disable the 1.13 auto-complete feature to stop spam kicks? (for any server lower than 1.13) + * + * @return True if enabled + */ + boolean isDisable1_13AutoComplete(); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index e41bdb500..381513d4c 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -536,6 +536,10 @@ public class Protocol1_13To1_12_2 extends Protocol { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { + // Disable auto-complete if configured + if (Via.getConfig().isDisable1_13AutoComplete()) { + wrapper.cancel(); + } int tid = wrapper.read(Type.VAR_INT); // Save transaction id wrapper.user().get(TabCompleteTracker.class).setTransactionId(tid); diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 22df7ea89..b657e1b53 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -90,6 +90,8 @@ quick-move-action-fix: false team-colour-fix: true # We warn when there's a error converting from pre-1.13 to 1.13, should we suppress these? (Only suggested if spamming) suppress-1_13-conversion-errors: false +# 1.13 introduced new auto complete which can trigger "Kicked for spamming" for servers older than 1.13, the following option will disable it completely. +disable-1_13-auto-complete: false # #----------------------------------------------------------# # 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS # diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java index 0acbc44b2..e22900614 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java @@ -215,4 +215,9 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig { public boolean isSuppress1_13ConversionErrors() { return getBoolean("suppress-1_13-conversion-errors", false); } + + @Override + public boolean isDisable1_13AutoComplete() { + return getBoolean("disable-1_13-auto-complete", false); + } }