mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
Case-insensitive commands
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
2a6a5d5dc5
commit
dbfb262c5d
1 changed files with 7 additions and 5 deletions
|
@ -53,11 +53,13 @@ public final class SimpleCommandMap implements CommandMap {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean register(String name, String fallbackPrefix, Command command) {
|
||||
boolean nameInUse = (knownCommands.get(name) != null);
|
||||
if (nameInUse)
|
||||
boolean nameInUse = (getCommand(name) != null);
|
||||
|
||||
if (nameInUse) {
|
||||
name = fallbackPrefix + ":" + name;
|
||||
}
|
||||
|
||||
knownCommands.put(name, command);
|
||||
knownCommands.put(name.toLowerCase(), command);
|
||||
return !nameInUse;
|
||||
}
|
||||
|
||||
|
@ -70,7 +72,7 @@ public final class SimpleCommandMap implements CommandMap {
|
|||
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
Command target = knownCommands.get(sentCommandLabel);
|
||||
Command target = getCommand(sentCommandLabel);
|
||||
boolean isRegisteredCommand = (target != null);
|
||||
if (isRegisteredCommand) {
|
||||
try {
|
||||
|
@ -92,7 +94,7 @@ public final class SimpleCommandMap implements CommandMap {
|
|||
}
|
||||
|
||||
public Command getCommand(String name) {
|
||||
return knownCommands.get(name);
|
||||
return knownCommands.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
private static class VersionCommand extends Command {
|
||||
|
|
Loading…
Reference in a new issue