Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the inability to override commands #2196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yexeed
Copy link
Contributor

@Yexeed Yexeed commented Aug 29, 2024

Currently, it is impossible to unregister a command using this method:

public static boolean unregisterCommand(Command command){
    command.setLabel(command.getName() + "__unregistered");
    return command.unregister(Server.getInstance().getCommandMap());
}

command.unregister() returns false because Command.allowChangesFrom() returns false. As old code shows, a commandMap passed as parameter should NOT be null (which is passes fine), and it should NOT be equal to command's known command map (this.commandMap), this sounds as complete nonsense because command SHOULD allow changes from a commandMap that is equal to this.commandMap and vice-versa. (Vanilla commands are all registered using same SimpleCommandMap instance so it should always return true when comparing this.commandMap to Server.getInstance().getCommandMap(), right?

P.S.
Also, this should prove my point.

@Yexeed Yexeed changed the title Fix the inability to override a commands Fix the inability to override commands Aug 29, 2024
@@ -211,7 +211,7 @@ public boolean unregister(CommandMap commandMap) {
}

public boolean allowChangesFrom(CommandMap commandMap) {
return commandMap != null && !commandMap.equals(this.commandMap);
return this.commandMap == null || this.commandMap.equals(commandMap);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to allow changes with null commandMap? Also, was it tested how this affects other methods using allowChangesFrom?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants