|
|
|
@ -34,7 +34,7 @@ public class TinyProtocol {
|
|
|
|
|
|
|
|
|
|
// Used in order to lookup a channel
|
|
|
|
|
private static final MethodInvoker getPlayerHandle = Reflection.getMethod("{obc}.entity.CraftPlayer", "getHandle");
|
|
|
|
|
private static final Class<Object> playerConnection = Reflection.getUntypedClass("{nms.network}.PlayerConnection");
|
|
|
|
|
private static final Class<Object> playerConnection = Reflection.getUntypedClass("{nms.server.network}.PlayerConnection");
|
|
|
|
|
private static final FieldAccessor<Object> getConnection = Reflection.getField("{nms.server.level}.EntityPlayer", playerConnection, 0);
|
|
|
|
|
private static final Class<Object> networkManager = Reflection.getUntypedClass("{nms.network}.NetworkManager");
|
|
|
|
|
private static final FieldAccessor<Object> getManager = Reflection.getField(playerConnection, networkManager, 0);
|
|
|
|
@ -45,16 +45,7 @@ public class TinyProtocol {
|
|
|
|
|
private static final Class<Object> serverConnectionClass = Reflection.getUntypedClass("{nms.server.network}.ServerConnection");
|
|
|
|
|
private static final FieldAccessor<Object> getMinecraftServer = Reflection.getField("{obc}.CraftServer", minecraftServerClass, 0);
|
|
|
|
|
private static final FieldAccessor<Object> getServerConnection = Reflection.getField(minecraftServerClass, serverConnectionClass, 0);
|
|
|
|
|
private static final MethodInvoker getNetworkMarkers;
|
|
|
|
|
static {
|
|
|
|
|
MethodInvoker networkMarkers;
|
|
|
|
|
try {
|
|
|
|
|
networkMarkers = Reflection.getTypedMethod(serverConnectionClass, null, List.class, serverConnectionClass);
|
|
|
|
|
} catch (IllegalStateException e) { // Paper, wtf why.
|
|
|
|
|
networkMarkers = Reflection.getTypedMethod(serverConnectionClass, null, Queue.class, serverConnectionClass);
|
|
|
|
|
}
|
|
|
|
|
getNetworkMarkers = networkMarkers;
|
|
|
|
|
}
|
|
|
|
|
private static final FieldAccessor<Collection> getNetworkMarkers = Reflection.getField(serverConnectionClass, Collection.class, 1);
|
|
|
|
|
|
|
|
|
|
// Packets we have to intercept
|
|
|
|
|
private static final Class<?> PACKET_LOGIN_IN_START = Reflection.getClass("{nms.network.protocol.login}.PacketLoginInStart");
|
|
|
|
@ -86,6 +77,10 @@ public class TinyProtocol {
|
|
|
|
|
|
|
|
|
|
public static final TinyProtocol instance = new TinyProtocol(Core.getInstance());
|
|
|
|
|
|
|
|
|
|
public static void init() {
|
|
|
|
|
//enforce init
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TinyProtocol(final Plugin plugin) {
|
|
|
|
|
this.plugin = plugin;
|
|
|
|
|
|
|
|
|
@ -187,7 +182,7 @@ public class TinyProtocol {
|
|
|
|
|
boolean looking = true;
|
|
|
|
|
|
|
|
|
|
// We need to synchronize against this list
|
|
|
|
|
networkManagers = (Collection<Object>) getNetworkMarkers.invoke(null, serverConnection);
|
|
|
|
|
networkManagers = getNetworkMarkers.get(serverConnection);
|
|
|
|
|
createServerChannelHandler();
|
|
|
|
|
|
|
|
|
|
// Find the correct list, or implicitly throw an exception
|
|
|
|
|