Merge branch 'master' of github.com:essentials/Essentials

This commit is contained in:
KHobbits 2011-12-12 00:49:33 +00:00
commit 3eff598791
5 changed files with 19 additions and 9 deletions

View File

@ -175,7 +175,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override @Override
public int compareTo(final User other) public int compareTo(final User other)
{ {
return this.getName().compareToIgnoreCase(other.getName()); return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
} }
@Override @Override

View File

@ -477,4 +477,15 @@ public class Util
} }
return buf.toString(); return buf.toString();
} }
private static transient final Pattern COLOR_PATTERN = Pattern.compile("(?i)\u00A7[0-9A-F]");
public static String stripColor(final String input)
{
if (input == null)
{
return null;
}
return COLOR_PATTERN.matcher(input).replaceAll("");
}
} }

View File

@ -2,8 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale; import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,9 +31,9 @@ public class Commandrealname extends EssentialsCommand
{ {
continue; continue;
} }
final String displayName = ChatColor.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH); final String displayName = Util.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
if (!whois.equals(displayName) if (!whois.equals(displayName)
&& !displayName.equals(ChatColor.stripColor(ess.getSettings().getNicknamePrefix()) + whois) && !displayName.equals(Util.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName())) && !whois.equalsIgnoreCase(u.getName()))
{ {
continue; continue;

View File

@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util; import com.earth2me.essentials.Util;
import java.util.Locale; import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -37,7 +36,7 @@ public class Commandwhois extends EssentialsCommand
showhidden = true; showhidden = true;
} }
final String whois = args[0].toLowerCase(Locale.ENGLISH); final String whois = args[0].toLowerCase(Locale.ENGLISH);
final int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length(); final int prefixLength = Util.stripColor(ess.getSettings().getNicknamePrefix()).length();
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
{ {
final User user = ess.getUser(onlinePlayer); final User user = ess.getUser(onlinePlayer);
@ -45,7 +44,7 @@ public class Commandwhois extends EssentialsCommand
{ {
continue; continue;
} }
final String nickName = ChatColor.stripColor(user.getNickname()); final String nickName = Util.stripColor(user.getNickname());
if (!whois.equalsIgnoreCase(nickName) if (!whois.equalsIgnoreCase(nickName)
&& !whois.substring(prefixLength).equalsIgnoreCase(nickName) && !whois.substring(prefixLength).equalsIgnoreCase(nickName)
&& !whois.equalsIgnoreCase(user.getName())) && !whois.equalsIgnoreCase(user.getName()))

View File

@ -5,8 +5,8 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*; import java.util.*;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -147,7 +147,7 @@ public class SignProtection extends EssentialsSign
{ {
return SignProtectionState.OWNER; return SignProtectionState.OWNER;
} }
if (ChatColor.stripColor(sign.getLine(3)).equalsIgnoreCase(username)) if (Util.stripColor(sign.getLine(3)).equalsIgnoreCase(username))
{ {
return SignProtectionState.OWNER; return SignProtectionState.OWNER;
} }