add player_as_op prefix

This commit is contained in:
plachta3 2015-02-08 15:08:01 +01:00
parent 6c6ebafb90
commit 20ac6bdaed
4 changed files with 57 additions and 18 deletions

View File

@ -1,13 +1,19 @@
#'dumb' parameter, will just use what you put in # 'dumb' parameter, will just use what you put in
banhammer: banhammer:
1: /ban !1 1: /ban !1
#name parameter is replaced with the command users name
gmon: # name parameter is replaced with the command users name
gmon:
0: /gamemode creative !name 0: /gamemode creative !name
1: /gamemode creative !1 1: /gamemode creative !1
gmoff: gmoff:
0: /gamemode survival !name 0: /gamemode survival !name
1: /gamemode survival !1 1: /gamemode survival !1
# call command which needs permission with default player
day:
0: player_as_op /time set 0
# 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
@ -16,17 +22,18 @@ to:
2: /tp !1p !2p 2: /tp !1p !2p
bring: bring:
1: /tp !1p !name 1: /tp !1p !name
# multiple command example # multiple command example
# note spaces in an alias go within quotes # note spaces in an alias go within quotes
"tp then kick": "tp then kick":
1: 1:
- /tp !1p !name - /tp !1p !name
- /kick !1p - /kick !1p
# replaced with the item name in the player's hand # replaced with the item name in the player's hand
hand: hand:
0: I have a !handItemName in my hand right now! 0: I have a !handItemName in my hand right now!
# replace with the item ID in the player's hand # replace with the item ID in the player's hand
handid: handid:
0: /give !name !handItemID 0: /give !name !handItemID
@ -38,7 +45,7 @@ gm:
# Send everything with a command # Send everything with a command
sendAll: sendAll:
"*": /say !* "*": /say !*
# Send everything with a command, but only on certain parameter lengths # Send everything with a command, but only on certain parameter lengths
sendAll: sendAll:
3: /say !* 3: /say !*
@ -53,7 +60,7 @@ sendAll:
# (Also shows how to use the reply modifier to only reply to the player) # (Also shows how to use the reply modifier to only reply to the player)
redText: redText:
0: reply Look at my &REDcolored &DARK_GREENtext! 0: reply Look at my &REDcolored &DARK_GREENtext!
# User must have betteralias.staff permission or be the console. # User must have betteralias.staff permission or be the console.
staff: staff:
permission: staff permission: staff
@ -61,22 +68,22 @@ staff:
- /seen Ne0nx3r0 - /seen Ne0nx3r0
- /seen someOtherStaffMember - /seen someOtherStaffMember
- /seen someThirdStaffMember - /seen someThirdStaffMember
# Console example # Console example
# If this seems dangerous, that's because it is! # If this seems dangerous, that's because it is!
# #
makeOp: makeOp:
# Required permission will be betteralias.your.node # Required permission will be betteralias.your.node
permission: your.node permission: your.node
# Must be makeOp, not Makeup, makeop, etc. # Must be makeOp, not Makeup, makeop, etc.
caseSensitive: true caseSensitive: true
# Quotes are required because 0 uses a colon (:) # Quotes are required because 0 uses a colon (:)
0: "reply Usage: /makeOp <username>" 0: "reply Usage: /makeOp <username>"
1: 1:
- console /say !1 has been opped! - console /say !1 has been opped!
- console /op !1 - console /op !1
- /me has opped !1 - /me has opped !1
# Wait example # Wait example
wait: wait:
# Quotes are required because 0 uses a colon (:) # Quotes are required because 0 uses a colon (:)

View File

@ -3,6 +3,7 @@ package com.ne0nx3r0.betteralias.alias;
public enum AliasCommandTypes public enum AliasCommandTypes
{ {
PLAYER, PLAYER,
PLAYER_AS_OP,
CONSOLE, CONSOLE,
REPLY_MESSAGE, REPLY_MESSAGE,
WAIT, WAIT,

View File

@ -107,6 +107,12 @@ public class AliasManager
sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1); sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1);
} }
else if(sType.equalsIgnoreCase("player_as_op"))
{
type = AliasCommandTypes.PLAYER_AS_OP;
sArgLine = sArgLine.substring(sArgLine.indexOf(" ")+1);
}
else if(sType.equalsIgnoreCase("reply")) else if(sType.equalsIgnoreCase("reply"))
{ {
type = AliasCommandTypes.REPLY_MESSAGE; type = AliasCommandTypes.REPLY_MESSAGE;
@ -342,7 +348,6 @@ public class AliasManager
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable()
{ {
@Override
public void run() public void run()
{ {
csWait.sendMessage(message); csWait.sendMessage(message);
@ -375,6 +380,35 @@ public class AliasManager
"[BetterAlias] "+ChatColor.AQUA+"Running: "+sNewCommand), ac.waitTime); "[BetterAlias] "+ChatColor.AQUA+"Running: "+sNewCommand), ac.waitTime);
} }
} }
else if(ac.type.equals(AliasCommandTypes.PLAYER_AS_OP) && player != null)
{
AliasManager.plugin.getLogger().log(
Level.INFO,
"[BetterAlias] {0}Running player_as_op command for {1}: {2}",
new Object[] { ChatColor.AQUA, player.getName(), sNewCommand }
);
if(player.isOp() == false)
{
try
{
player.setOp(true);
AliasManager.plugin.getServer().dispatchCommand(player, sNewCommand.substring(1));
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
player.setOp(false);
}
}
else
{
AliasManager.plugin.getServer().dispatchCommand(player, sNewCommand.substring(1));
}
}
else if(ac.type.equals(AliasCommandTypes.CONSOLE) else if(ac.type.equals(AliasCommandTypes.CONSOLE)
|| player == null) || player == null)
{ {
@ -428,7 +462,7 @@ public class AliasManager
return null; return null;
} }
// Delayed tasks // Delayed tasks
private static class waitConsoleCommand implements Runnable private static class waitConsoleCommand implements Runnable
{ {
private final String message; private final String message;
@ -440,7 +474,6 @@ public class AliasManager
this.command = command; this.command = command;
} }
@Override
public void run() public void run()
{ {
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command); plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command);
@ -458,7 +491,6 @@ public class AliasManager
this.command = command; this.command = command;
} }
@Override
public void run() public void run()
{ {
Player p = plugin.getServer().getPlayer(playerName); Player p = plugin.getServer().getPlayer(playerName);

View File

@ -15,7 +15,6 @@ public class BetterAliasCommandExecutor implements CommandExecutor
this.plugin = plugin; this.plugin = plugin;
} }
@Override
public boolean onCommand(CommandSender cs, Command cmnd, String alias, String[] args) public boolean onCommand(CommandSender cs, Command cmnd, String alias, String[] args)
{ {
// To allow nulling server commands out // To allow nulling server commands out