Wrap plugin.getDefaultWorldGenerator in try-catch. Fixes BUKKIT-4116

If a plugin generates an exception when returning a world generator, the
server will crash. This change adds a try-catch block to keep the server
from crashing on plugin defined world generators.
This commit is contained in:
riking 2013-04-18 17:50:05 -07:00 committed by Wesley Wolfe
parent 71a6a56572
commit 0506b709fe

View file

@ -1014,9 +1014,13 @@ public final class CraftServer implements Server {
} else if (!plugin.isEnabled()) { } else if (!plugin.isEnabled()) {
getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled yet (is it load:STARTUP?)"); getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled yet (is it load:STARTUP?)");
} else { } else {
result = plugin.getDefaultWorldGenerator(world, id); try {
if (result == null) { result = plugin.getDefaultWorldGenerator(world, id);
getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator"); if (result == null) {
getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator");
}
} catch (Throwable t) {
plugin.getLogger().log(Level.SEVERE, "Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName(), t);
} }
} }
} }