Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Merge branch 'master' into dev
Dieser Commit ist enthalten in:
Commit
b75016a186
@ -60,6 +60,7 @@ public class Entity1_14Types {
|
|||||||
CHICKEN(8, ABSTRACT_ANIMAL),
|
CHICKEN(8, ABSTRACT_ANIMAL),
|
||||||
COW(10, ABSTRACT_ANIMAL),
|
COW(10, ABSTRACT_ANIMAL),
|
||||||
MOOSHROOM(49, COW),
|
MOOSHROOM(49, COW),
|
||||||
|
PANDA(52, ABSTRACT_INSENTIENT),
|
||||||
PIG(54, ABSTRACT_ANIMAL),
|
PIG(54, ABSTRACT_ANIMAL),
|
||||||
POLAR_BEAR(57, ABSTRACT_ANIMAL),
|
POLAR_BEAR(57, ABSTRACT_ANIMAL),
|
||||||
RABBIT(59, 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.base.ProtocolInfo;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
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.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.service.ProtocolDetectorService;
|
||||||
import us.myles.ViaVersion.velocity.storage.VelocityStorage;
|
import us.myles.ViaVersion.velocity.storage.VelocityStorage;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ public class VelocityServerHandler {
|
|||||||
private static Method getMinecraftConnection;
|
private static Method getMinecraftConnection;
|
||||||
private static Method getNextProtocolVersion;
|
private static Method getNextProtocolVersion;
|
||||||
private static Method getKnownChannels;
|
private static Method getKnownChannels;
|
||||||
private static Class<?> clientPlaySessionHandler;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@ -42,13 +40,11 @@ public class VelocityServerHandler {
|
|||||||
.getDeclaredMethod("setProtocolVersion", ProtocolVersion.class);
|
.getDeclaredMethod("setProtocolVersion", ProtocolVersion.class);
|
||||||
setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
|
setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
|
||||||
.getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class);
|
.getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class);
|
||||||
getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer")
|
Class<?> connectedPlayer = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||||
.getDeclaredMethod("getMinecraftConnection");
|
getMinecraftConnection = connectedPlayer.getDeclaredMethod("getMinecraftConnection");
|
||||||
getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
|
getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
|
||||||
.getDeclaredMethod("getNextProtocolVersion");
|
.getDeclaredMethod("getNextProtocolVersion");
|
||||||
clientPlaySessionHandler = Class.forName("com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler");
|
getKnownChannels = connectedPlayer.getDeclaredMethod("getKnownChannels");
|
||||||
getKnownChannels = clientPlaySessionHandler
|
|
||||||
.getDeclaredMethod("getKnownChannels");
|
|
||||||
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -79,7 +75,6 @@ public class VelocityServerHandler {
|
|||||||
|
|
||||||
@Subscribe(order = PostOrder.LATE)
|
@Subscribe(order = PostOrder.LATE)
|
||||||
public void connectedEvent(ServerConnectedEvent e) {
|
public void connectedEvent(ServerConnectedEvent e) {
|
||||||
UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId());
|
|
||||||
try {
|
try {
|
||||||
checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId()));
|
checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId()));
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
@ -144,37 +139,29 @@ public class VelocityServerHandler {
|
|||||||
// Add version-specific base Protocol
|
// Add version-specific base Protocol
|
||||||
pipeline.add(ProtocolRegistry.getBaseProtocol(protocolId));
|
pipeline.add(ProtocolRegistry.getBaseProtocol(protocolId));
|
||||||
|
|
||||||
// Workaround 1.13 server change
|
Collection<String> knownChannels = (Collection<String>) getKnownChannels.invoke(e.getPlayer());
|
||||||
Object sessionHandler = ReflectionUtil.invoke(
|
if (previousServerProtocol != -1) {
|
||||||
getMinecraftConnection.invoke(e.getPlayer()),
|
int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol();
|
||||||
"getSessionHandler"
|
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
||||||
);
|
List<String> newChannels = new ArrayList<>();
|
||||||
|
for (String oldChannel : knownChannels) {
|
||||||
if (clientPlaySessionHandler.isInstance(sessionHandler)) { // It may be InitialConnectSessionHandler on the first server connection
|
String transformed = InventoryPackets.getNewPluginChannelId(oldChannel);
|
||||||
Set<String> knownChannels = (Set<String>) getKnownChannels.invoke(sessionHandler);
|
if (transformed != null) {
|
||||||
if (previousServerProtocol != -1) {
|
newChannels.add(transformed);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren