geforkt von Mirrors/Paper
Just NAG once, to be nice
By: Erik Broes <erikbroes@grum.nl>
Dieser Commit ist enthalten in:
Ursprung
db5dfb3f10
Commit
69973b8617
@ -68,4 +68,16 @@ public interface Plugin extends CommandExecutor {
|
|||||||
* Called when this plugin is enabled
|
* Called when this plugin is enabled
|
||||||
*/
|
*/
|
||||||
public void onEnable();
|
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);
|
||||||
}
|
}
|
||||||
|
@ -254,12 +254,16 @@ public final class SimplePluginManager implements PluginManager {
|
|||||||
try {
|
try {
|
||||||
registration.callEvent( event );
|
registration.callEvent( event );
|
||||||
} catch (AuthorNagException ex) {
|
} catch (AuthorNagException ex) {
|
||||||
server.getLogger().log(Level.SEVERE, String.format(
|
Plugin plugin = registration.getPlugin();
|
||||||
"Nag author: %s of %s about the following:",
|
if (plugin.isNaggable()) {
|
||||||
registration.getPlugin().getDescription().getAuthors().get(0),
|
plugin.setNaggable(false);
|
||||||
registration.getPlugin().getDescription().getName(),
|
server.getLogger().log(Level.SEVERE, String.format(
|
||||||
ex.getMessage()
|
"Nag author: %s of %s about the following:",
|
||||||
));
|
plugin.getDescription().getAuthors().get(0),
|
||||||
|
plugin.getDescription().getName(),
|
||||||
|
ex.getMessage()
|
||||||
|
));
|
||||||
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getType() + " to " + registration.getPlugin().getDescription().getName(), ex);
|
server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getType() + " to " + registration.getPlugin().getDescription().getName(), ex);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
private File dataFolder = null;
|
private File dataFolder = null;
|
||||||
private ClassLoader classLoader = null;
|
private ClassLoader classLoader = null;
|
||||||
private Configuration config = null;
|
private Configuration config = null;
|
||||||
|
private boolean naggable = true;
|
||||||
|
|
||||||
public JavaPlugin() {
|
public JavaPlugin() {
|
||||||
}
|
}
|
||||||
@ -189,4 +190,13 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
// Empty!
|
// Empty!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean isNaggable() {
|
||||||
|
return naggable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setNaggable(boolean canNag) {
|
||||||
|
this.naggable = canNag;;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren