PaperMC/patches/api/0391-Add-paper-dumplisteners-command.patch
Jake Potrebic 2fa8efce9b
Updated Upstream (Bukkit/CraftBukkit) (#9485)
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:
82af5dc6 SPIGOT-7396: Add PlayerSignOpenEvent
3f0281ca SPIGOT-7063, PR-763: Add DragonBattle#initiateRespawn with custom EnderCrystals
f83c8df4 PR-873: Add PlayerRecipeBookClickEvent
14560d39 SPIGOT-7435: Add TeleportCause#EXIT_BED
2cc6db92 SPIGOT-7422, PR-887: Add API to set sherds on decorated pots
36022f02 PR-883: Add ItemFactory#getSpawnEgg
12eb5c46 PR-881: Update Scoreboard Javadocs, remove explicit exception throwing
f6d8d44a PR-882: Add modern time API methods to ban API
21a7b710 Upgrade some Maven plugins to reduce warnings
11fd1225 PR-886: Deprecate the SmithingRecipe constructor as it now does nothing
dbd1761d SPIGOT-7406: Improve documentation for getDragonBattle

CraftBukkit Changes:
d548daac2 SPIGOT-7446: BlockState#update not updating a spawner's type to null
70e0bc050 SPIGOT-7447: Fix --forceUpgrade
6752f1d63 SPIGOT-7396: Add PlayerSignOpenEvent
847b4cad5 SPIGOT-7063, PR-1071: Add DragonBattle#initiateRespawn with custom EnderCrystals
c335a555f PR-1212: Add PlayerRecipeBookClickEvent
4be756ecb SPIGOT-7445: Fix opening smithing inventory
db70bd6ed SPIGOT-7441: Fix issue placing certain items in creative/op
f7fa6d993 SPIGOT-7435: Add TeleportCause#EXIT_BED
b435e8e8d SPIGOT-7349: Player#setDisplayName not working when message/format unmodified
a2fafdd1d PR-1232: Re-add fix for player rotation
7cf863de1 PR-1233: Remove some old MC bug fixes now fixed in vanilla
08ec344ad Fix ChunkGenerator#generateCaves never being called
5daeb502a SPIGOT-7422, PR-1228: Add API to set sherds on decorated pots
52faa6b32 PR-1224: Add ItemFactory#getSpawnEgg
01cae71b7 SPIGOT-7429: Fix LEFT_CLICK_AIR not working for passable entities and spectators
a94277a18 PR-1223: Remove non-existent scoreboard display name/prefix/suffix limits
36b107660 PR-1225: Add modern time API methods to ban API
59ead25bc Upgrade some Maven plugins to reduce warnings
202fc5c4e Increase outdated build delay
ce545de57 SPIGOT-7398: TextDisplay#setInterpolationDuration incorrectly updates the line width

Spigot Changes:
b41c46db Rebuild patches
3374045a SPIGOT-7431: Fix EntityMountEvent returning opposite entities
0ca4eb66 Rebuild patches
2023-08-05 17:21:59 -07:00

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
}