From 2e99a0f17dd137017c3f0b3c1db6255f1f93f48d Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 30 Mar 2011 00:25:11 +0200 Subject: [PATCH] Add 'NagException' to disclose plugin fail By: Erik Broes --- .../org/bukkit/plugin/AuthorNagException.java | 20 +++++++++++++++++++ .../bukkit/plugin/SimplePluginManager.java | 7 +++++++ 2 files changed, 27 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/plugin/AuthorNagException.java diff --git a/paper-api/src/main/java/org/bukkit/plugin/AuthorNagException.java b/paper-api/src/main/java/org/bukkit/plugin/AuthorNagException.java new file mode 100644 index 0000000000..d652891cbb --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/plugin/AuthorNagException.java @@ -0,0 +1,20 @@ +package org.bukkit.plugin; + +public class AuthorNagException extends RuntimeException { + private final String message; + + /** + * Constructs a new UnknownDependencyException based on the given Exception + * + * @param message Brief message explaining the cause of the exception + * @param throwable Exception that triggered this Exception + */ + public AuthorNagException(final String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } +} diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 47eaabc9d3..5cdee774c4 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -253,6 +253,13 @@ public final class SimplePluginManager implements PluginManager { for (RegisteredListener registration : eventListeners) { try { registration.callEvent( event ); + } catch (AuthorNagException ex) { + server.getLogger().log(Level.SEVERE, String.format( + "Nag author: %s of %s about the following:", + registration.getPlugin().getDescription().getAuthors().get(0), + registration.getPlugin().getDescription().getName(), + ex.getMessage() + )); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getType() + " to " + registration.getPlugin().getDescription().getName(), ex); }