From 440d469fa2d324f17baf64dd20faec70ab9adf1a Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Wed, 15 May 2019 23:16:01 +0200 Subject: [PATCH 1/2] Update to latest Velocity build --- .../handlers/VelocityServerHandler.java | 63 ++++++++----------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityServerHandler.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityServerHandler.java index 39fbc44da..bf2c32133 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityServerHandler.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityServerHandler.java @@ -16,15 +16,14 @@ import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; -import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.velocity.service.ProtocolDetectorService; import us.myles.ViaVersion.velocity.storage.VelocityStorage; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collection; import java.util.List; -import java.util.Set; import java.util.UUID; import java.util.concurrent.Semaphore; @@ -34,7 +33,6 @@ public class VelocityServerHandler { private static Method getMinecraftConnection; private static Method getNextProtocolVersion; private static Method getKnownChannels; - private static Class clientPlaySessionHandler; static { try { @@ -42,13 +40,11 @@ public class VelocityServerHandler { .getDeclaredMethod("setProtocolVersion", ProtocolVersion.class); setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection") .getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class); - getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer") - .getDeclaredMethod("getMinecraftConnection"); + Class connectedPlayer = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer"); + getMinecraftConnection = connectedPlayer.getDeclaredMethod("getMinecraftConnection"); getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection") .getDeclaredMethod("getNextProtocolVersion"); - clientPlaySessionHandler = Class.forName("com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler"); - getKnownChannels = clientPlaySessionHandler - .getDeclaredMethod("getKnownChannels"); + getKnownChannels = connectedPlayer.getDeclaredMethod("getKnownChannels"); } catch (NoSuchMethodException | ClassNotFoundException e) { e.printStackTrace(); } @@ -79,7 +75,6 @@ public class VelocityServerHandler { @Subscribe(order = PostOrder.LATE) public void connectedEvent(ServerConnectedEvent e) { - UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId()); try { checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId())); } catch (Exception e1) { @@ -144,37 +139,29 @@ public class VelocityServerHandler { // Add version-specific base Protocol pipeline.add(ProtocolRegistry.getBaseProtocol(protocolId)); - // Workaround 1.13 server change - Object sessionHandler = ReflectionUtil.invoke( - getMinecraftConnection.invoke(e.getPlayer()), - "getSessionHandler" - ); - - if (clientPlaySessionHandler.isInstance(sessionHandler)) { // It may be InitialConnectSessionHandler on the first server connection - Set knownChannels = (Set) getKnownChannels.invoke(sessionHandler); - if (previousServerProtocol != -1) { - int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol(); - if (previousServerProtocol < id1_13 && protocolId >= id1_13) { - ArrayList newChannels = new ArrayList<>(); - for (String oldChannel : knownChannels) { - String transformed = InventoryPackets.getNewPluginChannelId(oldChannel); - if (transformed != null) { - newChannels.add(transformed); - } + Collection knownChannels = (Collection) getKnownChannels.invoke(e.getPlayer()); + if (previousServerProtocol != -1) { + int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol(); + if (previousServerProtocol < id1_13 && protocolId >= id1_13) { + List newChannels = new ArrayList<>(); + for (String oldChannel : knownChannels) { + String transformed = InventoryPackets.getNewPluginChannelId(oldChannel); + if (transformed != null) { + newChannels.add(transformed); } - knownChannels.clear(); - knownChannels.addAll(newChannels); - } else if (previousServerProtocol >= id1_13 && protocolId < id1_13) { - ArrayList newChannels = new ArrayList<>(); - for (String oldChannel : knownChannels) { - String transformed = InventoryPackets.getOldPluginChannelId(oldChannel); - if (transformed != null) { - newChannels.add(transformed); - } - } - knownChannels.clear(); - knownChannels.addAll(newChannels); } + knownChannels.clear(); + knownChannels.addAll(newChannels); + } else if (previousServerProtocol >= id1_13 && protocolId < id1_13) { + List newChannels = new ArrayList<>(); + for (String oldChannel : knownChannels) { + String transformed = InventoryPackets.getOldPluginChannelId(oldChannel); + if (transformed != null) { + newChannels.add(transformed); + } + } + knownChannels.clear(); + knownChannels.addAll(newChannels); } } From 6882b7074ce146f6b963010e9023f9f7cd1c4832 Mon Sep 17 00:00:00 2001 From: Myles Date: Fri, 17 May 2019 11:59:46 +0100 Subject: [PATCH 2/2] Fix #1333 pandas missing --- .../java/us/myles/ViaVersion/api/entities/Entity1_14Types.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java b/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java index 6a77337a1..f9f5819ce 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java +++ b/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java @@ -60,6 +60,7 @@ public class Entity1_14Types { CHICKEN(8, ABSTRACT_ANIMAL), COW(10, ABSTRACT_ANIMAL), MOOSHROOM(49, COW), + PANDA(52, ABSTRACT_INSENTIENT), PIG(54, ABSTRACT_ANIMAL), POLAR_BEAR(57, ABSTRACT_ANIMAL), RABBIT(59, ABSTRACT_ANIMAL),