diff --git a/build.gradle b/build.gradle index 67bed4b..2e08343 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ plugins { group = 'de.steamwar' version = '' -sourceCompatibility = 11 -targetCompatibility = 11 +sourceCompatibility = 8 +targetCompatibility = 8 sourceSets { main { @@ -36,7 +36,7 @@ dependencies { annotationProcessor 'org.projectlombok:lombok:1.18.22' testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' - compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT' - compileOnly 'net.md-5:bungeecord-proxy:1.20-R0.3-SNAPSHOT' - implementation 'codecrafter47.bungeetablistplus:bungeetablistplus-api-bungee:3.5.2' + compileOnly 'net.md-5:bungeecord-api:1.21-R0.1-SNAPSHOT' + compileOnly 'net.md-5:bungeecord-proxy:1.21-R0.1-SNAPSHOT' + // compileOnly 'codecrafter47.bungeetablistplus:bungeetablistplus-api-bungee:3.5.2' } diff --git a/src/bungee.yml b/src/bungee.yml index 9093d06..8744acf 100644 --- a/src/bungee.yml +++ b/src/bungee.yml @@ -1,6 +1,3 @@ name: SteamWarTeamserverIntegration -version: 1.0.0 +version: '1.0.0' main: de.steamwar.SteamWarBungeeTeamserver - -softDepends: - - BungeeTabListPlus diff --git a/src/de/steamwar/listener/SteamwarConnectionListener.java b/src/de/steamwar/listener/SteamwarConnectionListener.java index ee330ab..59977df 100644 --- a/src/de/steamwar/listener/SteamwarConnectionListener.java +++ b/src/de/steamwar/listener/SteamwarConnectionListener.java @@ -20,7 +20,8 @@ package de.steamwar.listener; import de.steamwar.ConfigSystem; -import de.steamwar.utils.BungeeTabListPlusFixer; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.TObjectIntMap; import io.netty.buffer.ByteBuf; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.chat.TextComponent; @@ -31,15 +32,14 @@ import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.netty.ChannelWrapper; +import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.packet.Handshake; -import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetSocketAddress; -import java.util.Arrays; import java.util.Set; import java.util.UUID; import java.util.function.Supplier; @@ -61,14 +61,46 @@ public class SteamwarConnectionListener implements Listener { { try { + Protocol.DirectionData directionData = Protocol.HANDSHAKE.TO_SERVER; + Field directionDataProtocols = Protocol.DirectionData.class.getDeclaredField("protocols"); + directionDataProtocols.setAccessible(true); + TIntObjectMap protocols = (TIntObjectMap) directionDataProtocols.get(directionData); + + Class protocolDataClass = Class.forName("net.md_5.bungee.protocol.Protocol$ProtocolData"); + Field protocolDataPacketMap = protocolDataClass.getDeclaredField("packetMap"); + protocolDataPacketMap.setAccessible(true); + Field protocolDataPacketConstructors = protocolDataClass.getDeclaredField("packetConstructors"); + protocolDataPacketConstructors.setAccessible(true); + Method mapMethod = Protocol.class.getDeclaredMethod("map", int.class, int.class); mapMethod.setAccessible(true); Object protocolMapping = mapMethod.invoke(null, ProtocolConstants.MINECRAFT_1_8, 0x00); + Field protocolMappingPacketId = protocolMapping.getClass().getDeclaredField("packetID"); + protocolMappingPacketId.setAccessible(true); + int packetID = protocolMappingPacketId.getInt(protocolMapping); + + for (int version : ProtocolConstants.SUPPORTED_VERSION_IDS) { + Object protocolData = protocols.get(version); + + TObjectIntMap> packetMap = (TObjectIntMap>) protocolDataPacketMap.get(protocolData); + Supplier[] packetConstructors = (Supplier[]) protocolDataPacketConstructors.get(protocolData); + + packetMap.put(Handshake.class, packetID); + packetConstructors[packetID] = SteamwarHandshake::new; + } + + /* + Field FIELD_TO_SERVER = Protocol.class.getDeclaredField("TO_SERVER"); + FIELD_TO_SERVER.setAccessible(true); + Protocol.DirectionData o = FIELD_TO_SERVER.get(Protocol.HANDSHAKE); + + Class directionDataClazz = Class.forName("net.md_5.bungee.protocol.Protocol$DirectionData"); Class protocolMappingClazz = Class.forName("net.md_5.bungee.protocol.Protocol$ProtocolMapping"); - Field field = Protocol.class.getDeclaredField("TO_SERVER"); - field.setAccessible(true); - Object o = field.get(Protocol.HANDSHAKE); + + Field FIELD_PROTOCOLS = directionDataClazz.getDeclaredField("protocols"); + Object protocols = FIELD_PROTOCOLS.get(protocolMapping); + Method method = Arrays.stream(directionDataClazz.getDeclaredMethods()) .filter(m -> m.getName().equals("registerPacket")) .filter(m -> m.getParameterCount() == 3) @@ -86,6 +118,7 @@ public class SteamwarConnectionListener implements Listener { return new SteamwarHandshake(); } }, protocolMappingArray); + */ chField = InitialHandler.class.getDeclaredField("ch"); chField.setAccessible(true); @@ -102,7 +135,7 @@ public class SteamwarConnectionListener implements Listener { if (!ConfigSystem.isEnabled()) return; String address = preLoginEvent.getConnection().getSocketAddress().toString(); - if (address.startsWith("/78.31.71.136:")) { + if (address.startsWith("/178.63.72.88:")) { InitialHandler initialHandler = (InitialHandler) preLoginEvent.getConnection(); String extraData = initialHandler.getExtraDataInHandshake(); String[] split = extraData.split("\0"); @@ -158,8 +191,10 @@ public class SteamwarConnectionListener implements Listener { return; } + /* if (BungeeCord.getInstance().getPluginManager().getPlugin("BungeeTabListPlus") != null) { BungeeTabListPlusFixer.remove(postLoginEvent.getPlayer()); } + */ } } diff --git a/src/de/steamwar/utils/BungeeTabListPlusFixer.java b/src/de/steamwar/utils/BungeeTabListPlusFixer.java.txt similarity index 100% rename from src/de/steamwar/utils/BungeeTabListPlusFixer.java rename to src/de/steamwar/utils/BungeeTabListPlusFixer.java.txt