mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-21 14:39:01 +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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public boolean register(String name, String fallbackPrefix, Command command) {
|
public boolean register(String name, String fallbackPrefix, Command command) {
|
||||||
boolean nameInUse = (knownCommands.get(name) != null);
|
boolean nameInUse = (getCommand(name) != null);
|
||||||
if (nameInUse)
|
|
||||||
|
if (nameInUse) {
|
||||||
name = fallbackPrefix + ":" + name;
|
name = fallbackPrefix + ":" + name;
|
||||||
|
}
|
||||||
|
|
||||||
knownCommands.put(name, command);
|
knownCommands.put(name.toLowerCase(), command);
|
||||||
return !nameInUse;
|
return !nameInUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ public final class SimpleCommandMap implements CommandMap {
|
||||||
|
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
|
|
||||||
Command target = knownCommands.get(sentCommandLabel);
|
Command target = getCommand(sentCommandLabel);
|
||||||
boolean isRegisteredCommand = (target != null);
|
boolean isRegisteredCommand = (target != null);
|
||||||
if (isRegisteredCommand) {
|
if (isRegisteredCommand) {
|
||||||
try {
|
try {
|
||||||
|
@ -92,7 +94,7 @@ public final class SimpleCommandMap implements CommandMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command getCommand(String name) {
|
public Command getCommand(String name) {
|
||||||
return knownCommands.get(name);
|
return knownCommands.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class VersionCommand extends Command {
|
private static class VersionCommand extends Command {
|
||||||
|
|
Loading…
Add table
Reference in a new issue