[Fix] offline player matching for online only commands.

/kick,/warp, /burn & /tppos should only match online players
This commit is contained in:
Necrodoom 2013-03-19 14:52:45 +02:00 committed by KHobbits
parent f5c17fc7c7
commit ea9bf854cc
4 changed files with 11 additions and 19 deletions

View File

@ -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])));
}
}

View File

@ -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"));

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}