mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-04 15:31:48 +00:00
Warn when using Velocity 1.1.5 or above
Something about this version broke with Floodgate. Floodgate 2.0 is our bigger priority.
This commit is contained in:
@@ -61,6 +61,10 @@ public class VelocityPlugin {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.logger = logger;
|
||||
if (isCompatible(server.getVersion().getVersion().replace("-SNAPSHOT", ""), "1.1.5")) {
|
||||
logger.warning("Velocity 1.1.5 currently does not work with Floodgate! This is unlikely to be fixed.");
|
||||
logger.warning("Either downgrade to Velocity 1.1.4 or upgrade to Floodgate 2.0: https://github.com/GeyserMC/Floodgate/wiki/Floodgate-2.0");
|
||||
}
|
||||
if (!injectSucceed) return;
|
||||
|
||||
this.workingSet = new HashSet<>();
|
||||
@@ -208,6 +212,36 @@ public class VelocityPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCompatible(String version, String whichVersion) {
|
||||
int[] currentVersion = parseVersion(version);
|
||||
int[] otherVersion = parseVersion(whichVersion);
|
||||
int length = Math.max(currentVersion.length, otherVersion.length);
|
||||
for (int index = 0; index < length; index = index + 1) {
|
||||
int self = (index < currentVersion.length) ? currentVersion[index] : 0;
|
||||
int other = (index < otherVersion.length) ? otherVersion[index] : 0;
|
||||
|
||||
if (self != other) {
|
||||
return (self - other) > 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] parseVersion(String versionParam) {
|
||||
versionParam = (versionParam == null) ? "" : versionParam;
|
||||
String[] stringArray = versionParam.split("[_.-]");
|
||||
int[] temp = new int[stringArray.length];
|
||||
for (int index = 0; index <= (stringArray.length - 1); index = index + 1) {
|
||||
String t = stringArray[index].replaceAll("\\D", "");
|
||||
try {
|
||||
temp[index] = Integer.parseInt(t);
|
||||
} catch (NumberFormatException ex) {
|
||||
temp[index] = 0;
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
private Field handshakeField;
|
||||
private Field handshakeAddressField;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user