Skip to content

Commit

Permalink
chore: add debugging for command registration
Browse files Browse the repository at this point in the history
Signed-off-by: Thatsmusic99 <25277367+thatsmusic99@users.noreply.github.com>
  • Loading branch information
Thatsmusic99 committed Jul 25, 2023
1 parent 6d00c7c commit a62ebf1
Showing 1 changed file with 10 additions and 5 deletions.
Expand Up @@ -86,13 +86,12 @@ public static void registerCommands() {

private static void register(String name, ATCommand atCommand) {
PluginCommand command = Bukkit.getPluginCommand("advancedteleport:" + name);
CoreClass.debug("Fetching " + command + " - " + command);
if (command == null) command = atCommands.get(name);
if (command == null) return;

if (command.getPlugin() != CoreClass.getInstance()) {
command = Bukkit.getPluginCommand("advancedteleport:" + name);
if (command == null) {
CoreClass.getInstance().getLogger().warning("Could not add command " + name + " - has it been set up properly?");
return;
}
if (command == null) return;

atCommands.put(name, command);
CommandMap map = getMap();
Expand All @@ -108,6 +107,7 @@ private static void register(String name, ATCommand atCommand) {
if (MainConfig.get().DISABLED_COMMANDS.get().contains(alias)
|| removed
|| !atCommand.getRequiredFeature()) {
CoreClass.debug(alias + " has been marked for removal.");
if (command.isRegistered()) {
removed = true;
command.unregister(map);
Expand All @@ -120,6 +120,8 @@ private static void register(String name, ATCommand atCommand) {
commands.remove(alias);
commands.remove("advancedteleport:" + alias);

CoreClass.debug("Removed " + alias + ".");

// Let another plugin take over
Bukkit.getScheduler()
.runTaskLater(
Expand All @@ -135,6 +137,7 @@ private static void register(String name, ATCommand atCommand) {
if (parts.length < 2) continue;
if (parts[1].equals(alias)) {
if (parts[0].equals("advancedteleport")) continue;
CoreClass.debug("Letting " + parts[0] + "'s " + alias + " take over...");
pendingChanges.put(alias, commands.get(otherCmd));
break;
}
Expand Down Expand Up @@ -163,6 +166,8 @@ private static void register(String name, ATCommand atCommand) {
command.setTabCompleter(atCommand);
}

CoreClass.debug(aliases + " has " + (command.isRegistered() ? "" : "not ") + "been registed successfully.");

registeredCommands.put(name, command);
}

Expand Down

0 comments on commit a62ebf1

Please sign in to comment.