mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-26 11:07:55 +01:00
Allow kicking of hidden players
This commit is contained in:
parent
bdef1780ac
commit
ae7c64619c
@ -24,23 +24,29 @@ public class Commandkick extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final User user = getPlayer(server, args, 0);
|
||||
if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
throw new Exception(_("kickExempt"));
|
||||
final User target = getPlayer(server, args, 0, true);
|
||||
if (sender instanceof Player) {
|
||||
User user = ess.getUser(sender);
|
||||
if (target.isHidden() && !user.isAuthorized("essentials.list.hidden")) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
if (target.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
throw new Exception(_("kickExempt"));
|
||||
}
|
||||
}
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
|
||||
user.kickPlayer(kickReason);
|
||||
target.kickPlayer(kickReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
server.getLogger().log(Level.INFO, _("playerKicked", senderName, user.getName(), kickReason));
|
||||
server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason));
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason));
|
||||
onlinePlayer.sendMessage(_("playerKicked", senderName, target.getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
}
|
||||
if (args[pos].isEmpty())
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
final User user = ess.getUser(args[pos]);
|
||||
if (user != null)
|
||||
{
|
||||
if (!getOffline && (!user.isOnline() || user.isHidden()))
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
return user;
|
||||
}
|
||||
@ -85,7 +85,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
return userMatch;
|
||||
}
|
||||
}
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
|
||||
public class PlayerNotFoundException extends NoSuchFieldException
|
||||
{
|
||||
public PlayerNotFoundException()
|
||||
{
|
||||
super(_("playerNotFound"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user