diff --git a/README.md b/README.md index 37e07506..92ef43a3 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Possible values: `Premium`, `Cracked`, `Unknown` * Server software in offlinemode: * Spigot (or a fork e.g. Paper) 1.8.8+ * Protocol plugin: - * [ProtocolLib 5.2+](https://www.spigotmc.org/resources/protocollib.1997/) or + * [ProtocolLib 5.3+ with development build above 720](https://www.spigotmc.org/resources/protocollib.1997/) or * [ProtocolSupport](https://www.spigotmc.org/resources/protocolsupport.7201/) * Latest BungeeCord (or a fork e.g. Waterfall) or Velocity proxy * An auth plugin. diff --git a/bukkit/pom.xml b/bukkit/pom.xml index d528187d..4104c0ea 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -126,9 +126,6 @@ dmulloy2-repo https://repo.dmulloy2.net/repository/public/ - - false - @@ -211,7 +208,7 @@ com.comphenix.protocol ProtocolLib - 5.1.0 + 5.3.0-SNAPSHOT provided diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java index 2f861048..10ab8bee 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java @@ -30,12 +30,11 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.injector.PacketFilterManager; -import com.comphenix.protocol.injector.player.PlayerInjectionHandler; +import com.comphenix.protocol.injector.netty.channel.NettyChannelInjector; +import com.comphenix.protocol.injector.temporary.TemporaryPlayerFactory; import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.accessors.Accessors; -import com.comphenix.protocol.reflect.accessors.FieldAccessor; import com.comphenix.protocol.utility.MinecraftVersion; import com.comphenix.protocol.wrappers.BukkitConverters; import com.comphenix.protocol.wrappers.Converters; @@ -75,7 +74,6 @@ import static com.comphenix.protocol.PacketType.Login.Client.START; public class ProtocolLibListener extends PacketAdapter { private final FastLoginBukkit plugin; - private final PlayerInjectionHandler handler; //just create a new once on plugin enable. This used for verify token generation private final SecureRandom random = new SecureRandom(); @@ -94,7 +92,6 @@ public class ProtocolLibListener extends PacketAdapter { this.plugin = plugin; this.antiBotService = antiBotService; this.verifyClientKeys = verifyClientKeys; - this.handler = getHandler(); } public static void register(FastLoginBukkit plugin, AntiBotService antiBotService, boolean verifyClientKeys) { @@ -297,18 +294,19 @@ public class ProtocolLibListener extends PacketAdapter { return profile.getName(); } - private static PlayerInjectionHandler getHandler() { - PacketFilterManager manager = (PacketFilterManager) ProtocolLibrary.getProtocolManager(); - FieldAccessor accessor = Accessors.getFieldAccessor(manager.getClass(), PlayerInjectionHandler.class, true); - return (PlayerInjectionHandler) accessor.get(manager); - } - private FloodgatePlayer getFloodgatePlayer(Player player) { - Channel channel = handler.getChannel(player); + Channel channel = getChannel(player); AttributeKey floodgateAttribute = AttributeKey.valueOf("floodgate-player"); return channel.attr(floodgateAttribute).get(); } + private static Channel getChannel(Player player) { + NettyChannelInjector injector = (NettyChannelInjector) Accessors.getMethodAccessorOrNull( + TemporaryPlayerFactory.class, "getInjectorFromPlayer", Player.class + ).invoke(null, player); + return injector.getWrappedChannel(); + } + /** * Reimplementation of the tasks injected Floodgate in ProtocolLib that are not run due to a bug * @see Issue Floodgate#143 @@ -325,7 +323,7 @@ public class ProtocolLibListener extends PacketAdapter { } // kick the player, if necessary - Channel channel = handler.getChannel(packetEvent.getPlayer()); + Channel channel = getChannel(packetEvent.getPlayer()); AttributeKey kickMessageAttribute = AttributeKey.valueOf("floodgate-kick-message"); String kickMessage = channel.attr(kickMessageAttribute).get(); if (kickMessage != null) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java index 55f3b960..03925730 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java @@ -28,6 +28,7 @@ package com.github.games647.fastlogin.bukkit.listener.protocollib; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.injector.netty.channel.NettyChannelInjector; import com.comphenix.protocol.injector.packet.PacketRegistry; import com.comphenix.protocol.injector.temporary.TemporaryPlayerFactory; import com.comphenix.protocol.reflect.EquivalentConverter; @@ -218,15 +219,14 @@ public class VerifyResponseTask implements Runnable { //try to get the networkManager from ProtocolLib private Object getNetworkManager() throws ClassNotFoundException { - Object injectorContainer = TemporaryPlayerFactory.getInjectorFromPlayer(player); + NettyChannelInjector injectorContainer = (NettyChannelInjector) Accessors.getMethodAccessorOrNull( + TemporaryPlayerFactory.class, "getInjectorFromPlayer", Player.class + ).invoke(null, player); - // ChannelInjector - Class injectorClass = Class.forName("com.comphenix.protocol.injector.netty.Injector"); - Object rawInjector = FuzzyReflection.getFieldValue(injectorContainer, injectorClass, true); - - Class rawInjectorClass = rawInjector.getClass(); - FieldAccessor accessor = Accessors.getFieldAccessorOrNull(rawInjectorClass, "networkManager", Object.class); - return accessor.get(rawInjector); + FieldAccessor accessor = Accessors.getFieldAccessorOrNull( + NettyChannelInjector.class, "networkManager", Object.class + ); + return accessor.get(injectorContainer); } private boolean enableEncryption(SecretKey loginKey) throws IllegalArgumentException {