From 5ca171b422605b173c288eb63e068fbc80c1a6c1 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 30 Dec 2010 18:54:04 +0000 Subject: [PATCH] Broken plugins no longer crash the server By: Dinnerbone --- .../dinnerbone/bukkit/sample/SamplePlayerListener.java | 9 +++++++++ .../src/com/dinnerbone/bukkit/sample/SamplePlugin.java | 1 + paper-api/src/org/bukkit/plugin/SimplePluginManager.java | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java index 75589bfc55..408e6a684a 100644 --- a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java +++ b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlayerListener.java @@ -6,6 +6,7 @@ import org.bukkit.Player; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerMoveEvent; /** * Handle events for all Player related events @@ -55,4 +56,12 @@ public class SamplePlayerListener extends PlayerListener { event.setCancelled(true); } } + + @Override + public void onPlayerMove(PlayerMoveEvent event) { + Location from = event.getFrom(); + Location to = event.getTo(); + + System.out.println(String.format("From %2$f,%2$f,%2$f to %2$f,%2$f,%2$f", from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ())); + } } diff --git a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java index 53bb1317e8..2c623670ab 100644 --- a/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java +++ b/paper-api/sample/src/com/dinnerbone/bukkit/sample/SamplePlugin.java @@ -37,5 +37,6 @@ public class SamplePlugin extends JavaPlugin { getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this); getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this); + getServer().getPluginManager().registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this); } } diff --git a/paper-api/src/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/org/bukkit/plugin/SimplePluginManager.java index eef3f8ef45..d2c4b770e6 100644 --- a/paper-api/src/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/org/bukkit/plugin/SimplePluginManager.java @@ -176,7 +176,11 @@ public final class SimplePluginManager implements PluginManager { PluginLoader loader = plugin.getPluginLoader(); if (plugin.isEnabled()) { - loader.callEvent(registration, event); + try { + loader.callEvent(registration, event); + } catch (Throwable ex) { + Logger.getLogger(SimplePluginManager.class.getName()).log(Level.SEVERE, "Could not pass event " + event.getType() + " to " + plugin.getDescription().getName(), ex); + } } } }