Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Bossbar fix for delay-switch-until-joingame Velocity branch
Dieser Commit ist enthalten in:
Ursprung
d699000dc3
Commit
1b7b3d1d28
@ -102,8 +102,6 @@ public class VelocityServerHandler {
|
|||||||
|
|
||||||
VelocityStorage storage = user.get(VelocityStorage.class);
|
VelocityStorage storage = user.get(VelocityStorage.class);
|
||||||
|
|
||||||
if (storage.getBossbar() == null) storage.saveServerBossBars();
|
|
||||||
|
|
||||||
if (e.getServer() != null) {
|
if (e.getServer() != null) {
|
||||||
if (!e.getServer().getServerInfo().getName().equals(storage.getCurrentServer())) {
|
if (!e.getServer().getServerInfo().getName().equals(storage.getCurrentServer())) {
|
||||||
String serverName = e.getServer().getServerInfo().getName();
|
String serverName = e.getServer().getServerInfo().getName();
|
||||||
|
@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.data.UserConnection;
|
|||||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -16,7 +17,22 @@ import java.util.UUID;
|
|||||||
public class VelocityStorage extends StoredObject {
|
public class VelocityStorage extends StoredObject {
|
||||||
private Player player;
|
private Player player;
|
||||||
private String currentServer;
|
private String currentServer;
|
||||||
private List<UUID> bossbar;
|
private List<UUID> cachedBossbar;
|
||||||
|
private static Method getServerBossBars;
|
||||||
|
private static Class<?> clientPlaySessionHandler;
|
||||||
|
private static Method getMinecraftConnection;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
clientPlaySessionHandler = Class.forName("com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler");
|
||||||
|
getServerBossBars = clientPlaySessionHandler
|
||||||
|
.getDeclaredMethod("getServerBossBars");
|
||||||
|
getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer")
|
||||||
|
.getDeclaredMethod("getMinecraftConnection");
|
||||||
|
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public VelocityStorage(UserConnection user, Player player) {
|
public VelocityStorage(UserConnection user, Player player) {
|
||||||
super(user);
|
super(user);
|
||||||
@ -24,16 +40,22 @@ public class VelocityStorage extends StoredObject {
|
|||||||
this.currentServer = "";
|
this.currentServer = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveServerBossBars() {
|
public List<UUID> getBossbar() {
|
||||||
|
if (cachedBossbar == null) {
|
||||||
|
if (clientPlaySessionHandler == null) return null;
|
||||||
|
if (getServerBossBars == null) return null;
|
||||||
|
if (getMinecraftConnection == null) return null;
|
||||||
// Get bossbar list if it's supported
|
// Get bossbar list if it's supported
|
||||||
try {
|
try {
|
||||||
Object connection = ReflectionUtil.invoke(player, "getMinecraftConnection");
|
Object connection = getMinecraftConnection.invoke(player);
|
||||||
Object sessionHandler = ReflectionUtil.invoke(connection, "getSessionHandler");
|
Object sessionHandler = ReflectionUtil.invoke(connection, "getSessionHandler");
|
||||||
if (sessionHandler.getClass().getSimpleName().contains("Play")) {
|
if (clientPlaySessionHandler.isInstance(sessionHandler)) {
|
||||||
bossbar = (List<UUID>) ReflectionUtil.invoke(sessionHandler, "getServerBossBars");
|
cachedBossbar = (List<UUID>) getServerBossBars.invoke(sessionHandler);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cachedBossbar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren