From 0506b709fe9d325725a3ef1c758b7c9843dd7310 Mon Sep 17 00:00:00 2001 From: riking Date: Thu, 18 Apr 2013 17:50:05 -0700 Subject: [PATCH] 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. --- src/main/java/org/bukkit/craftbukkit/CraftServer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 51afd2564e..df2efe2c3e 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1014,9 +1014,13 @@ public final class CraftServer implements Server { } 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?)"); } else { - result = plugin.getDefaultWorldGenerator(world, id); - if (result == null) { - getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator"); + try { + result = plugin.getDefaultWorldGenerator(world, id); + 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); } } }