From df945146b83db64b84bae1ba50df725ac2dde633 Mon Sep 17 00:00:00 2001 From: games647 Date: Sat, 7 Oct 2017 19:19:45 +0200 Subject: [PATCH] Fix debug logging --- .../protocollib/ProtocolLibLoginSource.java | 7 +++---- .../listener/protocollib/VerifyResponseTask.java | 13 ++++--------- .../github/games647/fastlogin/core/CommonUtil.java | 5 ++++- pom.xml | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java index b915a593..330d716b 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java @@ -52,7 +52,7 @@ public class ProtocolLibLoginSource implements LoginSource { public void kick(String message) throws InvocationTargetException { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); - PacketContainer kickPacket = protocolManager.createPacket(DISCONNECT); + PacketContainer kickPacket = new PacketContainer(DISCONNECT); kickPacket.getChatComponents().write(0, WrappedChatComponent.fromText(message)); try { @@ -71,13 +71,12 @@ public class ProtocolLibLoginSource implements LoginSource { } private void sentEncryptionRequest() throws InvocationTargetException { - ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); /* * Packet Information: http://wiki.vg/Protocol#Encryption_Request * * ServerID="" (String) key=public server key verifyToken=random 4 byte array */ - PacketContainer newPacket = protocolManager.createPacket(ENCRYPTION_BEGIN); + PacketContainer newPacket = new PacketContainer(ENCRYPTION_BEGIN); newPacket.getStrings().write(0, serverId); PublicKey publicKey = plugin.getServerKey().getPublic(); @@ -86,7 +85,7 @@ public class ProtocolLibLoginSource implements LoginSource { newPacket.getByteArrays().write(0, verifyToken); //serverId is a empty string - protocolManager.sendServerPacket(player, newPacket); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, newPacket); } public String getServerId() { 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 db286be3..8c12a3e8 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 @@ -1,7 +1,6 @@ package com.github.games647.fastlogin.bukkit.listener.protocollib; import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.injector.server.TemporaryPlayerFactory; @@ -180,14 +179,12 @@ public class VerifyResponseTask implements Runnable { } private void kickPlayer(String reason) { - ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); - - PacketContainer kickPacket = protocolManager.createPacket(DISCONNECT); + PacketContainer kickPacket = new PacketContainer(DISCONNECT); kickPacket.getChatComponents().write(0, WrappedChatComponent.fromText(reason)); try { //send kick packet at login state //the normal event.getPlayer.kickPlayer(String) method does only work at play state - protocolManager.sendServerPacket(player, kickPacket); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, kickPacket); //tell the server that we want to close the connection player.kickPlayer("Disconnect"); } catch (InvocationTargetException ex) { @@ -197,17 +194,15 @@ public class VerifyResponseTask implements Runnable { //fake a new login packet in order to let the server handle all the other stuff private void receiveFakeStartPacket(String username) { - ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); - //see StartPacketListener for packet information - PacketContainer startPacket = protocolManager.createPacket(START); + PacketContainer startPacket = new PacketContainer(START); //uuid is ignored by the packet definition WrappedGameProfile fakeProfile = new WrappedGameProfile(UUID.randomUUID(), username); startPacket.getGameProfiles().write(0, fakeProfile); try { //we don't want to handle our own packets so ignore filters - protocolManager.recieveClientPacket(player, startPacket, false); + ProtocolLibrary.getProtocolManager().recieveClientPacket(player, startPacket, false); } catch (InvocationTargetException | IllegalAccessException ex) { plugin.getLog().warn("Failed to fake a new start packet", ex); //cancel the event in order to prevent the server receiving an invalid packet diff --git a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java index 5e7f99bf..c5ce82b8 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java @@ -63,10 +63,13 @@ public class CommonUtil { public static Logger createLoggerFromJDK(java.util.logging.Logger parent) { try { + parent.setLevel(Level.ALL); + Class adapterClass = JDK14LoggerAdapter.class; Constructor cons = adapterClass.getDeclaredConstructor(java.util.logging.Logger.class); cons.setAccessible(true); - return cons.newInstance(parent); + JDK14LoggerAdapter logger = cons.newInstance(parent); + return logger; } catch (ReflectiveOperationException reflectEx) { parent.log(Level.WARNING, "Cannot create slf4j logging adapter", reflectEx); parent.log(Level.WARNING, "Creating logger instance manually..."); diff --git a/pom.xml b/pom.xml index 59ff7e74..0c0c34ef 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ FastLogin 1.11 - 2015 + https://www.spigotmc.org/resources/fastlogin.14153/ Automatically logins premium (paid accounts) player on a offline mode server