From 851ed5adc044302bd22ebf16e39a58a767373fed Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 28 Apr 2024 01:01:30 +0200 Subject: [PATCH] Support 1.20.5 spigot, update languages module, update Bungee dependency so the project builds (#498) --- bungee/build.gradle.kts | 4 ++-- core/src/main/resources/languages | 2 +- .../floodgate/addon/data/SpigotDataHandler.java | 4 ++-- .../org/geysermc/floodgate/util/ClassNames.java | 17 +++++++++++++---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bungee/build.gradle.kts b/bungee/build.gradle.kts index b438a04e..0d228850 100644 --- a/bungee/build.gradle.kts +++ b/bungee/build.gradle.kts @@ -1,4 +1,4 @@ -var bungeeCommit = "master-SNAPSHOT" +var bungeeVersion = "1.20-R0.3-SNAPSHOT" var gsonVersion = "2.8.0" var guavaVersion = "21.0" @@ -16,6 +16,6 @@ relocate("io.leangen.geantyref") relocate("org.yaml") // these dependencies are already present on the platform -provided("com.github.SpigotMC.BungeeCord", "bungeecord-proxy", bungeeCommit) +provided("net.md-5", "bungeecord-proxy", bungeeVersion) provided("com.google.code.gson", "gson", gsonVersion) provided("com.google.guava", "guava", guavaVersion) diff --git a/core/src/main/resources/languages b/core/src/main/resources/languages index 204f4fe4..df599a9b 160000 --- a/core/src/main/resources/languages +++ b/core/src/main/resources/languages @@ -1 +1 @@ -Subproject commit 204f4fe4920defac3a472e762d95233d0756f35f +Subproject commit df599a9bc9d7fce93a586591d6c0d625eefe4463 diff --git a/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java b/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java index 75e7057c..36f34e9d 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java +++ b/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java @@ -68,9 +68,9 @@ protected Object setHostname(Object handshakePacket, String hostname) throws Ill // 1.20.2 and above try { Object[] components = new Object[]{ - ClassNames.HANDSHAKE_PORT.get(handshakePacket), - hostname, ClassNames.HANDSHAKE_PROTOCOL.get(handshakePacket), + hostname, + ClassNames.HANDSHAKE_PORT.get(handshakePacket), ClassNames.HANDSHAKE_INTENTION.get(handshakePacket) }; diff --git a/spigot/src/main/java/org/geysermc/floodgate/util/ClassNames.java b/spigot/src/main/java/org/geysermc/floodgate/util/ClassNames.java index b0eee8f0..d93548c6 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/util/ClassNames.java +++ b/spigot/src/main/java/org/geysermc/floodgate/util/ClassNames.java @@ -293,14 +293,23 @@ public class ClassNames { String.class, int.class, CLIENT_INTENT); checkNotNull(HANDSHAKE_PACKET_CONSTRUCTOR, "Handshake packet constructor"); - HANDSHAKE_PORT = getField(HANDSHAKE_PACKET, "a"); - checkNotNull(HANDSHAKE_PORT, "Handshake port"); - makeAccessible(HANDSHAKE_PORT); + Field a = getField(HANDSHAKE_PACKET, "a"); + checkNotNull(a, "Handshake \"a\" field (protocol version, or stream codec)"); + + if (a.getType().isPrimitive()) { // 1.20.2 - 1.20.4: a is the protocol version (int) + HANDSHAKE_PROTOCOL = a; + HANDSHAKE_PORT = getField(HANDSHAKE_PACKET, "c"); + } else { // 1.20.5: a is the stream_codec thing, so everything is shifted + HANDSHAKE_PROTOCOL = getField(HANDSHAKE_PACKET, "b"); + HANDSHAKE_PORT = getField(HANDSHAKE_PACKET, "d"); + } - HANDSHAKE_PROTOCOL = getField(HANDSHAKE_PACKET, "c"); checkNotNull(HANDSHAKE_PROTOCOL, "Handshake protocol"); makeAccessible(HANDSHAKE_PROTOCOL); + checkNotNull(HANDSHAKE_PORT, "Handshake port"); + makeAccessible(HANDSHAKE_PORT); + HANDSHAKE_INTENTION = getFieldOfType(HANDSHAKE_PACKET, CLIENT_INTENT); checkNotNull(HANDSHAKE_INTENTION, "Handshake intention"); makeAccessible(HANDSHAKE_INTENTION);