Skip to content

Commit

Permalink
Fix teleport command from commandblocks/console.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Mar 2, 2013
1 parent fa1f811 commit 8d9cd97
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -144,15 +144,15 @@ public void teleport(CommandContext args, CommandSender sender) throws CommandEx
if (loc.getZ() == loc.getBlockZ()) loc.add(0, 0, 0.5);
targets = PlayerUtil.matchPlayers(PlayerUtil.checkPlayer(sender));
// check target location (CommandPermissions annotation only checks sender's location)
CommandBook.inst().checkPermission(PlayerUtil.checkPlayer(sender), loc.getWorld(), "commandbook.teleport");
CommandBook.inst().checkPermission(sender, loc.getWorld(), "commandbook.teleport");
} else if (args.argsLength() == 2) {
targets = PlayerUtil.matchPlayers(sender, args.getString(0));
loc = LocationUtil.matchLocation(sender, args.getString(1)); // matches both #4 and #5
if (loc.getX() == loc.getBlockX()) loc.add(0.5, 0, 0);
if (loc.getZ() == loc.getBlockZ()) loc.add(0, 0, 0.5);

// Check permissions!
CommandBook.inst().checkPermission(PlayerUtil.checkPlayer(sender), loc.getWorld(), "commandbook.teleport");
CommandBook.inst().checkPermission(sender, loc.getWorld(), "commandbook.teleport");
for (Player target : targets) {
if (target != sender) { // if any of the targets is not the sender, we need to check .other
CommandBook.inst().checkPermission(sender, "commandbook.teleport.other");
Expand All @@ -172,7 +172,7 @@ public void teleport(CommandContext args, CommandSender sender) throws CommandEx
if (loc.getX() == loc.getBlockX()) loc.add(0.5, 0, 0);
if (loc.getZ() == loc.getBlockZ()) loc.add(0, 0, 0.5);
// check location permission
CommandBook.inst().checkPermission(PlayerUtil.checkPlayer(sender), loc.getWorld(), "commandbook.teleport");
CommandBook.inst().checkPermission(sender, loc.getWorld(), "commandbook.teleport");
} else if (args.argsLength() == 4) {
targets = PlayerUtil.matchPlayers(sender, args.getString(0)); // matches #1
// support relative location (~5 -> current coord + 5)
Expand All @@ -183,7 +183,7 @@ public void teleport(CommandContext args, CommandSender sender) throws CommandEx
if (yArg.startsWith("~")) relative[1] = true;
if (zArg.startsWith("~")) relative[2] = true;
if (relative[0] || relative[1] || relative[2]) {
CommandBook.inst().checkPermission(PlayerUtil.checkPlayer(sender), "commandbook.locations.coords.relative");
CommandBook.inst().checkPermission(sender, "commandbook.locations.coords.relative");
}
int x = Integer.valueOf(xArg.replace("~", ""));
int y = Integer.valueOf(yArg.replace("~", ""));
Expand All @@ -199,7 +199,7 @@ public void teleport(CommandContext args, CommandSender sender) throws CommandEx
}
}
loc = new Location(world, x, y, z);
CommandBook.inst().checkPermission(PlayerUtil.checkPlayer(sender), loc.getWorld(), "commandbook.teleport");
CommandBook.inst().checkPermission(sender, loc.getWorld(), "commandbook.teleport");
for (Player target : targets) {
if (target != sender) { // if any of the targets is not the sender, we need to check .other
CommandBook.inst().checkPermission(sender, "commandbook.teleport.other");
Expand Down

0 comments on commit 8d9cd97

Please sign in to comment.