mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-11 11:58:49 +01:00
74c4554995
* Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 151457628 Fix Counter#decrement recursive call (#5665) 21ac7dc98 [Auto] Updated Upstream (CraftBukkit) 18ad2c9dd Add environment variable (PAPER_DISABLE_SERVER_GUI) to disable server gui 6ecbe5776 Rename leftover resource->datapack (#5662) ec90a7859 I give up on trying to teach people to avoid the incorrect ways. dc7b7a160 Fix missing username console death message (#5654) (#5658) c639a52a6 Add basic Datapack API (#5653) (#5653) 99c1d9da6 Updated Upstream (CraftBukkit) (#5652) 2d50c17e2 [CI-SKIP] Add PR rebasing steps (#5634) 2c5f8085e Remove boat interaction event (Fixes #5539) 96ee1fb8f fix WorldSaveEvent not firing with /save-all (#5650) e90e7829e remove unneeded patch (#5641) d875bacc2 Activate warning by default when people are doing silly things (#5642) cb896d471 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5643) ecbf5a38e Revert "Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636)" 20fc4ab70 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636) 20d8812ea Fix CraftPotionBrewer cache (#5632) cd6ae8816 Add a "Should Burn in Sunlight" API for Phantoms and Skeletons (#5608) 25edfe58b Remove unneeded component conversion for kick msg (#5626) cec386f66 Call PortalCreateEvent when players enter the end (#5618) 453c7f05c Add ItemStack#displayName to get the formatted display name of an ItemStack (#5628) 4efe8b498 Update Java version warning (#5621) e0a021ccc Add ItemStack#getTranslationKey() (#5616) 53d71b717 Add setPotionUseTimeLeft to Witch (#5597) 239935d18 Add Inventory#close (#5610) 29bf6cd41 Updated Upstream (CraftBukkit) ad45f316c Add raw address to AsyncPlayerPreLoginEvent (#5614) 28865335a [Auto] Updated Upstream (CraftBukkit) 750049fa2 Fix incorrect colors in some log messages (#5609) c5fa3f0d4 Add Adventure message to PlayerAdvancementDoneEvent (#5030) 69c09cdb0 Updated Upstream (CraftBukkit) (#5607) Tuinity Changes: 1222573 Fix incorrect status dataconverter for pre 1.13 chunks Airplane Changes: 3dce697 Fix gradle stuff 209bce3 Patches Purpur Changes: 72708f4 Option to disable dragon egg teleporting 5f87a45 Updated Upstream (Paper) 7bfc70d swap heavy logic to end bb9d72d Fix #338 - Phantoms always burning bug 8fa99b3 Configurable critical damage multiplier (#339) dc4a1cb Updated Upstream (Paper & Tuinity) c166841 Configurable powered rail boost modifier (closes #329) (#333) ab9b8ca Updated Upstream (Paper & Airplane) 44e72f7 Let parrots breed using any tempting item 09d98d3 this part is important, too :3 2015fe5 Breedable parrots 552d783 Iron golem poppy calms anger 1fa06a1 Optimize collisions (#328) 1112240 Extend Halloween Optimization (#321) 03f1aec Config for health to impact Creeper explosion radius (#304) 8f7bce4 Add config for hidden from entity selector patch 21906a2 Hide hidden players from entity selector 445496d [ci-skip] fix this too, now.. jfc 3ba8c81 Ya'll didn't see nothing.. 2d4611b Updated Upstream (Paper) beed258 Better offline mode warning (#330) c1efe3c It's meant to be double 🤦 3f9958b Implement the Mob Blindness mod 6e98c88 Add missing repo to settings.gradle.kts da5185b Update Gradle to 7.0.1 fbd28d8 Updated Upstream (Paper & Tuinity) cb42dec Updated Upstream (Paper) e883991 Fix compatibility with MyPet Origami Changes: 4c0616d Update Paper * Updated Upstream and Sidestream(s) (Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 45e19ffb0 [Auto] Updated Upstream (CraftBukkit) * Updated Upstream and Sidestream(s) (Paper/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) Purpur Changes: ca9be56 Do not allow duplicate unsafe enchants * Updated Upstream and Sidestream(s) (Paper/Purpur/Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) Purpur Changes: ca9be56 Do not allow duplicate unsafe enchants Paper Changes: 322886c86 Avoid NPE due to PlayerBedFailEnterEvent d3c9a195c removed duplicate ProjectileHitEvent for fireball (#5671) * Updated Upstream and Sidestream(s) (Paper/Airplane/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 2c6b1f048 Revert "Remove itneract event from boat" (Fixes #5677) aae1c54a9 Add command line option to load extra plugin jars not in the plugins folder Airplane Changes: 4a22184 Updated Upstream (Tuinity) Empirecraft Changes: d0aaf527 Updated Paper * Updated Upstream and Sidestream(s) (Airplane/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Airplane Changes: 046ae54 Improve hopper performance via bitset Purpur Changes: c333d3d Add config for the unverified username message (#348) 703b5da Fix invulnerable-while-accepting-resource-pack not being used * Updated Upstream and Sidestream(s) (Paper/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 6c183f1ae [Auto] Updated Upstream (CraftBukkit) Purpur Changes: e0991e0 allow using legacy section symbol in unverified username message 6bd246b Updated Upstream (Paper) * Updated Upstream and Sidestream(s) (Airplane) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Airplane Changes: 5fab6a2 Improvements to fluid & profiler patches * Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 41e6073ce [Auto] Updated Upstream (CraftBukkit) 6f93dc95d Add cause to Weather/ThunderChangeEvents (#4832) 507cf19b3 [CI-SKIP] [Auto] Rebuild Patches afe0785bf Added PlayerPurchaseEvent for standalone Merchant GUIs (#5583) 615df3d8a Fix entity motion tag from mob spawners (#5718) 2d34898b5 Add methods for getting default item attributes (#5593) d9766433e Add EntityInsideBlockEvent (#5596) 47d48790d Change return type of ItemStack#editMeta to allow checking for successful vs non-successful edits 7aabe7d56 [CI-SKIP] fix minecart vs minecraft typos (#5713) f775e87b4 [CI-SKIP] ci: update setup-java action (#5710) c58b3b277 ci: replace Java 11 with Java 16 in GH Actions build flow (#5709) 4b72327a6 ItemStack#editMeta 68984b664 Add Unix domain socket support (#5611) 68c67e680 Add Mob#lookAt API (#5633) 4bacecd16 [Auto] Updated Upstream (Bukkit/CraftBukkit) 1f28e6eeb Fix default ChatRenderer when no plugins are installed (#5702) ecb0d32ca Enhance (Async)ChatEvent with per-viewer rendering API (#5684) f3e541ca1 Actually list all missing hard depends (#5701) 11f83fe8e [CI-SKIP] [Auto] Rebuild Patches a36e5d65f MC-148809: Fix incorrect structure block data length 3dcbdc73b Fix force upgrade patch (#5699) dab6ec6cd List all missing hard depends not just first (#5673) aed5031e3 Fix/Optimize world and light datafixes (#5693) 719040d92 [Auto] Updated Upstream (CraftBukkit) Tuinity Changes: f0e91a4 Updated Upstream (Paper) f88659c Fix and optimise world force upgrading Airplane Changes: 636dbff [ci skip] Cleanup mcdev import files c579320 [ci skip] Remove icons 7ada9a4 [skip ci] Need to specify 1.16.5 in the README of course 813df1a Update README daf3f0b Optimize air case for raytracing 1c252a5 Update Tuinity URL 50babee Updated Upstream (Tuinity) 85e0c63 Revert "Allow plugins to stupidly replace server internals" db3fe2c Remove auto import 6b32e01 Allow plugins to stupidly replace server internals f849f00 Flare Update ac10e43 Flare Update 7f3b091 Move check 040fa19 Better checking for useless move packets Purpur Changes: adb0cafe Updated Upstream (Paper) f9ccf6dd Updated Upstream (Paper & Airplane) 1343a050 Updated Upstream (Paper, Tuinity, & Airplane) af2dd61a Updated Upstream (Paper, Tuinity, & Airplane) 1808888a Expand gamemode extra perms some more Empirecraft Changes: 9e2881e6 Don't dismount on teleports... 7ed16bf3 Updated Paper c3d0a1b2 Re-add missing line in Vehicle teleporting patch * drop Improved-oversized-chunk-data-packet-handling.patch
259 lines
13 KiB
Diff
259 lines
13 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: ishland <ishlandmc@yeah.net>
|
|
Date: Fri, 29 Jan 2021 09:57:47 +0800
|
|
Subject: [PATCH] Suspected plugins report
|
|
|
|
Added "Suspected Plugins" to Watchdog, crash reports and exception messages
|
|
|
|
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
index d1c35e4cf778070f8d18bbe0af8d423334c6dfbf..d87c8e97a4a73f8df1f5badc7bdfea18a54e406b 100644
|
|
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
@@ -577,7 +577,11 @@ public final class SimplePluginManager implements PluginManager {
|
|
|
|
// Paper start
|
|
private void handlePluginException(String msg, Throwable ex, Plugin plugin) {
|
|
- server.getLogger().log(Level.SEVERE, msg, ex);
|
|
+ // Yatopia start - detailed report
|
|
+ server.getLogger().log(Level.SEVERE, msg);
|
|
+ org.yatopiamc.yatopia.api.internal.StackTraceUtils.print(ex, _msg -> server.getLogger().log(Level.SEVERE, _msg));
|
|
+ server.getLogger().log(Level.SEVERE, org.yatopiamc.yatopia.api.internal.StackTraceUtils.EXCEPTION_DETAILS_BELOW, ex);
|
|
+ // Yatopia end
|
|
callEvent(new ServerExceptionEvent(new ServerPluginEnableDisableException(msg, ex, plugin)));
|
|
}
|
|
// Paper end
|
|
@@ -638,7 +642,11 @@ public final class SimplePluginManager implements PluginManager {
|
|
} catch (Throwable ex) {
|
|
// Paper start - error reporting
|
|
String msg = "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName();
|
|
- server.getLogger().log(Level.SEVERE, msg, ex);
|
|
+ // Yatopia start - detailed report
|
|
+ server.getLogger().log(Level.SEVERE, msg);
|
|
+ org.yatopiamc.yatopia.api.internal.StackTraceUtils.print(ex, _msg -> server.getLogger().log(Level.SEVERE, _msg));
|
|
+ server.getLogger().log(Level.SEVERE, org.yatopiamc.yatopia.api.internal.StackTraceUtils.EXCEPTION_DETAILS_BELOW, ex);
|
|
+ // Yatopia end
|
|
if (!(event instanceof ServerExceptionEvent)) { // We don't want to cause an endless event loop
|
|
callEvent(new ServerExceptionEvent(new ServerEventException(msg, ex, registration.getPlugin(), registration.getListener(), event)));
|
|
}
|
|
@@ -922,4 +930,10 @@ public final class SimplePluginManager implements PluginManager {
|
|
}
|
|
// Paper end
|
|
|
|
+ // Yatopia start - Accessor
|
|
+ @NotNull
|
|
+ public Collection<PluginLoader> getPluginLoaders() {
|
|
+ return new HashSet<>(fileAssociations.values());
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
|
|
index 04fa3991f6ce4e9dad804f28fc6c947695857089..cb11eab6e13ed1c395b8f7db033c9a2817f4089c 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
|
|
@@ -111,7 +111,7 @@ public abstract class JavaPlugin extends PluginBase {
|
|
* @return File containing this plugin
|
|
*/
|
|
@NotNull
|
|
- protected File getFile() {
|
|
+ public File getFile() { // Yatopia
|
|
return file;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
index b622cedeeee017f042bcf92485d81832030a8030..f1d3042e7f224059547ac840524cae5dd80ecd8b 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
@@ -369,7 +369,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
try {
|
|
jPlugin.setEnabled(true);
|
|
} catch (Throwable ex) {
|
|
- server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
|
+ // Yatopia start - detailed report
|
|
+ server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)");
|
|
+ org.yatopiamc.yatopia.api.internal.StackTraceUtils.print(ex, _msg -> server.getLogger().log(Level.SEVERE, _msg));
|
|
+ server.getLogger().log(Level.SEVERE, org.yatopiamc.yatopia.api.internal.StackTraceUtils.EXCEPTION_DETAILS_BELOW, ex);
|
|
+ // Yatopia end
|
|
// Paper start - Disable plugins that fail to load
|
|
server.getPluginManager().disablePlugin(jPlugin, true); // Paper - close Classloader on disable - She's dead jim
|
|
return;
|
|
@@ -404,7 +408,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
try {
|
|
jPlugin.setEnabled(false);
|
|
} catch (Throwable ex) {
|
|
- server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
|
+ // Yatopia start - detailed report
|
|
+ server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)");
|
|
+ org.yatopiamc.yatopia.api.internal.StackTraceUtils.print(ex, _msg -> server.getLogger().log(Level.SEVERE, _msg));
|
|
+ server.getLogger().log(Level.SEVERE, org.yatopiamc.yatopia.api.internal.StackTraceUtils.EXCEPTION_DETAILS_BELOW, ex);
|
|
+ // Yatopia end
|
|
}
|
|
|
|
if (cloader instanceof PluginClassLoader) {
|
|
@@ -428,11 +436,20 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
loader.close();
|
|
}
|
|
} catch (IOException e) {
|
|
+ // Yatopia start - detailed report
|
|
server.getLogger().log(Level.WARNING, "Error closing the Plugin Class Loader for " + plugin.getDescription().getFullName());
|
|
+ org.yatopiamc.yatopia.api.internal.StackTraceUtils.print(e, _msg -> server.getLogger().log(Level.WARNING, _msg));
|
|
+ server.getLogger().log(Level.WARNING, org.yatopiamc.yatopia.api.internal.StackTraceUtils.EXCEPTION_DETAILS_BELOW, e);
|
|
+ // Yatopia end
|
|
e.printStackTrace();
|
|
}
|
|
// Paper end
|
|
}
|
|
}
|
|
}
|
|
+ // Yatopia start - Accessor
|
|
+ public List<PluginClassLoader> getClassLoaders() {
|
|
+ return java.util.Collections.unmodifiableList(loaders);
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
index 6ced06643cd9740e2c62bc8f10d150a2f9a92e31..161263242860fbae7b05766f006a7a83df82fc03 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
|
@@ -250,4 +250,13 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
|
|
'}';
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Yatopia start - Accessor
|
|
+ public java.util.Collection<Class<?>> getLoadedClasses() {
|
|
+ return java.util.Collections.unmodifiableCollection(
|
|
+ new java.util.HashSet<>(classes.values()).stream()
|
|
+ .filter(clazz -> clazz.getClassLoader() == this).collect(java.util.stream.Collectors.toSet())
|
|
+ );
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
diff --git a/src/main/java/org/yatopiamc/yatopia/api/internal/StackTraceUtils.java b/src/main/java/org/yatopiamc/yatopia/api/internal/StackTraceUtils.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..0aa9bc6ad0a85d469b29201b9da29165bafb874c
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/yatopiamc/yatopia/api/internal/StackTraceUtils.java
|
|
@@ -0,0 +1,105 @@
|
|
+package org.yatopiamc.yatopia.api.internal;
|
|
+
|
|
+import com.google.common.base.Suppliers;
|
|
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.plugin.Plugin;
|
|
+import org.bukkit.plugin.PluginLoader;
|
|
+import org.bukkit.plugin.SimplePluginManager;
|
|
+import org.bukkit.plugin.java.JavaPlugin;
|
|
+import org.bukkit.plugin.java.JavaPluginLoader;
|
|
+import org.bukkit.plugin.java.PluginClassLoader;
|
|
+
|
|
+import java.util.Arrays;
|
|
+import java.util.Collection;
|
|
+import java.util.Collections;
|
|
+import java.util.HashSet;
|
|
+import java.util.List;
|
|
+import java.util.Map;
|
|
+import java.util.Set;
|
|
+import java.util.concurrent.TimeUnit;
|
|
+import java.util.function.Consumer;
|
|
+import java.util.function.Supplier;
|
|
+import java.util.stream.Collectors;
|
|
+
|
|
+public class StackTraceUtils {
|
|
+
|
|
+ public static final String EXCEPTION_DETAILS_BELOW = "Exception details below: ";
|
|
+
|
|
+ private static final Supplier<Map<Plugin, Set<Class<?>>>> loadedClassesSupplier = Suppliers.memoizeWithExpiration(StackTraceUtils::scanForPluginClasses, 5, TimeUnit.SECONDS);
|
|
+
|
|
+ public static void print(StackTraceElement[] stackTrace, Consumer<String> out) {
|
|
+ Set<Plugin> suspectedPlugins = getSuspectedPluginsFromStackTrace(stackTrace);
|
|
+
|
|
+ printSuspectedPlugins(out, suspectedPlugins);
|
|
+ }
|
|
+
|
|
+ public static void print(Throwable t, Consumer<String> out) {
|
|
+ Set<Plugin> suspectedPlugins = getSuspectedPluginsFromStackTrace(getStackTracesFromThrowable(t).toArray(new StackTraceElement[0]));
|
|
+
|
|
+ printSuspectedPlugins(out, suspectedPlugins);
|
|
+ }
|
|
+
|
|
+ private static Set<StackTraceElement> getStackTracesFromThrowable(Throwable t) {
|
|
+ if(t == null) return Collections.emptySet();
|
|
+ Set<StackTraceElement> elements = new ObjectOpenHashSet<>();
|
|
+ elements.addAll(getStackTracesFromThrowable(t.getCause()));
|
|
+ elements.addAll(Arrays.stream(t.getSuppressed()).flatMap(throwable -> getStackTracesFromThrowable(throwable).stream()).collect(Collectors.toSet()));
|
|
+ elements.addAll(Arrays.asList(t.getStackTrace()));
|
|
+ return elements;
|
|
+ }
|
|
+
|
|
+ private static void printSuspectedPlugins(Consumer<String> out, Set<Plugin> suspectedPlugins) {
|
|
+ if (!suspectedPlugins.isEmpty()) {
|
|
+ out.accept("Suspected Plugins: ");
|
|
+ for (Plugin plugin : suspectedPlugins) {
|
|
+ StringBuilder builder = new StringBuilder("\t");
|
|
+ builder.append(plugin.getName())
|
|
+ .append("{")
|
|
+ .append(plugin.isEnabled() ? "enabled" : "disabled")
|
|
+ .append(",").append("ver=").append(plugin.getDescription().getVersion());
|
|
+ if (!plugin.isNaggable())
|
|
+ builder.append(",").append("nag");
|
|
+ if (plugin instanceof JavaPlugin)
|
|
+ builder.append(",").append("path=").append(((JavaPlugin) plugin).getFile());
|
|
+
|
|
+ builder.append("}");
|
|
+ out.accept(builder.toString());
|
|
+ }
|
|
+ } else {
|
|
+ out.accept("Suspected Plugins: None");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private static Set<Plugin> getSuspectedPluginsFromStackTrace(StackTraceElement[] stackTrace) {
|
|
+ Map<Plugin, Set<Class<?>>> loadedClasses = loadedClassesSupplier.get();
|
|
+ Set<Plugin> suspectedPlugins = new HashSet<>();
|
|
+ for (StackTraceElement stackTraceElement : stackTrace) {
|
|
+ for (Map.Entry<Plugin, Set<Class<?>>> pluginSetEntry : loadedClasses.entrySet()) {
|
|
+ if (pluginSetEntry.getValue().stream().anyMatch(clazz -> clazz.getName().equals(stackTraceElement.getClassName())))
|
|
+ suspectedPlugins.add(pluginSetEntry.getKey());
|
|
+ }
|
|
+ }
|
|
+ return suspectedPlugins;
|
|
+ }
|
|
+
|
|
+ private static Map<Plugin, Set<Class<?>>> scanForPluginClasses() {
|
|
+ Map<Plugin, Set<Class<?>>> loadedClasses = new Object2ObjectOpenHashMap<>();
|
|
+ if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
|
|
+ final SimplePluginManager pluginManager = (SimplePluginManager) Bukkit.getPluginManager();
|
|
+ final Collection<PluginLoader> pluginLoaders = pluginManager.getPluginLoaders();
|
|
+ for (PluginLoader pluginLoader : pluginLoaders) {
|
|
+ if (pluginLoader instanceof JavaPluginLoader) {
|
|
+ JavaPluginLoader javaPluginLoader = (JavaPluginLoader) pluginLoader;
|
|
+ final List<PluginClassLoader> classLoaders = javaPluginLoader.getClassLoaders();
|
|
+ for (PluginClassLoader classLoader : classLoaders) {
|
|
+ loadedClasses.put(classLoader.getPlugin(), new ObjectOpenHashSet<>(classLoader.getLoadedClasses()));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return loadedClasses;
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
|
index 82b2783497947f336b0dd95db61f31f8f77f446c..d0673f4cea94ce833a08bc3395fe3cc0abb614cb 100644
|
|
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
|
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
|
@@ -57,8 +57,11 @@ public class AnnotationTest {
|
|
"co/aikar/timings/TimingHistory$2$1$2",
|
|
"co/aikar/timings/TimingHistory$3",
|
|
"co/aikar/timings/TimingHistory$4",
|
|
- "co/aikar/timings/TimingHistoryEntry$1"
|
|
+ "co/aikar/timings/TimingHistoryEntry$1",
|
|
// Paper end
|
|
+ // Yatopia start
|
|
+ "org/yatopiamc/yatopia/api/internal/StackTraceUtils"
|
|
+ // Yatopia end
|
|
};
|
|
|
|
@Test
|