From 518b013a63a23f9bdb587355aa34442cf2327a25 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 20 Mar 2012 13:26:49 +0000 Subject: [PATCH] Teleport check cleanup --- .../com/earth2me/essentials/ISettings.java | 2 +- .../src/com/earth2me/essentials/Settings.java | 2 +- .../src/com/earth2me/essentials/User.java | 2 +- .../essentials/commands/Commandtp.java | 4 ++-- .../essentials/commands/Commandtpa.java | 2 +- .../essentials/commands/Commandtpaccept.java | 22 +++++++++---------- .../essentials/commands/Commandtpo.java | 2 +- .../essentials/commands/Commandworld.java | 2 +- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index c5773404e..fe12720ea 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -154,7 +154,7 @@ public interface ISettings extends IConf boolean getRepairEnchanted(); - boolean getIsWorldTeleportPermissions(); + boolean isWorldTeleportPermissions(); boolean registerBackInListener(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 6db8dcafc..f094dda6e 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -678,7 +678,7 @@ public class Settings implements ISettings } @Override - public boolean getIsWorldTeleportPermissions() + public boolean isWorldTeleportPermissions() { return config.getBoolean("world-teleport-permissions", false); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index b9f5198dc..3d5cbb398 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -250,7 +250,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser return teleportRequester; } - public boolean isTeleportRequestHere() + public boolean isTpRequestHere() { return teleportRequestHere; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java index 05451fdcf..22d4778d3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -30,7 +30,7 @@ public class Commandtp extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - if (user.getWorld() != player.getWorld() && ess.getSettings().getIsWorldTeleportPermissions() + if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + player.getWorld().getName())) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); @@ -49,7 +49,7 @@ public class Commandtp extends EssentialsCommand user.sendMessage(_("teleporting")); final User target = getPlayer(server, args, 0); final User toPlayer = getPlayer(server, args, 1); - if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().getIsWorldTeleportPermissions() + if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName())) { throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName())); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java index 90e8e69d9..95cbc58cd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java @@ -25,7 +25,7 @@ public class Commandtpa extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - if (user.getWorld() != player.getWorld() && ess.getSettings().getIsWorldTeleportPermissions() + if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + player.getWorld().getName())) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 449ae7489..ffc8f2fdd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -19,16 +19,14 @@ public class Commandtpaccept extends EssentialsCommand { final User target = user.getTeleportRequest(); - if (target == null - || !target.isOnline() - || (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")) - || (!user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpa") && !target.isAuthorized("essentials.tpaall")) - ) - { - throw new Exception(_("noPendingRequest")); - } - - if (args.length > 0 && !target.getName().contains(args[0])) + + if (target == null || !target.isOnline() + || (args.length > 0 && !target.getName().contains(args[0])) + || (user.isTpRequestHere() && !target.isAuthorized("essentials.tpahere")) + || (!user.isTpRequestHere() && ((!target.isAuthorized("essentials.tpa") && !target.isAuthorized("essentials.tpaall")) + || (user.getWorld() != target.getWorld() + && ess.getSettings().isWorldTeleportPermissions() + && !user.isAuthorized("essentials.world." + target.getWorld().getName()))))) { throw new Exception(_("noPendingRequest")); } @@ -41,7 +39,7 @@ public class Commandtpaccept extends EssentialsCommand } final Trade charge = new Trade(this.getName(), ess); - if (user.isTeleportRequestHere()) + if (user.isTpRequestHere()) { charge.isAffordableFor(user); } @@ -52,7 +50,7 @@ public class Commandtpaccept extends EssentialsCommand user.sendMessage(_("requestAccepted")); target.sendMessage(_("requestAcceptedFrom", user.getDisplayName())); - if (user.isTeleportRequestHere()) + if (user.isTpRequestHere()) { user.getTeleport().teleport(target, charge, TeleportCause.COMMAND); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java index 5edbe274d..e30aee127 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java @@ -32,7 +32,7 @@ public class Commandtpo extends EssentialsCommand // Verify permission if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden")) { - if (user.getWorld() != player.getWorld() && ess.getSettings().getIsWorldTeleportPermissions() + if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + player.getWorld().getName())) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index c160e0a7a..647115d66 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -54,7 +54,7 @@ public class Commandworld extends EssentialsCommand } } - if (ess.getSettings().getIsWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + world.getName())) + if (ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + world.getName())) { throw new Exception(_("noPerm", "essentials.world." + world.getName())); }