Improve config-file errors from /ma setting.
Catches ConfigError and prints its message rather than letting it bubble up to the command handler as an uncaught exception. This means that instead of seeing "An internal error occurred...", command senders now see the underlying error message, as well as a short message telling them to fix the error in the config-file and reload. Closes #599
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.garbagemule.MobArena.commands.setup;
|
||||
|
||||
import com.garbagemule.MobArena.ConfigError;
|
||||
import com.garbagemule.MobArena.commands.Command;
|
||||
import com.garbagemule.MobArena.commands.CommandInfo;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
@@ -89,7 +90,13 @@ public class SettingCommand implements Command {
|
||||
|
||||
// Save config-file and reload arena
|
||||
am.saveConfig();
|
||||
am.reloadArena(args[0]);
|
||||
try {
|
||||
am.reloadArena(args[0]);
|
||||
} catch (ConfigError e) {
|
||||
am.getGlobalMessenger().tell(sender, "Failed to reload arena after changing setting, reason:\n" + ChatColor.RED + e.getMessage());
|
||||
am.getGlobalMessenger().tell(sender, "Fix the error in your config-file, then run " + ChatColor.YELLOW + "/ma reload");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Notify the sender
|
||||
StringBuilder buffy = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user