Try to determine plugin name on bad plugin command registration

This commit is contained in:
Aikar
2016-04-30 12:53:20 -04:00
parent 81f624837f
commit 3b3f85f88f

View File

@@ -2085,14 +2085,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public static Timing getCommandTiming(String pluginName, Command command) { + public static Timing getCommandTiming(String pluginName, Command command) {
+ Plugin plugin = null; + Plugin plugin = null;
+ final Server server = Bukkit.getServer(); + final Server server = Bukkit.getServer();
+ if (!("minecraft".equals(pluginName) || "bukkit".equals(pluginName) || "Spigot".equals(pluginName) || + if (!( server == null || pluginName == null ||
+ server == null)) { + "minecraft".equals(pluginName) || "bukkit".equals(pluginName) ||
+ "spigot".equalsIgnoreCase(pluginName) || "paper".equals(pluginName)
+ )) {
+ plugin = server.getPluginManager().getPlugin(pluginName); + plugin = server.getPluginManager().getPlugin(pluginName);
+ }
+ if (plugin == null) { + if (plugin == null) {
+ // Plugin is passing custom fallback prefix, try to look up by class loader + // Plugin is passing custom fallback prefix, try to look up by class loader
+ plugin = getPluginByClassloader(command.getClass()); + plugin = getPluginByClassloader(command.getClass());
+ } + }
+ }
+ if (plugin == null) { + if (plugin == null) {
+ return Timings.ofSafe("Command: " + pluginName + ":" + command.getTimingName()); + return Timings.ofSafe("Command: " + pluginName + ":" + command.getTimingName());
+ } + }
@@ -2906,7 +2908,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.commandMap = commandMap; this.commandMap = commandMap;
+ // Paper start - Some plugins do things the wrong way, try and account for that + // Paper start - Some plugins do things the wrong way, try and account for that
+ if (this.timings == null) { + if (this.timings == null) {
+ this.timings = co.aikar.timings.TimingsManager.getCommandTiming("unknown", this); + this.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, this);
+ } + }
+ // Paper end + // Paper end
return true; return true;