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,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;