From bde91b77844f440d7d528831b4b3e7d940e15650 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Thu, 3 Jan 2019 16:40:51 +0100 Subject: [PATCH] Fixed commands being registered with their main label as fallbackPrefix This has been replaced by "bentobox" or the addon's name. --- .../bentobox/bentobox/managers/CommandsManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/managers/CommandsManager.java b/src/main/java/world/bentobox/bentobox/managers/CommandsManager.java index 4ecfb643e..02a90f45a 100644 --- a/src/main/java/world/bentobox/bentobox/managers/CommandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/CommandsManager.java @@ -2,6 +2,7 @@ package world.bentobox.bentobox.managers; import java.lang.reflect.Field; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -21,7 +22,13 @@ public class CommandsManager { Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap"); commandMapField.setAccessible(true); CommandMap commandMap = (CommandMap) commandMapField.get(Bukkit.getServer()); - commandMap.register(command.getLabel(), command); + + String commandPrefix = "bentobox"; + if (command.getAddon() != null) { + commandPrefix = command.getAddon().getDescription().getName().toLowerCase(Locale.ENGLISH); + } + + commandMap.register(commandPrefix, command); } catch(Exception exception){ Bukkit.getLogger().severe("Bukkit server commandMap method is not there! This means no commands can be registered!");