re-adding support for !*

This commit is contained in:
Ne0n x3r0 2013-02-26 10:57:56 -06:00
parent 8c0b3ae954
commit 03186b6056
3 changed files with 61 additions and 41 deletions

View File

@ -27,7 +27,7 @@ public class Alias
public boolean hasCommandFor(int length)
{
return this.parameters.containsKey(length);
return this.parameters.containsKey(length) || this.parameters.containsKey(-1);
}
public String getPermissionNode()
@ -42,7 +42,14 @@ public class Alias
Iterable<AliasCommand> getCommands(int length)
{
return this.parameters.get(length);
List<AliasCommand> commands = this.parameters.get(length);
if(commands != null)
{
return commands;
}
return this.parameters.get(-1);
}
void setCommandsFor(int length,List<AliasCommand> commandsList)

View File

@ -72,48 +72,57 @@ public class AliasManager
if(!sArg.equalsIgnoreCase("permission"))
{
int iArg = Integer.parseInt(sArg);
int iArg;
List<String> sArgLines = new ArrayList<String>();
if(yml.isList(sAlias+"."+sArg))
{
sArgLines = yml.getStringList(sAlias+"."+sArg);
}
else
{
sArgLines.add(yml.getString(sAlias+"."+sArg));
}
for(String sArgLine : sArgLines)
{
AliasCommandTypes type = AliasCommandTypes.PLAYER;
if(sArgLine.contains(" "))
if(sArg.equals("*"))
{
String sType = sArgLine.substring(0,sArgLine.indexOf(" "));
if(sType.equalsIgnoreCase("console"))
{
type = AliasCommandTypes.CONSOLE;
sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1);
}
else if(sType.equalsIgnoreCase("reply"))
{
type = AliasCommandTypes.REPLY_MESSAGE;
sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1);
}
iArg = -1;
}
else
{
iArg = Integer.parseInt(sArg);
}
sArgLine = this.replaceColorCodes(sArgLine);
List<String> sArgLines = new ArrayList<String>();
commandsList.add(new AliasCommand(sArgLine,type));
if(yml.isList(sAlias+"."+sArg))
{
sArgLines = yml.getStringList(sAlias+"."+sArg);
}
else
{
sArgLines.add(yml.getString(sAlias+"."+sArg));
}
for(String sArgLine : sArgLines)
{
AliasCommandTypes type = AliasCommandTypes.PLAYER;
if(sArgLine.contains(" "))
{
String sType = sArgLine.substring(0,sArgLine.indexOf(" "));
if(sType.equalsIgnoreCase("console"))
{
type = AliasCommandTypes.CONSOLE;
sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1);
}
else if(sType.equalsIgnoreCase("reply"))
{
type = AliasCommandTypes.REPLY_MESSAGE;
sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1);
}
}
sArgLine = this.replaceColorCodes(sArgLine);
commandsList.add(new AliasCommand(sArgLine,type));
}
alias.setCommandsFor(iArg,commandsList);
}
alias.setCommandsFor(iArg,commandsList);
}
}
this.aliases.put(sAlias, alias);
@ -220,6 +229,10 @@ public class AliasManager
return true;
}
}
else if(text.equalsIgnoreCase("*"))
{
text = commandString;
}
else if(text.length() >= 2 && text.substring(1,2).equalsIgnoreCase("p"))
{
int iParam = -1;

View File

@ -1,6 +1,6 @@
name: BetterAlias
main: com.ne0nx3r0.betteralias.BetterAlias
version: '1.0.1'
version: '1.1.0'
database: false
description: Command alias system
commands: