Wrap entire LD loading in a catch and make it check for updates if exception is thrown

This commit is contained in:
libraryaddict 2021-05-15 12:32:08 +12:00
parent c8bd25ba57
commit d4abde2542

View file

@ -59,6 +59,7 @@ public class LibsDisguises extends JavaPlugin {
@Override
public void onLoad() {
try {
if (instance != null || !Bukkit.getServer().getWorlds().isEmpty() || !Bukkit.getOnlinePlayers().isEmpty()) {
reloaded = true;
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
@ -85,8 +86,8 @@ public class LibsDisguises extends JavaPlugin {
}
} catch (Exception e) {
getLogger()
.severe("Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you can " +
"join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
.severe("Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
" can " + "join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
e.printStackTrace();
}
@ -106,10 +107,16 @@ public class LibsDisguises extends JavaPlugin {
}
WatcherSanitizer.init();
} catch (Throwable throwable) {
getUpdateChecker().doUpdate();
throw throwable;
}
}
@Override
public void onEnable() {
try {
if (reloaded) {
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
}
@ -151,7 +158,8 @@ public class LibsDisguises extends JavaPlugin {
LibsPremium.check(getDescription().getVersion(), getFile());
if (!LibsPremium.isPremium()) {
getLogger().info("You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
getLogger()
.info("You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
}
if (ReflectionManager.getVersion() == null) {
@ -166,7 +174,8 @@ public class LibsDisguises extends JavaPlugin {
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
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 +
getLogger()
.severe("Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
"!");
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target/ProtocolLib" + ".jar");
getLogger().severe("Or! Use /ld updateprotocollib - To update to the latest development build");
@ -245,6 +254,11 @@ public class LibsDisguises extends JavaPlugin {
unregisterCommands(false);
new MetricsInitalizer();
} catch (Throwable throwable) {
getUpdateChecker().doUpdate();
throw throwable;
}
}
public void unregisterCommands(boolean force) {