- Small bug fixing
This commit is contained in:
@@ -5,6 +5,7 @@ import me.finn.unlegitlibrary.network.system.client.events.*;
|
||||
import me.finn.unlegitlibrary.network.system.packets.Packet;
|
||||
import me.finn.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import me.finn.unlegitlibrary.network.system.packets.impl.ClientIDPacket;
|
||||
import me.finn.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||
import me.finn.unlegitlibrary.network.utils.PemUtils;
|
||||
import me.finn.unlegitlibrary.utils.DefaultMethodsOverrider;
|
||||
import me.finn.unlegitlibrary.utils.Logger;
|
||||
@@ -174,6 +175,12 @@ public final class NetworkClient {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof NetworkClient target)) return false;
|
||||
return target.getClientID() == clientID;
|
||||
}
|
||||
|
||||
public boolean sendPacket(Packet packet) throws IOException, ClassNotFoundException {
|
||||
if (!isConnected()) return false;
|
||||
boolean sent = packetHandler.sendPacket(packet, outputStream);
|
||||
|
@@ -19,6 +19,12 @@ public class ConnectionHandler {
|
||||
private ObjectInputStream inputStream;
|
||||
private final NetworkServer server;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ConnectionHandler target)) return false;
|
||||
return target.getClientID() == clientID;
|
||||
}
|
||||
|
||||
public SSLSocket getSocket() {
|
||||
return socket;
|
||||
}
|
||||
|
@@ -33,6 +33,17 @@ public final class NetworkServer {
|
||||
return connectionHandlers;
|
||||
}
|
||||
|
||||
public ConnectionHandler getConnectionHandlerByID(int clientID) {
|
||||
for (ConnectionHandler connectionHandler : connectionHandlers) if (connectionHandler.getClientID() == clientID) return connectionHandler;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof NetworkServer target)) return false;
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
@@ -53,7 +64,7 @@ public final class NetworkServer {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
private boolean requireClientCert;
|
||||
private final boolean requireClientCert;
|
||||
|
||||
private NetworkServer(int port, PacketHandler packetHandler, EventManager eventManager,
|
||||
Logger logger, int timeout, SSLServerSocketFactory factory, boolean requireClientCert) {
|
||||
|
Reference in New Issue
Block a user