mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Merge branch 'master' into dev
This commit is contained in:
commit
b75016a186
@ -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),
|
||||
|
@ -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<String> knownChannels = (Set<String>) getKnownChannels.invoke(sessionHandler);
|
||||
if (previousServerProtocol != -1) {
|
||||
int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol();
|
||||
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
||||
ArrayList<String> newChannels = new ArrayList<>();
|
||||
for (String oldChannel : knownChannels) {
|
||||
String transformed = InventoryPackets.getNewPluginChannelId(oldChannel);
|
||||
if (transformed != null) {
|
||||
newChannels.add(transformed);
|
||||
}
|
||||
Collection<String> knownChannels = (Collection<String>) getKnownChannels.invoke(e.getPlayer());
|
||||
if (previousServerProtocol != -1) {
|
||||
int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol();
|
||||
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
||||
List<String> 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<String> 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<String> newChannels = new ArrayList<>();
|
||||
for (String oldChannel : knownChannels) {
|
||||
String transformed = InventoryPackets.getOldPluginChannelId(oldChannel);
|
||||
if (transformed != null) {
|
||||
newChannels.add(transformed);
|
||||
}
|
||||
}
|
||||
knownChannels.clear();
|
||||
knownChannels.addAll(newChannels);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user