mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Fix new velocity version
This commit is contained in:
parent
200ccfd092
commit
c8e8f39f9d
@ -14,7 +14,6 @@ import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
import us.myles.ViaVersion.velocity.service.ProtocolDetectorService;
|
||||
import us.myles.ViaVersion.velocity.storage.VelocityStorage;
|
||||
|
||||
@ -26,6 +25,8 @@ import java.util.concurrent.Semaphore;
|
||||
public class VelocityServerHandler {
|
||||
private static Method setProtocolVersion;
|
||||
private static Method setNextProtocolVersion;
|
||||
private static Method getMinecraftConnection;
|
||||
private static Method getNextProtocolVersion;
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -33,6 +34,10 @@ 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");
|
||||
getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
|
||||
.getDeclaredMethod("getNextProtocolVersion");
|
||||
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -51,12 +56,12 @@ public class VelocityServerHandler {
|
||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.get(ProtocolInfo.class).getProtocolVersion(), protocolId);
|
||||
|
||||
// Check if ViaVersion can support that version
|
||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
||||
Object connection = getMinecraftConnection.invoke(e.getPlayer());
|
||||
setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
|
||||
? user.get(ProtocolInfo.class).getProtocolVersion()
|
||||
: protocolId));
|
||||
|
||||
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e1) {
|
||||
} catch (IllegalAccessException | InvocationTargetException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -132,8 +137,8 @@ public class VelocityServerHandler {
|
||||
protocol.init(user);
|
||||
}
|
||||
|
||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
||||
ProtocolVersion version = (ProtocolVersion) ReflectionUtil.invoke(connection, "getNextProtocolVersion");
|
||||
Object connection = getMinecraftConnection.invoke(e.getPlayer());
|
||||
ProtocolVersion version = (ProtocolVersion) getNextProtocolVersion.invoke(connection);
|
||||
setProtocolVersion.invoke(connection, version);
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -24,15 +22,16 @@ public class VelocityStorage extends StoredObject {
|
||||
this.currentServer = "";
|
||||
|
||||
// Get bossbar list if it's supported
|
||||
/* TODO make this work - do we need this?
|
||||
try {
|
||||
Object connection = ReflectionUtil.invoke(player, "getConnection");
|
||||
Object sessionHandler = ReflectionUtil.invoke(connection, "getSessionHandler");
|
||||
if (sessionHandler.getClass().getSimpleName().contains("Play")) {
|
||||
bossbar = (Set<UUID>) ReflectionUtil.invoke(sessionHandler, "getServerBossBars");
|
||||
// TODO make this work
|
||||
bossbar = (Set<UUID>) ReflectionUtil.invoke(sessionHandler, "getServerBossBars");
|
||||
}
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user