mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 01:12:47 +01:00
c0936a71bd
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
177 lines
8 KiB
Diff
177 lines
8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
|
|
Date: Sat, 19 Nov 2022 19:46:44 +0100
|
|
Subject: [PATCH] Add /paper dumplisteners command
|
|
|
|
|
|
diff --git a/src/main/java/co/aikar/timings/TimedEventExecutor.java b/src/main/java/co/aikar/timings/TimedEventExecutor.java
|
|
index be275c25664e0c76123371c6c8fac601f87fa492..8f29c1561ba5916cb5634392edd8bd2a5a294a51 100644
|
|
--- a/src/main/java/co/aikar/timings/TimedEventExecutor.java
|
|
+++ b/src/main/java/co/aikar/timings/TimedEventExecutor.java
|
|
@@ -81,4 +81,10 @@ public class TimedEventExecutor implements EventExecutor {
|
|
executor.execute(listener, event);
|
|
}
|
|
}
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public String toString() {
|
|
+ return "TimedEventExecutor['" + this.executor.toString() + "']";
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
|
index 5b28e9b1daba7834af67dbc193dd656bedd9a994..fbebf649e893cf872be9b27091146a7c2f451aca 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
|
@@ -14,10 +14,12 @@ import org.jetbrains.annotations.NotNull;
|
|
public class MethodHandleEventExecutor implements EventExecutor {
|
|
private final Class<? extends Event> eventClass;
|
|
private final MethodHandle handle;
|
|
+ private final Method method;
|
|
|
|
public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull MethodHandle handle) {
|
|
this.eventClass = eventClass;
|
|
this.handle = handle;
|
|
+ this.method = null;
|
|
}
|
|
|
|
public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) {
|
|
@@ -28,6 +30,7 @@ public class MethodHandleEventExecutor implements EventExecutor {
|
|
} catch (IllegalAccessException e) {
|
|
throw new AssertionError("Unable to set accessible", e);
|
|
}
|
|
+ this.method = m;
|
|
}
|
|
|
|
@Override
|
|
@@ -39,4 +42,10 @@ public class MethodHandleEventExecutor implements EventExecutor {
|
|
SneakyThrow.sneaky(t);
|
|
}
|
|
}
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public String toString() {
|
|
+ return "MethodHandleEventExecutor['" + this.method + "']";
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
|
index c83672427324bd068ed52916f700b68446a226f6..87ea5354808dbbdefbdfc78f352a543f72a0d033 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
|
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
|
public class StaticMethodHandleEventExecutor implements EventExecutor {
|
|
private final Class<? extends Event> eventClass;
|
|
private final MethodHandle handle;
|
|
+ private final Method method;
|
|
|
|
public StaticMethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) {
|
|
Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m);
|
|
@@ -29,6 +30,7 @@ public class StaticMethodHandleEventExecutor implements EventExecutor {
|
|
} catch (IllegalAccessException e) {
|
|
throw new AssertionError("Unable to set accessible", e);
|
|
}
|
|
+ this.method = m;
|
|
}
|
|
|
|
@Override
|
|
@@ -40,4 +42,10 @@ public class StaticMethodHandleEventExecutor implements EventExecutor {
|
|
SneakyThrow.sneaky(throwable);
|
|
}
|
|
}
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public String toString() {
|
|
+ return "StaticMethodHandleEventExecutor['" + this.method + "']";
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/event/HandlerList.java b/src/main/java/org/bukkit/event/HandlerList.java
|
|
index ed78cca71f83b296d082d0af147ca8d622c7606a..2292bd460ce2be113beb4ba6b4eb19350060f01c 100644
|
|
--- a/src/main/java/org/bukkit/event/HandlerList.java
|
|
+++ b/src/main/java/org/bukkit/event/HandlerList.java
|
|
@@ -33,6 +33,13 @@ public class HandlerList {
|
|
*/
|
|
private static ArrayList<HandlerList> allLists = new ArrayList<HandlerList>();
|
|
|
|
+ // Paper start
|
|
+ /**
|
|
+ * Event types which have instantiated a {@link HandlerList}.
|
|
+ */
|
|
+ private static final java.util.Set<String> EVENT_TYPES = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
|
+ // Paper end
|
|
+
|
|
/**
|
|
* Bake all handler lists. Best used just after all normal event
|
|
* registration is complete, ie just after all plugins are loaded if
|
|
@@ -94,6 +101,12 @@ public class HandlerList {
|
|
* The HandlerList is then added to meta-list for use in bakeAll()
|
|
*/
|
|
public HandlerList() {
|
|
+ // Paper start
|
|
+ java.lang.StackWalker.getInstance(java.util.EnumSet.of(java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE), 4)
|
|
+ .walk(s -> s.filter(f -> Event.class.isAssignableFrom(f.getDeclaringClass())).findFirst())
|
|
+ .map(f -> f.getDeclaringClass().getName())
|
|
+ .ifPresent(EVENT_TYPES::add);
|
|
+ // Paper end
|
|
handlerslots = new EnumMap<EventPriority, ArrayList<RegisteredListener>>(EventPriority.class);
|
|
for (EventPriority o : EventPriority.values()) {
|
|
handlerslots.put(o, new ArrayList<RegisteredListener>());
|
|
diff --git a/src/main/java/org/bukkit/plugin/EventExecutor.java b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
index 5fa52419f21d8e8b3d8f9aafd248b05774a28348..60e086be70529e0804280b24a2a3e7ae72d8d363 100644
|
|
--- a/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
+++ b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
@@ -70,9 +70,18 @@ public interface EventExecutor {
|
|
try {
|
|
EventExecutor asmExecutor = executorClass.newInstance();
|
|
// Define a wrapper to conform to bukkit stupidity (passing in events that don't match and wrapper exception)
|
|
- return (listener, event) -> {
|
|
- if (!eventClass.isInstance(event)) return;
|
|
- asmExecutor.execute(listener, event);
|
|
+ return new EventExecutor() {
|
|
+ @Override
|
|
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
|
|
+ if (!eventClass.isInstance(event)) return;
|
|
+ asmExecutor.execute(listener, event);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public String toString() {
|
|
+ return "ASMEventExecutor['" + m + "']";
|
|
+ }
|
|
};
|
|
} catch (InstantiationException | IllegalAccessException e) {
|
|
throw new AssertionError("Unable to initialize generated event executor", e);
|
|
diff --git a/src/main/java/org/bukkit/plugin/RegisteredListener.java b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
|
index 419aec56b0e3fa8bcec2ea7f340caa3456b57d00..3b3d9642a8d63798dc28f2f8df77f0466451cbff 100644
|
|
--- a/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
|
+++ b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
|
@@ -78,4 +78,27 @@ public class RegisteredListener {
|
|
public boolean isIgnoringCancelled() {
|
|
return ignoreCancelled;
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ /**
|
|
+ * Get the executor for this registration.
|
|
+ *
|
|
+ * @return executor
|
|
+ */
|
|
+ @NotNull
|
|
+ public EventExecutor getExecutor() {
|
|
+ return this.executor;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String toString() {
|
|
+ return "RegisteredListener{"
|
|
+ + "plugin=\"" + this.plugin.getName()
|
|
+ + "\", listener=\"" + this.listener
|
|
+ + "\", executor=\"" + this.executor
|
|
+ + "\", priority=\"" + this.priority.name() + " (" + this.priority.getSlot() + ")"
|
|
+ + "\", ignoringCancelled=" + this.ignoreCancelled
|
|
+ + "}";
|
|
+ }
|
|
+ // Paper end
|
|
}
|