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