[ci skip] Replace FQN with import in EventExecutor
This commit is contained in:
@@ -1,17 +1,14 @@
|
|||||||
package org.bukkit.plugin;
|
package org.bukkit.plugin;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import com.google.common.base.Preconditions;
|
||||||
import org.bukkit.event.EventException;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
// Paper start
|
|
||||||
import io.papermc.paper.event.executor.EventExecutorFactory;
|
import io.papermc.paper.event.executor.EventExecutorFactory;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
import com.google.common.base.Preconditions;
|
import org.bukkit.event.EventException;
|
||||||
// Paper end
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface which defines the class for event call backs to plugins
|
* Interface which defines the class for event call backs to plugins
|
||||||
@@ -21,18 +18,18 @@ public interface EventExecutor {
|
|||||||
|
|
||||||
// Paper start
|
// Paper start
|
||||||
@NotNull
|
@NotNull
|
||||||
public static EventExecutor create(@NotNull Method m, @NotNull Class<? extends Event> eventClass) {
|
static EventExecutor create(@NotNull Method m, @NotNull Class<? extends Event> eventClass) {
|
||||||
Preconditions.checkNotNull(m, "Null method");
|
Preconditions.checkNotNull(m, "Null method");
|
||||||
Preconditions.checkArgument(m.getParameterCount() != 0, "Incorrect number of arguments %s", m.getParameterCount());
|
Preconditions.checkArgument(m.getParameterCount() != 0, "Incorrect number of arguments %s", m.getParameterCount());
|
||||||
Preconditions.checkArgument(m.getParameterTypes()[0] == eventClass, "First parameter %s doesn't match event class %s", m.getParameterTypes()[0], eventClass);
|
Preconditions.checkArgument(m.getParameterTypes()[0] == eventClass, "First parameter %s doesn't match event class %s", m.getParameterTypes()[0], eventClass);
|
||||||
if (m.getReturnType() != Void.TYPE) {
|
if (m.getReturnType() != Void.TYPE) {
|
||||||
final org.bukkit.plugin.java.JavaPlugin plugin = org.bukkit.plugin.java.JavaPlugin.getProvidingPlugin(m.getDeclaringClass());
|
final JavaPlugin plugin = JavaPlugin.getProvidingPlugin(m.getDeclaringClass());
|
||||||
org.bukkit.Bukkit.getLogger().warning("@EventHandler method " + m.getDeclaringClass().getName() + (Modifier.isStatic(m.getModifiers()) ? '.' : '#') + m.getName()
|
org.bukkit.Bukkit.getLogger().warning("@EventHandler method " + m.getDeclaringClass().getName() + (Modifier.isStatic(m.getModifiers()) ? '.' : '#') + m.getName()
|
||||||
+ " returns non-void type " + m.getReturnType().getName() + ". This is unsupported behavior and will no longer work in a future version of Paper."
|
+ " returns non-void type " + m.getReturnType().getName() + ". This is unsupported behavior and will no longer work in a future version of Paper."
|
||||||
+ " This should be reported to the developers of " + plugin.getPluginMeta().getDisplayName() + " (" + String.join(",", plugin.getPluginMeta().getAuthors()) + ')');
|
+ " This should be reported to the developers of " + plugin.getPluginMeta().getDisplayName() + " (" + String.join(",", plugin.getPluginMeta().getAuthors()) + ')');
|
||||||
}
|
}
|
||||||
if (!m.trySetAccessible()) {
|
if (!m.trySetAccessible()) {
|
||||||
final org.bukkit.plugin.java.JavaPlugin plugin = org.bukkit.plugin.java.JavaPlugin.getProvidingPlugin(m.getDeclaringClass());
|
final JavaPlugin plugin = JavaPlugin.getProvidingPlugin(m.getDeclaringClass());
|
||||||
throw new AssertionError(
|
throw new AssertionError(
|
||||||
"@EventHandler method " + m.getDeclaringClass().getName() + (Modifier.isStatic(m.getModifiers()) ? '.' : '#') + m.getName() + " is not accessible."
|
"@EventHandler method " + m.getDeclaringClass().getName() + (Modifier.isStatic(m.getModifiers()) ? '.' : '#') + m.getName() + " is not accessible."
|
||||||
+ " This should be reported to the developers of " + plugin.getDescription().getName() + " (" + String.join(",", plugin.getDescription().getAuthors()) + ')'
|
+ " This should be reported to the developers of " + plugin.getDescription().getName() + " (" + String.join(",", plugin.getDescription().getAuthors()) + ')'
|
||||||
|
|||||||
Reference in New Issue
Block a user