Detect incompatible BungeeCord versions

This commit is contained in:
Luck 2020-05-03 00:23:58 +01:00
parent cd25681cd3
commit 8771d4c5e5
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -79,6 +79,9 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
private final CountDownLatch loadLatch = new CountDownLatch(1); private final CountDownLatch loadLatch = new CountDownLatch(1);
private final CountDownLatch enableLatch = new CountDownLatch(1); private final CountDownLatch enableLatch = new CountDownLatch(1);
// if the plugin has been loaded on an incompatible version
private boolean incompatibleVersion = false;
public LPBungeeBootstrap() { public LPBungeeBootstrap() {
this.schedulerAdapter = new BungeeSchedulerAdapter(this); this.schedulerAdapter = new BungeeSchedulerAdapter(this);
this.classLoader = new ReflectionClassLoader(this); this.classLoader = new ReflectionClassLoader(this);
@ -111,6 +114,11 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
public void onLoad() { public void onLoad() {
this.logger = new JavaPluginLogger(getLogger()); this.logger = new JavaPluginLogger(getLogger());
if (checkIncompatibleVersion()) {
this.incompatibleVersion = true;
return;
}
try { try {
this.plugin.load(); this.plugin.load();
} finally { } finally {
@ -120,6 +128,21 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
@Override @Override
public void onEnable() { public void onEnable() {
if (this.incompatibleVersion) {
getLogger().severe("----------------------------------------------------------------------");
getLogger().severe("Your proxy version is not compatible with this build of LuckPerms. :(");
getLogger().severe("");
getLogger().severe("This is most likely because you are using an old/outdated version of BungeeCord.");
getLogger().severe("If you need 1.7 support, replace your BungeeCord.jar file with the latest build of");
getLogger().severe("'Travertine' from here:");
getLogger().severe("==> https://papermc.io/downloads#Travertine");
getLogger().severe("");
getLogger().severe("The proxy will now shutdown.");
getLogger().severe("----------------------------------------------------------------------");
getProxy().stop();
return;
}
this.startTime = Instant.now(); this.startTime = Instant.now();
try { try {
this.plugin.enable(); this.plugin.enable();
@ -130,6 +153,10 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
@Override @Override
public void onDisable() { public void onDisable() {
if (this.incompatibleVersion) {
return;
}
this.plugin.disable(); this.plugin.disable();
} }
@ -232,4 +259,13 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
public boolean isPlayerOnline(UUID uniqueId) { public boolean isPlayerOnline(UUID uniqueId) {
return getProxy().getPlayer(uniqueId) != null; return getProxy().getPlayer(uniqueId) != null;
} }
private static boolean checkIncompatibleVersion() {
try {
Class<?> aClass = Class.forName("com.google.gson.internal.bind.TreeTypeAdapter");
return false;
} catch (ClassNotFoundException e) {
return true;
}
}
} }