From ea9bf854cc1430ab97881ff2c62366a80c459b92 Mon Sep 17 00:00:00 2001 From: Necrodoom Date: Tue, 19 Mar 2013 14:52:45 +0200 Subject: [PATCH] [Fix] offline player matching for online only commands. /kick,/warp, /burn & /tppos should only match online players --- .../earth2me/essentials/commands/Commandburn.java | 9 ++++----- .../earth2me/essentials/commands/Commandkick.java | 3 ++- .../earth2me/essentials/commands/Commandtppos.java | 4 ++-- .../earth2me/essentials/commands/Commandwarp.java | 14 +++----------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java index 1a734ebd2..8c98188f7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java @@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.earth2me.essentials.User; public class Commandburn extends EssentialsCommand @@ -27,10 +28,8 @@ public class Commandburn extends EssentialsCommand throw new NotEnoughArgumentsException("You need to specify a player to burn."); } - for (Player p : server.matchPlayer(args[0])) - { - p.setFireTicks(Integer.parseInt(args[1]) * 20); - sender.sendMessage(_("burnMsg", p.getDisplayName(), Integer.parseInt(args[1]))); - } + User user = getPlayer(server, args, 0); + user.setFireTicks(Integer.parseInt(args[1]) * 20); + sender.sendMessage(_("burnMsg", user.getDisplayName(), Integer.parseInt(args[1]))); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index 206127b58..792ed4906 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -25,7 +25,7 @@ public class Commandkick extends EssentialsCommand throw new NotEnoughArgumentsException(); } - final User target = getPlayer(server, args, 0, true); + final User target = getPlayer(server, args, 0); if (sender instanceof Player) { User user = ess.getUser(sender); @@ -33,6 +33,7 @@ public class Commandkick extends EssentialsCommand { throw new PlayerNotFoundException(); } + if (target.isAuthorized("essentials.kick.exempt")) { throw new Exception(_("kickExempt")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java index 6f7789208..16e5c3fcf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java @@ -55,7 +55,7 @@ public class Commandtppos extends EssentialsCommand throw new NotEnoughArgumentsException(); } - User user = ess.getUser(server.getPlayer(args[0])); + User user = getPlayer(server, args, 0); final double x = args[1].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]); final double y = args[2].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]); final double z = args[3].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]); @@ -77,4 +77,4 @@ public class Commandtppos extends EssentialsCommand user.getTeleport().teleport(location, null, TeleportCause.COMMAND); } -} \ No newline at end of file +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 9755d451d..9e22ce9d5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -41,11 +41,7 @@ public class Commandwarp extends EssentialsCommand User otherUser = null; if (args.length == 2 && (user.isAuthorized("essentials.warp.otherplayers") || user.isAuthorized("essentials.warp.others"))) { - otherUser = ess.getUser(server.getPlayer(args[1])); - if (otherUser == null) - { - throw new Exception(_("playerNotFound")); - } + otherUser = getPlayer(server, args, 1); warpUser(user, otherUser, args[0]); throw new NoChargeException(); } @@ -62,11 +58,7 @@ public class Commandwarp extends EssentialsCommand warpList(sender, args); throw new NoChargeException(); } - User otherUser = ess.getUser(server.getPlayer(args[1])); - if (otherUser == null) - { - throw new Exception(_("playerNotFound")); - } + User otherUser = getPlayer(server, args, 1); otherUser.getTeleport().warp(args[0], null, TeleportCause.COMMAND); throw new NoChargeException(); @@ -127,4 +119,4 @@ public class Commandwarp extends EssentialsCommand } user.getTeleport().warp(name, charge, TeleportCause.COMMAND); } -} \ No newline at end of file +}