Merge branch 'Exortions/SongodaCore:master' into development (#27)

This commit is contained in:
Christian Koop 2021-11-01 20:18:04 +01:00
commit af9def96b3
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -71,13 +71,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
try {
onPluginLoad();
} catch (Throwable t) {
Bukkit.getLogger().log(Level.SEVERE,
"Unexpected error while loading " + getDescription().getName()
+ " v" + getDescription().getVersion()
+ " c" + SongodaCore.getCoreLibraryVersion()
+ ": Disabling plugin!", t);
emergencyStop = true;
crash(t);
}
}
@ -113,13 +107,8 @@ public abstract class SongodaPlugin extends JavaPlugin {
// Start Metrics
Metrics.start(this);
} catch (Throwable th) {
Bukkit.getLogger().log(Level.SEVERE,
"Unexpected error while loading " + getDescription().getName()
+ " v" + getDescription().getVersion()
+ " c" + SongodaCore.getCoreLibraryVersion()
+ ": Disabling plugin!", th);
} catch (Throwable t) {
crash(t);
emergencyStop();
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
@ -224,4 +213,15 @@ public abstract class SongodaPlugin extends JavaPlugin {
}
}
}
/**
Invoke this method if a severe error occurs and the plugin needs to shut down.
@param t Any exceptions that are thrown when crashed should be put here, and will print once the error message logs.
*/
public void crash(Throwable... t) {
Bukkit.getLogger().log(Level.SEVERE, String.format("Unexpected error while loading %s v%s c%s: Disabling plugin!", getDescription().getName(), getDescription().getVersion(), SongodaCore.getCoreLibraryVersion()), t);
emergencyStop();
}
}