Bug fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package org.openautonomousconnection.protocol.side.client;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.state.disconnect.ClientDisconnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.state.disconnect.ClientFullyDisconnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.Transport;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.utils.NetworkUtils;
|
||||
@@ -48,7 +47,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
/**
|
||||
* Stores the protocol version of the connected insserver.
|
||||
*/
|
||||
private ProtocolVersion insServerVersion = null;
|
||||
private ProtocolVersion insVersion = null;
|
||||
/**
|
||||
* Stores the protocol version of the connected server.
|
||||
*/
|
||||
@@ -221,17 +220,17 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*
|
||||
* @return the ProtocolVersion of the server, or PV_1_0_0_CLASSIC if not set.
|
||||
*/
|
||||
public final ProtocolVersion getInsServerVersion() {
|
||||
return insServerVersion == null ? ProtocolVersion.PV_1_0_0_CLASSIC : insServerVersion;
|
||||
public final ProtocolVersion getInsVersion() {
|
||||
return insVersion == null ? ProtocolVersion.PV_1_0_0_CLASSIC : insVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the protocol version of the connected server.
|
||||
*
|
||||
* @param insServerVersion the ProtocolVersion to set for the server.
|
||||
* @param insVersion the ProtocolVersion to set for the server.
|
||||
*/
|
||||
public final void setInsServerVersion(ProtocolVersion insServerVersion) {
|
||||
if (insServerVersion == null) this.insServerVersion = insServerVersion;
|
||||
public final void setInsVersion(ProtocolVersion insVersion) {
|
||||
if (insVersion == null) this.insVersion = insVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +241,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
public final void onDisconnect(ClientFullyDisconnectedEvent event) {
|
||||
// Reset server version on INS disconnect
|
||||
if (!clientToINS.isFullyConnected() && clientToINS != null) {
|
||||
insServerVersion = null;
|
||||
insVersion = null;
|
||||
clientToINS = null;
|
||||
disconnectFromServer();
|
||||
}
|
||||
@@ -287,7 +286,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*/
|
||||
public final boolean isINSBetaServer() {
|
||||
// Check if the server version is beta
|
||||
return getInsServerVersion().getProtocolType() == ProtocolVersion.ProtocolType.BETA;
|
||||
return getInsVersion().getProtocolType() == ProtocolVersion.ProtocolType.BETA;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +296,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*/
|
||||
public final boolean supportINSServerBeta() {
|
||||
boolean yes = false;
|
||||
for (ProtocolVersion compatibleVersion : getInsServerVersion().getCompatibleVersions()) {
|
||||
for (ProtocolVersion compatibleVersion : getInsVersion().getCompatibleVersions()) {
|
||||
// Check if compatible version is beta
|
||||
yes = compatibleVersion.getProtocolType() == ProtocolVersion.ProtocolType.BETA;
|
||||
if (yes) break;
|
||||
@@ -314,7 +313,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*/
|
||||
public final boolean isINSClassicServer() {
|
||||
// Check if the server version is classic
|
||||
return getInsServerVersion().getProtocolType() == ProtocolVersion.ProtocolType.CLASSIC;
|
||||
return getInsVersion().getProtocolType() == ProtocolVersion.ProtocolType.CLASSIC;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +323,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*/
|
||||
public final boolean supportINSServerClassic() {
|
||||
boolean yes = false;
|
||||
for (ProtocolVersion compatibleVersion : getInsServerVersion().getCompatibleVersions()) {
|
||||
for (ProtocolVersion compatibleVersion : getInsVersion().getCompatibleVersions()) {
|
||||
// Check if compatible version is classic
|
||||
yes = compatibleVersion.getProtocolType() == ProtocolVersion.ProtocolType.CLASSIC;
|
||||
if (yes) break;
|
||||
@@ -353,7 +352,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*/
|
||||
public final boolean supportINSServerVersion(ProtocolVersion targetVersion) {
|
||||
// Directly check if the server version matches or is in the list of compatible versions
|
||||
return getInsServerVersion() == targetVersion || getInsServerVersion().getCompatibleVersions().contains(targetVersion);
|
||||
return getInsVersion() == targetVersion || getInsVersion().getCompatibleVersions().contains(targetVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,14 +363,14 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
*/
|
||||
public final boolean supportINSServerProtocol(ProtocolVersion.Protocol protocol) {
|
||||
boolean yes = false;
|
||||
for (ProtocolVersion compatibleVersion : getInsServerVersion().getCompatibleVersions()) {
|
||||
for (ProtocolVersion compatibleVersion : getInsVersion().getCompatibleVersions()) {
|
||||
// Check if compatible version supports the protocol
|
||||
yes = compatibleVersion.getSupportedProtocols().contains(protocol);
|
||||
if (yes) break;
|
||||
}
|
||||
|
||||
// Check if the server version supports the protocol
|
||||
return getInsServerVersion().getSupportedProtocols().contains(protocol) || yes;
|
||||
return getInsVersion().getSupportedProtocols().contains(protocol) || yes;
|
||||
}
|
||||
|
||||
//fwfwef
|
||||
|
||||
@@ -32,6 +32,8 @@ public abstract class CustomConnectedClient {
|
||||
connection.disconnect();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
clientVersion = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user