From a27808ade12944f854d3add43c5d74be9569536e Mon Sep 17 00:00:00 2001 From: mmxw11 Date: Thu, 5 Oct 2017 22:05:53 +0300 Subject: [PATCH] Add config for quick move action patch --- .../ViaVersion/bukkit/platform/BukkitConfigAPI.java | 5 +++++ .../ViaVersion/bukkit/platform/BukkitViaLoader.java | 4 +++- .../ViaVersion/bungee/platform/BungeeConfigAPI.java | 7 ++++++- .../java/us/myles/ViaVersion/api/ViaVersionConfig.java | 9 ++++++++- .../protocol1_12to1_11_1/packets/InventoryPackets.java | 6 +++++- common/src/main/resources/assets/viaversion/config.yml | 2 ++ .../ViaVersion/sponge/platform/SpongeConfigAPI.java | 7 ++++++- 7 files changed, 35 insertions(+), 5 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 b4ccbc593..b95e0b5c1 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 @@ -164,6 +164,11 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig { public boolean is1_12NBTArrayFix() { return getBoolean("chat-nbt-fix", true); } + + @Override + public boolean is1_12QuickMoveActionFix() { + return getBoolean("quick-move-action-fix", true); + } @Override public List getBlockedProtocols() { diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java index 3d2a53084..d511ec0d1 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java @@ -64,7 +64,9 @@ public class BukkitViaLoader implements ViaPlatformLoader { /* Providers */ Via.getManager().getProviders().use(BulkChunkTranslatorProvider.class, new BukkitViaBulkChunkTranslator()); Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BukkitViaMovementTransmitter()); - Via.getManager().getProviders().use(InvContainerItemProvider.class, new BukkitInvContainerItemProvider()); + if (plugin.getConf().is1_12QuickMoveActionFix()) { + Via.getManager().getProviders().use(InvContainerItemProvider.class, new BukkitInvContainerItemProvider()); + } Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() { @Override public Item getHandItem(final UserConnection info) { 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 a69b8e056..e4f8d7a1f 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 @@ -10,7 +10,7 @@ import java.net.URL; import java.util.*; public class BungeeConfigAPI extends Config implements ViaVersionConfig { - private static List UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch"); + private static List UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix"); public BungeeConfigAPI(File configFile) { super(new File(configFile, "config.yml")); @@ -203,6 +203,11 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig { public boolean is1_12NBTArrayFix() { return getBoolean("chat-nbt-fix", true); } + + @Override + public boolean is1_12QuickMoveActionFix() { + return false; + } @Override public List getBlockedProtocols() { 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 90f85ff39..98578e5d0 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -209,7 +209,14 @@ public interface ViaVersionConfig { * @return True if enabled */ boolean is1_12NBTArrayFix(); - + + /** + * Should we fix shift quick move action for 1.12 clients + * + * @return True if enabled + */ + boolean is1_12QuickMoveActionFix(); + /** * Get the blocked protocols * diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java index 743d52d0f..4a473ec48 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java @@ -120,9 +120,13 @@ public class InventoryPackets { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { + Item item = wrapper.get(Type.ITEM, 0); + if (!Via.getConfig().is1_12QuickMoveActionFix()) { + BedRewriter.toServerItem(item); + return; + } byte button = wrapper.get(Type.BYTE, 0); int mode = wrapper.get(Type.VAR_INT, 0); - Item item = wrapper.get(Type.ITEM, 0); // QUICK_MOVE PATCH (Shift + (click/double click)) if (mode == 1 && button == 0 && item == null) { short windowId = wrapper.get(Type.UNSIGNED_BYTE, 0); diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 43855685b..a90a40505 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -84,6 +84,8 @@ hologram-y: -0.96 piston-animation-patch: false # Should we fix nbt for 1.12 and above clients in chat messages (causes invalid item) chat-nbt-fix: true +# Should we fix shift quick move action for 1.12 clients (causes shift + double click not to work when moving items) (only works on 1.8-1.11.2 bukkit based servers) +quick-move-action-fix: true # #----------------------------------------------------------# # 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 5910be1f1..da5cd7dcc 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 @@ -13,7 +13,7 @@ import java.util.Map; import java.util.Optional; public class SpongeConfigAPI extends Config implements ViaVersionConfig { - private static List UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers"); + private static List UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "quick-move-action-fix"); private final PluginContainer pluginContainer; public SpongeConfigAPI(PluginContainer pluginContainer, File configFile) { @@ -185,6 +185,11 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig { public boolean is1_12NBTArrayFix() { return getBoolean("chat-nbt-fix", true); } + + @Override + public boolean is1_12QuickMoveActionFix() { + return false; + } @Override public List getBlockedProtocols() {