diff --git a/src/main/java/de/rayzs/pat/api/communication/client/ClientInfo.java b/src/main/java/de/rayzs/pat/api/communication/client/ClientInfo.java index e37e91e8..8bc83614 100644 --- a/src/main/java/de/rayzs/pat/api/communication/client/ClientInfo.java +++ b/src/main/java/de/rayzs/pat/api/communication/client/ClientInfo.java @@ -9,15 +9,11 @@ public abstract class ClientInfo { private boolean sentFeedback = false; private long syncTime = System.currentTimeMillis(); - private final Object serverObj; - - public ClientInfo(Object serverObj, String serverId) { - this.serverObj = serverObj; + public ClientInfo(String serverId) { this.id = serverId; } - public ClientInfo(Object serverObj, String serverId, String name) { - this.serverObj = serverObj; + public ClientInfo(String serverId, String name) { this.id = serverId; this.name = name; } @@ -59,8 +55,4 @@ public abstract class ClientInfo { public String getId() { return id; } - - public Object getServerObj() { - return serverObj; - } } diff --git a/src/main/java/de/rayzs/pat/api/communication/client/impl/BungeeClientInfo.java b/src/main/java/de/rayzs/pat/api/communication/client/impl/BungeeClientInfo.java index 375f5d96..ebd2daca 100644 --- a/src/main/java/de/rayzs/pat/api/communication/client/impl/BungeeClientInfo.java +++ b/src/main/java/de/rayzs/pat/api/communication/client/impl/BungeeClientInfo.java @@ -2,26 +2,21 @@ package de.rayzs.pat.api.communication.client.impl; import de.rayzs.pat.api.communication.Client; import de.rayzs.pat.api.communication.client.ClientInfo; -import net.md_5.bungee.api.connection.Server; +import net.md_5.bungee.api.ProxyServer; public class BungeeClientInfo extends ClientInfo { - public BungeeClientInfo(Object serverObj, String serverId) { - super(serverObj, serverId); + public BungeeClientInfo(String serverId) { + super(serverId); } - public BungeeClientInfo(Object serverObj, String serverId, String name) { - super(serverObj, serverId, name); + public BungeeClientInfo(String serverId, String name) { + super(serverId, name); } @Override public void sendBytes(byte[] bytes) { - ((Server) getServerObj()).sendData(Client.CHANNEL_NAME, bytes); - } - - @Override - public Object getServerObj() { - return super.getServerObj(); + ProxyServer.getInstance().getServers().entrySet().stream().filter(entry -> entry.getKey().equals(getName())).forEach(entry -> entry.getValue().sendData(Client.CHANNEL_NAME, bytes)); } @Override diff --git a/src/main/java/de/rayzs/pat/api/communication/client/impl/VelocityClientInfo.java b/src/main/java/de/rayzs/pat/api/communication/client/impl/VelocityClientInfo.java index f9b9db77..8e302084 100644 --- a/src/main/java/de/rayzs/pat/api/communication/client/impl/VelocityClientInfo.java +++ b/src/main/java/de/rayzs/pat/api/communication/client/impl/VelocityClientInfo.java @@ -2,25 +2,21 @@ package de.rayzs.pat.api.communication.client.impl; import de.rayzs.pat.api.communication.client.ClientInfo; import de.rayzs.pat.api.communication.impl.VelocityClient; +import de.rayzs.pat.plugin.VelocityLoader; public class VelocityClientInfo extends ClientInfo { - public VelocityClientInfo(Object serverObj, String serverId) { - super(serverObj, serverId); + public VelocityClientInfo(String serverId) { + super(serverId); } - public VelocityClientInfo(Object serverObj, String serverId, String name) { - super(serverObj, serverId, name); + public VelocityClientInfo(String serverId, String name) { + super(serverId, name); } @Override public void sendBytes(byte[] bytes) { - ((com.velocitypowered.api.proxy.server.RegisteredServer) getServerObj()).sendPluginMessage(VelocityClient.getIdentifier(), bytes); - } - - @Override - public Object getServerObj() { - return super.getServerObj(); + VelocityLoader.getServer().getAllServers().stream().filter(server -> server.getServerInfo().getName().equals(getName())).forEach(server -> server.sendPluginMessage(VelocityClient.getIdentifier(), bytes)); } @Override