3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Add method to remove sub commands from command handler (#3941)

Dieser Commit ist enthalten in:
EnZaXD 2024-06-15 20:51:24 +02:00 committet von GitHub
Ursprung 9a9ca9676d
Commit ec976dfb6c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 12 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -34,6 +34,13 @@ public interface ViaVersionCommand {
*/ */
void registerSubCommand(ViaSubCommand command); void registerSubCommand(ViaSubCommand command);
/**
* Removes a subcommand by name, can be used to unload default subcommands which are not supported
* on the platform.
* @param name Subcommand name
*/
void removeSubCommand(String name);
/** /**
* Check if a subcommand is registered. * Check if a subcommand is registered.
* *

Datei anzeigen

@ -57,6 +57,11 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
commandMap.put(command.name().toLowerCase(Locale.ROOT), command); commandMap.put(command.name().toLowerCase(Locale.ROOT), command);
} }
@Override
public void removeSubCommand(final String name) {
commandMap.remove(name.toLowerCase(Locale.ROOT));
}
@Override @Override
public boolean hasSubCommand(String name) { public boolean hasSubCommand(String name) {
return commandMap.containsKey(name.toLowerCase(Locale.ROOT)); return commandMap.containsKey(name.toLowerCase(Locale.ROOT));