fix possible settings NPE

This commit is contained in:
jascotty2 2019-09-02 07:49:19 -05:00
parent 04de7c9060
commit d04de3159c
2 changed files with 10 additions and 3 deletions

View File

@ -86,12 +86,14 @@ public abstract class SongodaPlugin extends JavaPlugin {
locale = Locale.loadDefaultLocale(this, "en_US");
// plugin setup
onPluginEnable();
if(emergencyStop) {
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
return;
}
// Start Metrics
Metrics.start(this);
} catch (Throwable t) {
getLogger().log(Level.SEVERE, "Unexpected error while loading " + getDescription().getName() + ": Disabling plugin!", t);
emergencyStop = true;
setEnabled(false);
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
return;
}
@ -99,6 +101,11 @@ public abstract class SongodaPlugin extends JavaPlugin {
console.sendMessage(ChatColor.GREEN + "=============================");
}
protected void emergencyStop() {
emergencyStop = true;
Bukkit.getPluginManager().disablePlugin(this);
}
@Override
public final void onDisable() {
if (emergencyStop) {

View File

@ -60,7 +60,7 @@ public class PluginConfigGui extends SimplePagedGui {
try {
// can we also grab extra config from this mysterious plugin?
Object more = plugin.getClass().getDeclaredMethod("getExtraConfig").invoke(plugin);
if (more instanceof List && !((List) more).isEmpty()) {
if (more != null && more instanceof List && !((List) more).isEmpty()) {
try {
// if we have the getExtraConfig function, we should also be able to get the file
Method method_Config_getFile = ((List) more).get(0).getClass().getDeclaredMethod("getFile");