From 3b3f85f88f3298a774b9762e580830057bc7b4a9 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 30 Apr 2016 12:53:20 -0400 Subject: [PATCH] Try to determine plugin name on bad plugin command registration --- Spigot-API-Patches/Timings-v2.patch | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Spigot-API-Patches/Timings-v2.patch b/Spigot-API-Patches/Timings-v2.patch index c2cdcba433..8adbe1f4e9 100644 --- a/Spigot-API-Patches/Timings-v2.patch +++ b/Spigot-API-Patches/Timings-v2.patch @@ -2085,13 +2085,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static Timing getCommandTiming(String pluginName, Command command) { + Plugin plugin = null; + final Server server = Bukkit.getServer(); -+ if (!("minecraft".equals(pluginName) || "bukkit".equals(pluginName) || "Spigot".equals(pluginName) || -+ server == null)) { ++ if (!( server == null || pluginName == null || ++ "minecraft".equals(pluginName) || "bukkit".equals(pluginName) || ++ "spigot".equalsIgnoreCase(pluginName) || "paper".equals(pluginName) ++ )) { + plugin = server.getPluginManager().getPlugin(pluginName); -+ if (plugin == null) { -+ // Plugin is passing custom fallback prefix, try to look up by class loader -+ plugin = getPluginByClassloader(command.getClass()); -+ } ++ } ++ if (plugin == null) { ++ // Plugin is passing custom fallback prefix, try to look up by class loader ++ plugin = getPluginByClassloader(command.getClass()); + } + if (plugin == null) { + return Timings.ofSafe("Command: " + pluginName + ":" + command.getTimingName()); @@ -2906,7 +2908,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.commandMap = commandMap; + // Paper start - Some plugins do things the wrong way, try and account for that + if (this.timings == null) { -+ this.timings = co.aikar.timings.TimingsManager.getCommandTiming("unknown", this); ++ this.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, this); + } + // Paper end return true;