From aecd84681489085c644b9b6d70e7961dcc9eb0fa Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 9 Feb 2014 12:27:08 -0500 Subject: [PATCH] [Bleeding] Fix getCommand for conflicting plugin commands. By: t00thpick1 --- .../src/main/java/org/bukkit/command/SimpleCommandMap.java | 4 ++-- .../src/main/java/org/bukkit/plugin/java/JavaPlugin.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java index a0dd292f04..3f651de317 100644 --- a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -3,7 +3,6 @@ package org.bukkit.command; import static org.bukkit.util.Java15Compat.Arrays_copyOfRange; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -101,7 +100,8 @@ public class SimpleCommandMap implements CommandMap { * {@inheritDoc} */ public boolean register(String label, String fallbackPrefix, Command command) { - label = label.toLowerCase(); + label = label.toLowerCase().trim(); + fallbackPrefix = fallbackPrefix.toLowerCase().trim(); boolean registered = register(label, command, false); knownCommands.put(fallbackPrefix + ":" + label, command); diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index d1c3321c77..a0b609fab0 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -351,11 +351,11 @@ public abstract class JavaPlugin extends PluginBase { String alias = name.toLowerCase(); PluginCommand command = getServer().getPluginCommand(alias); - if ((command != null) && (command.getPlugin() != this)) { + if (command == null || command.getPlugin() != this) { command = getServer().getPluginCommand(description.getName().toLowerCase() + ":" + alias); } - if ((command != null) && (command.getPlugin() == this)) { + if (command != null && command.getPlugin() == this) { return command; } else { return null;