diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 17f2411cda..c285706b15 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -18,6 +18,9 @@ import java.util.logging.Level; import java.util.regex.Matcher; import org.bukkit.Server; import java.util.regex.Pattern; +import org.bukkit.command.Command; +import org.bukkit.command.PluginCommandYamlParser; +import org.bukkit.command.SimpleCommandMap; import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; @@ -35,6 +38,7 @@ public final class SimplePluginManager implements PluginManager { private final Map lookupNames = new HashMap(); private final Map> listeners = new EnumMap>(Event.Type.class); private static File updateDirectory = null; + private final SimpleCommandMap commandMap; private final Comparator comparer = new Comparator() { public int compare(RegisteredListener i, RegisteredListener j) { int result = i.getPriority().compareTo(j.getPriority()); @@ -47,8 +51,9 @@ public final class SimplePluginManager implements PluginManager { } }; - public SimplePluginManager(Server instance) { + public SimplePluginManager(Server instance, SimpleCommandMap commandMap) { server = instance; + this.commandMap = commandMap; } /** @@ -249,6 +254,12 @@ public final class SimplePluginManager implements PluginManager { public void enablePlugin(final Plugin plugin) { if (!plugin.isEnabled()) { + List pluginCommands = PluginCommandYamlParser.parse(plugin); + + if (!pluginCommands.isEmpty()) { + commandMap.registerAll(plugin.getDescription().getName(), pluginCommands); + } + try { plugin.getPluginLoader().enablePlugin(plugin); } catch (Throwable ex) {