Send Bytes Improvement

This commit is contained in:
RayzsYT committed 2024-05-21 01:30:49 +02:00
1 parent 2c5c504b0d
commit 663266a482
3 files changed
+14 -31

No files matched your search

@@ -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;
}
}
@@ -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
@@ -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