geforkt von Mirrors/Paper
Warn server owners of plugins using deprecated events. Fixes BUKKIT-2027
By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Ursprung
4535326014
Commit
6aae0dcd35
@ -8,6 +8,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -30,6 +31,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.AuthorNagException;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
@ -293,6 +295,24 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
eventSet = new HashSet<RegisteredListener>();
|
||||
ret.put(eventClass, eventSet);
|
||||
}
|
||||
|
||||
for (Class<?> clazz = eventClass; Event.class.isAssignableFrom(clazz); clazz = clazz.getSuperclass()) {
|
||||
// This loop checks for extending deprecated events
|
||||
if (clazz.getAnnotation(Deprecated.class) != null) {
|
||||
plugin.getLogger().log(
|
||||
Level.WARNING,
|
||||
String.format(
|
||||
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." +
|
||||
" Server performance will be affected; please notify the authors %s.",
|
||||
plugin.getDescription().getFullName(),
|
||||
clazz.getName(),
|
||||
method.toGenericString(),
|
||||
Arrays.toString(plugin.getDescription().getAuthors().toArray())),
|
||||
new AuthorNagException(null));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EventExecutor executor = new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
try {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren