From 9ecdde2292885b2fbf95c43a386c291f735a1770 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 15 Nov 2016 02:40:46 +1100 Subject: [PATCH] Add support for Minecraft 1.11 Improve QueryHandler session handling as suggested by IchBinJoe --- api/pom.xml | 4 +- bootstrap/pom.xml | 4 +- chat/pom.xml | 4 +- config/pom.xml | 4 +- event/pom.xml | 4 +- log/pom.xml | 4 +- module/cmd-alert/pom.xml | 4 +- module/cmd-find/pom.xml | 4 +- module/cmd-list/pom.xml | 4 +- module/cmd-send/pom.xml | 4 +- module/cmd-server/pom.xml | 4 +- module/pom.xml | 4 +- module/reconnect-yaml/pom.xml | 4 +- native/pom.xml | 4 +- pom.xml | 4 +- protocol/pom.xml | 4 +- .../net/md_5/bungee/protocol/Protocol.java | 3 +- .../bungee/protocol/ProtocolConstants.java | 7 +- proxy/pom.xml | 4 +- .../net/md_5/bungee/entitymap/EntityMap.java | 2 + .../md_5/bungee/entitymap/EntityMap_1_11.java | 178 ++++++++++++++++++ query/pom.xml | 4 +- .../net/md_5/bungee/query/QueryHandler.java | 24 ++- 23 files changed, 240 insertions(+), 46 deletions(-) create mode 100644 proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java diff --git a/api/pom.xml b/api/pom.xml index bd89a6ba..43a4dd94 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-api - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-API diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index 9eb904ba..5c42c6fa 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-bootstrap - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Bootstrap diff --git a/chat/pom.xml b/chat/pom.xml index 79a774a5..e8f3fd6c 100644 --- a/chat/pom.xml +++ b/chat/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-chat - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Chat diff --git a/config/pom.xml b/config/pom.xml index c6d0a0be..5d32d0e8 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-config - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Config diff --git a/event/pom.xml b/event/pom.xml index 66881534..65a64224 100644 --- a/event/pom.xml +++ b/event/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-event - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Event diff --git a/log/pom.xml b/log/pom.xml index b970df05..22a933f2 100644 --- a/log/pom.xml +++ b/log/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-log - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Log diff --git a/module/cmd-alert/pom.xml b/module/cmd-alert/pom.xml index 31563344..223d0f6f 100644 --- a/module/cmd-alert/pom.xml +++ b/module/cmd-alert/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-alert - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar cmd_alert diff --git a/module/cmd-find/pom.xml b/module/cmd-find/pom.xml index 2a9b50f0..7635889d 100644 --- a/module/cmd-find/pom.xml +++ b/module/cmd-find/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-find - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar cmd_find diff --git a/module/cmd-list/pom.xml b/module/cmd-list/pom.xml index e68aa93b..76158bcb 100644 --- a/module/cmd-list/pom.xml +++ b/module/cmd-list/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-list - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar cmd_list diff --git a/module/cmd-send/pom.xml b/module/cmd-send/pom.xml index 7a087535..87375419 100644 --- a/module/cmd-send/pom.xml +++ b/module/cmd-send/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-send - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar cmd_send diff --git a/module/cmd-server/pom.xml b/module/cmd-server/pom.xml index d3fb072f..8a0ed9de 100644 --- a/module/cmd-server/pom.xml +++ b/module/cmd-server/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-server - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar cmd_server diff --git a/module/pom.xml b/module/pom.xml index c59ac9de..2d517465 100644 --- a/module/pom.xml +++ b/module/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT pom BungeeCord Modules diff --git a/module/reconnect-yaml/pom.xml b/module/reconnect-yaml/pom.xml index 7bd55210..c08ad70d 100644 --- a/module/reconnect-yaml/pom.xml +++ b/module/reconnect-yaml/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-reconnect-yaml - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar reconnect_yaml diff --git a/native/pom.xml b/native/pom.xml index a3bd6323..940d257e 100644 --- a/native/pom.xml +++ b/native/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-native - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Native diff --git a/pom.xml b/pom.xml index ad098893..7f9564c6 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT pom BungeeCord-Parent @@ -66,7 +66,7 @@ unknown - 4.1.5.Final + 4.1.6.Final 1.7 1.7 UTF-8 diff --git a/protocol/pom.xml b/protocol/pom.xml index bac4690c..63d04980 100644 --- a/protocol/pom.xml +++ b/protocol/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-protocol - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Protocol diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index d15d4edb..c5a7add8 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -261,7 +261,8 @@ public enum Protocol ProtocolConstants.MINECRAFT_1_9_1, ProtocolConstants.MINECRAFT_1_9_2, ProtocolConstants.MINECRAFT_1_9_4, - ProtocolConstants.MINECRAFT_1_10 + ProtocolConstants.MINECRAFT_1_10, + ProtocolConstants.MINECRAFT_1_11 ) ); } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index 8a99ff99..f3c13bf4 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -12,17 +12,20 @@ public class ProtocolConstants public static final int MINECRAFT_1_9_2 = 109; public static final int MINECRAFT_1_9_4 = 110; public static final int MINECRAFT_1_10 = 210; + public static final int MINECRAFT_1_11 = 315; public static final List SUPPORTED_VERSIONS = Arrays.asList( "1.8.x", "1.9.x", - "1.10.x" + "1.10.x", + "1.11.x" ); public static final List SUPPORTED_VERSION_IDS = Arrays.asList( ProtocolConstants.MINECRAFT_1_8, ProtocolConstants.MINECRAFT_1_9, ProtocolConstants.MINECRAFT_1_9_1, ProtocolConstants.MINECRAFT_1_9_2, ProtocolConstants.MINECRAFT_1_9_4, - ProtocolConstants.MINECRAFT_1_10 + ProtocolConstants.MINECRAFT_1_10, + ProtocolConstants.MINECRAFT_1_11 ); public enum Direction diff --git a/proxy/pom.xml b/proxy/pom.xml index 515f2eef..703fbda3 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-proxy - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Proxy diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 7eb48e09..34ddc19f 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -35,6 +35,8 @@ public abstract class EntityMap return EntityMap_1_9_4.INSTANCE; case ProtocolConstants.MINECRAFT_1_10: return EntityMap_1_10.INSTANCE; + case ProtocolConstants.MINECRAFT_1_11: + return EntityMap_1_11.INSTANCE; } throw new RuntimeException( "Version " + version + " has no entity map" ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java new file mode 100644 index 00000000..aa0fb730 --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java @@ -0,0 +1,178 @@ +package net.md_5.bungee.entitymap; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import io.netty.buffer.ByteBuf; +import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.UserConnection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.ProtocolConstants; + +import java.util.UUID; + +class EntityMap_1_11 extends EntityMap +{ + + static final EntityMap_1_11 INSTANCE = new EntityMap_1_11(); + + EntityMap_1_11() + { + addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity + addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb + addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving + addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting + addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn + addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation + addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation + addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus + addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove + addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook + addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook + addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity + addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed + addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect + addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation + addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera + addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata + addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity + addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity + addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment + addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount + addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect + addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport + addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes + addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect + + addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity + addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction + } + + @Override + @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") + public void rewriteClientbound(ByteBuf packet, int oldId, int newId) + { + super.rewriteClientbound( packet, oldId, newId ); + + // Special cases + int readerIndex = packet.readerIndex(); + int packetId = DefinedPacket.readVarInt( packet ); + int packetIdLength = packet.readerIndex() - readerIndex; + int jumpIndex = packet.readerIndex(); + switch ( packetId ) + { + case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: + rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); + break; + case 0x48 /* Collect Item : PacketPlayOutCollect */: + DefinedPacket.readVarInt( packet ); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + break; + case 0x40 /* Attach Entity : PacketPlayOutMount */: + DefinedPacket.readVarInt( packet ); + jumpIndex = packet.readerIndex(); + // Fall through on purpose to int array of IDs + case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: + int count = DefinedPacket.readVarInt( packet ); + int[] ids = new int[ count ]; + for ( int i = 0; i < count; i++ ) + { + ids[i] = DefinedPacket.readVarInt( packet ); + } + packet.readerIndex( jumpIndex ); + packet.writerIndex( jumpIndex ); + DefinedPacket.writeVarInt( count, packet ); + for ( int id : ids ) + { + if ( id == oldId ) + { + id = newId; + } else if ( id == newId ) + { + id = oldId; + } + DefinedPacket.writeVarInt( id, packet ); + } + break; + case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: + DefinedPacket.readVarInt( packet ); + DefinedPacket.readUUID( packet ); + int type = packet.readUnsignedByte(); + + if ( type == 60 || type == 90 || type == 91 ) + { + if ( type == 60 || type == 91 ) + { + oldId = oldId + 1; + newId = newId + 1; + } + + packet.skipBytes( 26 ); // double, double, double, byte, byte + int position = packet.readerIndex(); + int readId = packet.readInt(); + if ( readId == oldId ) + { + packet.setInt( position, newId ); + } else if ( readId == newId ) + { + packet.setInt( position, oldId ); + } + } + break; + case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: + DefinedPacket.readVarInt( packet ); // Entity ID + int idLength = packet.readerIndex() - readerIndex - packetIdLength; + UUID uuid = DefinedPacket.readUUID( packet ); + ProxiedPlayer player; + if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) + { + int previous = packet.writerIndex(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength + idLength ); + DefinedPacket.writeUUID( player.getUniqueId(), packet ); + packet.writerIndex( previous ); + } + break; + case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: + int event = packet.readUnsignedByte(); + if ( event == 1 /* End Combat*/ ) + { + DefinedPacket.readVarInt( packet ); + rewriteInt( packet, oldId, newId, packet.readerIndex() ); + } else if ( event == 2 /* Entity Dead */ ) + { + int position = packet.readerIndex(); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + packet.readerIndex( position ); + DefinedPacket.readVarInt( packet ); + rewriteInt( packet, oldId, newId, packet.readerIndex() ); + } + break; + } + packet.readerIndex( readerIndex ); + } + + @Override + public void rewriteServerbound(ByteBuf packet, int oldId, int newId) + { + super.rewriteServerbound( packet, oldId, newId ); + // Special cases + int readerIndex = packet.readerIndex(); + int packetId = DefinedPacket.readVarInt( packet ); + int packetIdLength = packet.readerIndex() - readerIndex; + + if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + { + UUID uuid = DefinedPacket.readUUID( packet ); + ProxiedPlayer player; + if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) + { + int previous = packet.writerIndex(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + packet.writerIndex( previous ); + } + } + packet.readerIndex( readerIndex ); + } +} diff --git a/query/pom.xml b/query/pom.xml index 8df9b12d..fbadb189 100644 --- a/query/pom.xml +++ b/query/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.10-SNAPSHOT + 1.11-SNAPSHOT ../pom.xml net.md-5 bungeecord-query - 1.10-SNAPSHOT + 1.11-SNAPSHOT jar BungeeCord-Query diff --git a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java index fd77c621..614dd94a 100644 --- a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java +++ b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java @@ -1,17 +1,19 @@ package net.md_5.bungee.query; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import io.netty.buffer.ByteBuf; import io.netty.channel.AddressedEnvelope; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.socket.DatagramPacket; -import java.nio.ByteOrder; -import java.util.HashMap; +import java.net.InetAddress; import java.util.LinkedHashMap; import java.util.Map; import java.util.Random; import java.util.concurrent.TimeUnit; import java.util.logging.Level; +import lombok.Data; import lombok.RequiredArgsConstructor; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ListenerInfo; @@ -25,11 +27,11 @@ public class QueryHandler extends SimpleChannelInboundHandler private final ListenerInfo listener; /*========================================================================*/ private final Random random = new Random(); - private final Map sessions = new HashMap<>(); + private final Cache sessions = CacheBuilder.newBuilder().expireAfterWrite( 30, TimeUnit.SECONDS).build(); private void writeShort(ByteBuf buf, int s) { - buf.order( ByteOrder.LITTLE_ENDIAN ).writeShort( s ); + buf.writeShortLE( s ); } private void writeNumber(ByteBuf buf, int i) @@ -68,7 +70,7 @@ public class QueryHandler extends SimpleChannelInboundHandler out.writeInt( sessionId ); int challengeToken = random.nextInt(); - sessions.put( challengeToken, System.currentTimeMillis() ); + sessions.put( msg.sender().getAddress(), new QuerySession( challengeToken, System.currentTimeMillis() ) ); writeNumber( out, challengeToken ); } @@ -76,8 +78,8 @@ public class QueryHandler extends SimpleChannelInboundHandler if ( type == 0x00 ) { int challengeToken = in.readInt(); - Long session = sessions.get( challengeToken ); - if ( session == null || System.currentTimeMillis() - session > TimeUnit.SECONDS.toMillis( 30 ) ) + QuerySession session = sessions.getIfPresent( msg.sender().getAddress() ); + if ( session == null || session.getToken() != challengeToken ) { throw new IllegalStateException( "No session!" ); } @@ -147,4 +149,12 @@ public class QueryHandler extends SimpleChannelInboundHandler { bungee.getLogger().log( Level.WARNING, "Error whilst handling query packet from " + ctx.channel().remoteAddress(), cause ); } + + @Data + private static class QuerySession + { + + private final int token; + private final long time; + } }