diff --git a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java index 82359691c2..11c2aa84a3 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java @@ -68,4 +68,16 @@ public interface Plugin extends CommandExecutor { * Called when this plugin is enabled */ public void onEnable(); + + /** + * Simple boolean if we can still nag to the logs about things + * @return boolean whether we can nag + */ + public boolean isNaggable(); + + /** + * Set naggable state + * @param canNag is this plugin still naggable? + */ + public void setNaggable(boolean canNag); } 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 5cdee774c4..efa1f033e0 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -254,12 +254,16 @@ public final class SimplePluginManager implements PluginManager { 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() - )); + Plugin plugin = registration.getPlugin(); + if (plugin.isNaggable()) { + plugin.setNaggable(false); + server.getLogger().log(Level.SEVERE, String.format( + "Nag author: %s of %s about the following:", + plugin.getDescription().getAuthors().get(0), + plugin.getDescription().getName(), + ex.getMessage() + )); + } } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getType() + " to " + registration.getPlugin().getDescription().getName(), ex); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 10186f6c22..f33ddb78b7 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -24,6 +24,7 @@ public abstract class JavaPlugin implements Plugin { private File dataFolder = null; private ClassLoader classLoader = null; private Configuration config = null; + private boolean naggable = true; public JavaPlugin() { } @@ -189,4 +190,13 @@ public abstract class JavaPlugin implements Plugin { public void onLoad() { // Empty! } + + public final boolean isNaggable() { + return naggable; + } + + public final void setNaggable(boolean canNag) { + this.naggable = canNag;; + } + }