This commit is contained in:
@ -39,4 +39,5 @@ dependencies {
|
||||
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'
|
||||
implementation 'it.unimi.dsi:fastutil-core:8.5.15'
|
||||
}
|
||||
|
||||
@ -20,9 +20,9 @@
|
||||
package de.steamwar.listener;
|
||||
|
||||
import de.steamwar.ConfigSystem;
|
||||
import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.TObjectIntMap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
@ -64,7 +64,7 @@ public class SteamwarConnectionListener implements Listener {
|
||||
Protocol.DirectionData directionData = Protocol.HANDSHAKE.TO_SERVER;
|
||||
Field directionDataProtocols = Protocol.DirectionData.class.getDeclaredField("protocols");
|
||||
directionDataProtocols.setAccessible(true);
|
||||
TIntObjectMap protocols = (TIntObjectMap) directionDataProtocols.get(directionData);
|
||||
Int2ObjectMap protocols = (Int2ObjectMap) directionDataProtocols.get(directionData);
|
||||
|
||||
Class<?> protocolDataClass = Class.forName("net.md_5.bungee.protocol.Protocol$ProtocolData");
|
||||
Field protocolDataPacketMap = protocolDataClass.getDeclaredField("packetMap");
|
||||
@ -82,44 +82,13 @@ public class SteamwarConnectionListener implements Listener {
|
||||
for (int version : ProtocolConstants.SUPPORTED_VERSION_IDS) {
|
||||
Object protocolData = protocols.get(version);
|
||||
|
||||
TObjectIntMap<Class<? extends DefinedPacket>> packetMap = (TObjectIntMap<Class<? extends DefinedPacket>>) protocolDataPacketMap.get(protocolData);
|
||||
Object2IntMap<Class<? extends DefinedPacket>> packetMap = (Object2IntMap<Class<? extends DefinedPacket>>) protocolDataPacketMap.get(protocolData);
|
||||
Supplier<? extends DefinedPacket>[] packetConstructors = (Supplier<? extends DefinedPacket>[]) 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_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)
|
||||
.filter(m -> m.getParameterTypes()[0] == Class.class)
|
||||
.filter(m -> m.getParameterTypes()[1] == Supplier.class)
|
||||
.filter(m -> m.getParameterTypes()[2].isArray())
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("Could not find registerPacket method"));
|
||||
method.setAccessible(true);
|
||||
Object protocolMappingArray = Array.newInstance(protocolMappingClazz, 1);
|
||||
Array.set(protocolMappingArray, 0, protocolMapping);
|
||||
method.invoke(o, Handshake.class, new Supplier<Handshake>() {
|
||||
@Override
|
||||
public Handshake get() {
|
||||
return new SteamwarHandshake();
|
||||
}
|
||||
}, protocolMappingArray);
|
||||
*/
|
||||
|
||||
chField = InitialHandler.class.getDeclaredField("ch");
|
||||
chField.setAccessible(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user