Finishing up for release

This commit is contained in:
Ne0n x3r0 2013-02-06 18:52:38 -06:00
parent d4ae745e59
commit 1f87b909c5
3 changed files with 43 additions and 17 deletions

View File

@ -3,11 +3,11 @@ banhammer:
1: /ban !1 1: /ban !1
#name parameter is replaced with the command users name #name parameter is replaced with the command users name
gmon: gmon:
0: /gamemode !name 1 0: /gamemode creative !name
1: /gamemode !1 1 1: /gamemode creative !1
gmoff: gmoff:
0: /gamemode !name 0 0: /gamemode survival !name
1: /gamemode !1 0 1: /gamemode survival !1
# putting a P after the parameter specifies this is a player, and BA should try to guess which player # putting a P after the parameter specifies this is a player, and BA should try to guess which player
# useful for things like "/to e0n" instead of "/to Ne0nx3r0" # useful for things like "/to e0n" instead of "/to Ne0nx3r0"
# This will ONLY look for players that are online # This will ONLY look for players that are online

View File

@ -57,9 +57,9 @@ public class AliasManager
{ {
Alias alias; Alias alias;
if(yml.isString(sAlias+".permission")) if(yml.getString(sAlias+".permission") != null)
{ {
alias = new Alias(sAlias,yml.getString("permission")); alias = new Alias(sAlias,yml.getString(sAlias+".permission"));
} }
else else
{ {
@ -170,7 +170,7 @@ public class AliasManager
while(m.find()) while(m.find())
{ {
String text = m.group(0).substring(1); String text = m.group(0).substring(1);
if(text.equalsIgnoreCase("name")) if(text.equalsIgnoreCase("name"))
{ {
if(player != null) if(player != null)
@ -179,7 +179,11 @@ public class AliasManager
} }
else else
{ {
cs.sendMessage(ChatColor.RED+"[BA] A parameter of this alias requires a player."); cs.sendMessage("[BetterAlias] "+ChatColor.RED+"A parameter of this alias requires a player.");
cs.sendMessage("[BetterAlias] Line: "+ac.command);
return true;
} }
} }
else if(text.equalsIgnoreCase("handItemName")) else if(text.equalsIgnoreCase("handItemName"))
@ -190,7 +194,11 @@ public class AliasManager
} }
else else
{ {
cs.sendMessage(ChatColor.RED+"[BA] A parameter of this alias requires a player."); cs.sendMessage("[BetterAlias] "+ChatColor.RED+"A parameter of this alias requires a player.");
cs.sendMessage("[BetterAlias] Line: "+ac.command);
return true;
} }
} }
else if(text.equalsIgnoreCase("handItemID")) else if(text.equalsIgnoreCase("handItemID"))
@ -201,7 +209,11 @@ public class AliasManager
} }
else else
{ {
cs.sendMessage(ChatColor.RED+"[BA] A parameter of this alias requires a player."); cs.sendMessage("[BetterAlias] "+ChatColor.RED+"A parameter of this alias requires a player.");
cs.sendMessage("[BetterAlias] Line: "+ac.command);
return true;
} }
} }
else if(text.length() >= 2 && text.substring(1,2).equalsIgnoreCase("p")) else if(text.length() >= 2 && text.substring(1,2).equalsIgnoreCase("p"))
@ -266,14 +278,14 @@ public class AliasManager
{ {
if(player != null) if(player != null)
{ {
plugin.getLogger().log(Level.INFO,"[BA] Running console command for "+player.getName()+": "+sNewCommand); plugin.getLogger().log(Level.INFO,"[BetterAlias] "+ChatColor.AQUA+"Running console command for "+player.getName()+": "+sNewCommand);
} }
else else
{ {
cs.sendMessage(ChatColor.AQUA+"[BA] Running: "+sNewCommand); cs.sendMessage("[BetterAlias] "+ChatColor.AQUA+"Running: "+sNewCommand);
} }
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), sNewCommand); plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), sNewCommand.substring(1));
} }
else else
{ {

View File

@ -23,24 +23,38 @@ public class BetterAliasCommandListener implements Listener
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e)
{ {
String sCommand = e.getMessage().substring(0,e.getMessage().indexOf(" ")); String sCommand = null;
String sArgs = "";
if(e.getMessage().contains(" "))
{
sCommand = e.getMessage().substring(1,e.getMessage().indexOf(" "));
sArgs = e.getMessage().substring(e.getMessage().indexOf(" ")+1);
}
else
{
sCommand = e.getMessage().substring(1);
}
Alias alias = plugin.aliasManager.getAlias(sCommand); Alias alias = plugin.aliasManager.getAlias(sCommand);
if(alias != null) if(alias != null)
{ {
Player player = e.getPlayer(); Player player = e.getPlayer();
if(alias.hasPermission() if(alias.hasPermission()
&& !player.hasPermission("betteralias."+alias.getPermissionNode())) && !player.hasPermission("betteralias."+alias.getPermissionNode()))
{ {
player.sendMessage(ChatColor.RED+"You do not have permission to use this command."); player.sendMessage(ChatColor.RED+"You do not have permission to use this alias.");
e.setCancelled(true);
} }
else else
{ {
if(plugin.aliasManager.sendAliasCommands( if(plugin.aliasManager.sendAliasCommands(
alias, alias,
(CommandSender) e.getPlayer(), (CommandSender) e.getPlayer(),
e.getMessage().substring(e.getMessage().indexOf(" ")+1))) sArgs));
{ {
e.setCancelled(true); e.setCancelled(true);
} }