mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-15 15:28:36 +01:00
Start whining about ProtocolLib
This commit is contained in:
parent
ffd6536565
commit
31672fce7b
@ -1,5 +1,7 @@
|
|||||||
package me.libraryaddict.disguise;
|
package me.libraryaddict.disguise;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.ProtocolLib;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
||||||
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||||
@ -78,6 +80,17 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
"reloads gracefully!");
|
"reloads gracefully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
|
||||||
|
|
||||||
|
String requiredProtocolLib = "4.5.1";
|
||||||
|
|
||||||
|
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
||||||
|
getLogger().severe("!! Attention please !!");
|
||||||
|
getLogger().severe("Update your ProtocolLib! You are running " + version +
|
||||||
|
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
||||||
|
getLogger().severe("!! Attention please !!");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||||
}
|
}
|
||||||
|
@ -2065,6 +2065,35 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int[] getNumericVersion(String version) {
|
||||||
|
int[] v = new int[0];
|
||||||
|
for (String split : version.split("\\.-")) {
|
||||||
|
if (!split.matches("[0-9]+")) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
v = Arrays.copyOf(v, v.length + 1);
|
||||||
|
v[v.length - 1] = Integer.parseInt(split);
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isOlderThan(String requiredVersion, String theirVersion) {
|
||||||
|
int[] ourVersion = getNumericVersion(requiredVersion);
|
||||||
|
int[] theirs = getNumericVersion(theirVersion);
|
||||||
|
|
||||||
|
for (int i = 0; i < Math.min(ourVersion.length, theirs.length); i++) {
|
||||||
|
if (ourVersion[i] <= theirs[i]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static Logger getLogger() {
|
public static Logger getLogger() {
|
||||||
return LibsDisguises.getInstance().getLogger();
|
return LibsDisguises.getInstance().getLogger();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user