Skip to content

Commit

Permalink
Added player @p thingy to add a players name to a command.
Browse files Browse the repository at this point in the history
Signed-off-by: me4502 <mnmiller1@hotmail.com>
  • Loading branch information
me4502 committed Nov 10, 2012
1 parent 2e907c7 commit 968b461
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mechanisms/src/main/java/com/sk89q/craftbook/mech/Command.java
Expand Up @@ -105,7 +105,10 @@ public void onRightClick(PlayerInteractEvent event) {

Sign s = (Sign) event.getClickedBlock().getState();

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), s.getLine(2).replace("/", "") + s.getLine(3));
String command = s.getLine(2).replace("/", "") + s.getLine(3);
command = command.replace("@p", event.getPlayer().getName());

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);

event.setCancelled(true);
}
Expand All @@ -119,7 +122,11 @@ public void onBlockRedstoneChange(SourcedBlockRedstoneEvent event) {

Sign s = (Sign) event.getBlock().getState();

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), s.getLine(2).replace("/", "") + s.getLine(3));
String command = s.getLine(2).replace("/", "") + s.getLine(3);
if(command.contains("@p"))
return; //We don't work with player commands.

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}

@Override
Expand Down

0 comments on commit 968b461

Please sign in to comment.