2013-02-06 19:35:14 +01:00
|
|
|
package com.ne0nx3r0.betteralias.alias;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class Alias
|
|
|
|
{
|
|
|
|
private final String command;
|
|
|
|
private final String permission;
|
|
|
|
private final HashMap<Integer, List<AliasCommand>> parameters;
|
|
|
|
|
|
|
|
public Alias(String commandName)
|
|
|
|
{
|
|
|
|
this.command = commandName;
|
|
|
|
this.permission = null;
|
|
|
|
|
|
|
|
this.parameters = new HashMap<Integer,List<AliasCommand>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Alias(String commandName,String permissionNode)
|
|
|
|
{
|
|
|
|
this.command = commandName;
|
|
|
|
this.permission = permissionNode;
|
|
|
|
|
|
|
|
this.parameters = new HashMap<Integer,List<AliasCommand>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasCommandFor(int length)
|
|
|
|
{
|
2013-02-26 17:57:56 +01:00
|
|
|
return this.parameters.containsKey(length) || this.parameters.containsKey(-1);
|
2013-02-06 19:35:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getPermissionNode()
|
|
|
|
{
|
|
|
|
return this.permission;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasPermission()
|
|
|
|
{
|
|
|
|
return this.permission != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Iterable<AliasCommand> getCommands(int length)
|
|
|
|
{
|
2013-02-26 17:57:56 +01:00
|
|
|
List<AliasCommand> commands = this.parameters.get(length);
|
|
|
|
|
|
|
|
if(commands != null)
|
|
|
|
{
|
|
|
|
return commands;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.parameters.get(-1);
|
2013-02-06 19:35:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setCommandsFor(int length,List<AliasCommand> commandsList)
|
|
|
|
{
|
|
|
|
this.parameters.put(length, commandsList);
|
|
|
|
}
|
|
|
|
}
|