Case insensitive commands
This commit is contained in:
parent
a2ebb92d56
commit
bd39fad41b
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.api.plugin;
|
package net.md_5.bungee.api.plugin;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -37,6 +38,7 @@ public abstract class Command
|
|||||||
*/
|
*/
|
||||||
public Command(String name, String permission, String... aliases)
|
public Command(String name, String permission, String... aliases)
|
||||||
{
|
{
|
||||||
|
Preconditions.checkArgument(name != null, "name");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
|
@ -41,7 +41,7 @@ public class PluginManager
|
|||||||
*/
|
*/
|
||||||
public void registerCommand(Command command)
|
public void registerCommand(Command command)
|
||||||
{
|
{
|
||||||
commandMap.put(command.getName(), command);
|
commandMap.put(command.getName().toLowerCase(), command);
|
||||||
for (String alias : command.getAliases())
|
for (String alias : command.getAliases())
|
||||||
{
|
{
|
||||||
commandMap.put(alias, command);
|
commandMap.put(alias, command);
|
||||||
@ -69,7 +69,7 @@ public class PluginManager
|
|||||||
public boolean dispatchCommand(CommandSender sender, String commandLine)
|
public boolean dispatchCommand(CommandSender sender, String commandLine)
|
||||||
{
|
{
|
||||||
String[] split = argsSplit.split(commandLine);
|
String[] split = argsSplit.split(commandLine);
|
||||||
Command command = commandMap.get(split[0]);
|
Command command = commandMap.get(split[0].toLowerCase());
|
||||||
if (command == null)
|
if (command == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user