Players should not be able to ignore Console

Also implement chat exempt permission in other commands.
This commit is contained in:
KHobbits 2012-06-16 16:22:51 +01:00
parent a764f8c929
commit 97eada7dd6
9 changed files with 36 additions and 35 deletions

View File

@ -557,7 +557,7 @@ public class Essentials extends JavaPlugin implements IEssentials
for (Player player : players)
{
final User user = getUser(player);
if (!user.isIgnoredPlayer(sender.getName()))
if (!user.isIgnoredPlayer(sender))
{
player.sendMessage(message);
}

View File

@ -63,7 +63,7 @@ public class EssentialsPlayerListener implements Listener
while (it.hasNext())
{
final User u = ess.getUser(it.next());
if (u.isIgnoredPlayer(user.getName()))
if (u.isIgnoredPlayer(user))
{
it.remove();
}

View File

@ -458,20 +458,20 @@ public abstract class UserData extends PlayerExtension implements IConf
config.save();
}
public boolean isIgnoredPlayer(String name)
public boolean isIgnoredPlayer(IUser user)
{
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
}
public void setIgnoredPlayer(String name, boolean set)
public void setIgnoredPlayer(IUser user, boolean set)
{
if (set)
{
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
ignoredPlayers.add(user.getName().toLowerCase(Locale.ENGLISH));
}
else
{
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
ignoredPlayers.remove(user.getName().toLowerCase(Locale.ENGLISH));
}
setIgnoredPlayers(ignoredPlayers);
}

View File

@ -32,15 +32,14 @@ public class Commandignore extends EssentialsCommand
{
throw new Exception(_("playerNotFound"));
}
final String name = player.getName();
if (user.isIgnoredPlayer(name))
if (user.isIgnoredPlayer(player))
{
user.setIgnoredPlayer(name, false);
user.setIgnoredPlayer(player, false);
user.sendMessage(_("unignorePlayer", player.getName()));
}
else
{
user.setIgnoredPlayer(name, true);
user.setIgnoredPlayer(player, true);
user.sendMessage(_("ignorePlayer", player.getName()));
}
}

View File

@ -56,7 +56,7 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("playerNeverOnServer", args[1]));
}
if (!u.isIgnoredPlayer(user.getName()))
if (!u.isIgnoredPlayer(user))
{
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);

View File

@ -81,7 +81,7 @@ public class Commandmsg extends EssentialsCommand
{
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
final User matchedUser = ess.getUser(matchedPlayer);
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
{
continue;
}

View File

@ -55,7 +55,7 @@ public class Commandr extends EssentialsCommand
if (target instanceof Player)
{
User player = ess.getUser(target);
if (player.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
if (sender instanceof Player && player.isIgnoredPlayer(ess.getUser(sender)))
{
return;
}

View File

@ -30,7 +30,7 @@ public class Commandtpa extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
if (!player.isIgnoredPlayer(user.getName()))
if (!player.isIgnoredPlayer(user))
{
player.requestTeleport(user, false);
player.sendMessage(_("teleportRequest", user.getDisplayName()));

View File

@ -121,7 +121,7 @@ public abstract class EssentialsChatPlayer implements Listener
{
String type = _("chatTypeLocal");
final User onlineUser = ess.getUser(onlinePlayer);
if (onlineUser.isIgnoredPlayer(sender.getName()) && !sender.isAuthorized("essentials.chat.ignoreexempt"))
if (onlineUser.isIgnoredPlayer(sender))
{
continue;
}
@ -138,7 +138,8 @@ public abstract class EssentialsChatPlayer implements Listener
{
abort = true;
}
if (abort) {
if (abort)
{
if (onlineUser.isAuthorized("essentials.chat.spy"))
{
type = type.concat(_("chatTypeSpy"));
@ -148,6 +149,7 @@ public abstract class EssentialsChatPlayer implements Listener
continue;
}
}
}
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
for (IEssentialsChatListener listener : listeners.values())