Add required version of PL for 1.17
This commit is contained in:
parent
d525d03383
commit
ea48d98c2a
@ -67,7 +67,7 @@ public class LibsDisguises extends JavaPlugin {
|
||||
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
|
||||
|
||||
if (plugin == null || DisguiseUtilities.isOlderThan(DisguiseUtilities.getProtocolLibRequiredVersion(), plugin.getDescription().getVersion())) {
|
||||
if (plugin == null || DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
getLogger().warning("Noticed you're using an older version of ProtocolLib (or not using it)! We're forcibly updating you!");
|
||||
|
||||
try {
|
||||
@ -171,10 +171,10 @@ public class LibsDisguises extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
String requiredProtocolLib = DisguiseUtilities.getProtocolLibRequiredVersion();
|
||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
||||
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
|
||||
|
||||
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
||||
if (DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
getLogger().severe("!! May I have your attention please !!");
|
||||
getLogger()
|
||||
.severe("Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
|
||||
|
@ -22,6 +22,7 @@ import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -69,10 +70,10 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
protected boolean isNotPremium(CommandSender sender) {
|
||||
String requiredProtocolLib = DisguiseUtilities.getProtocolLibRequiredVersion();
|
||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
||||
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
|
||||
|
||||
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
||||
if (DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
DisguiseUtilities.sendProtocolLibUpdateMessage(sender, version, requiredProtocolLib);
|
||||
}
|
||||
|
||||
|
@ -460,8 +460,49 @@ public class DisguiseUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getProtocolLibRequiredVersion() {
|
||||
return !NmsVersion.v1_13.isSupported() ? "4.4.0" : NmsVersion.v1_16.isSupported() ? "4.6.0" : "4.5.1";
|
||||
public static String[] getProtocolLibRequiredVersion() {
|
||||
// If we are on 1.12
|
||||
if (!NmsVersion.v1_13.isSupported()) {
|
||||
return new String[]{"4.4.0"};
|
||||
}
|
||||
|
||||
// If we are on 1.13, 1.14, 1.15
|
||||
if (!NmsVersion.v1_16.isSupported()) {
|
||||
return new String[]{"4.5.1"};
|
||||
}
|
||||
|
||||
// If we are on 1.16
|
||||
if (!NmsVersion.v1_17.isSupported()) {
|
||||
return new String[]{"4.6.0"};
|
||||
}
|
||||
|
||||
// If we are on 1.17, future release build or this dev build
|
||||
return new String[]{"4.7.1", "521"};
|
||||
}
|
||||
|
||||
public static boolean isProtocolLibOutdated() {
|
||||
String plVersion = Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
|
||||
String[] reqVersion = getProtocolLibRequiredVersion();
|
||||
|
||||
// If this is also checking for a custom build, and PL has the custom build in..
|
||||
// We run this check first as the 4.7.1 isn't out, and it'd always tell us to update otherwise.
|
||||
if (reqVersion.length > 1 && plVersion.contains("-SNAPSHOT-b")) {
|
||||
try {
|
||||
String build = plVersion.substring(plVersion.lastIndexOf("b") + 1);
|
||||
|
||||
// Just incase they're running a custom build?
|
||||
if (build.length() < 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int buildNo = Integer.parseInt(build);
|
||||
|
||||
return buildNo < Integer.parseInt(reqVersion[1]);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return isOlderThan(reqVersion[0], plVersion);
|
||||
}
|
||||
|
||||
public static File updateProtocolLib() throws Exception {
|
||||
|
@ -19,6 +19,7 @@ import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
|
||||
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -329,10 +330,10 @@ public class DisguiseListener implements Listener {
|
||||
p.removeMetadata("ld_loggedin", LibsDisguises.getInstance());
|
||||
plugin.getUpdateChecker().notifyUpdate(p);
|
||||
|
||||
String requiredProtocolLib = DisguiseUtilities.getProtocolLibRequiredVersion();
|
||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
||||
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
|
||||
|
||||
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
||||
if (DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
DisguiseUtilities.sendProtocolLibUpdateMessage(p, version, requiredProtocolLib);
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
Loading…
Reference in New Issue
Block a user