diff options
author | snowleo <schneeleo@gmail.com> | 2011-12-11 09:25:33 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-12-11 09:25:33 +0100 |
commit | d1aea7dd359bacd82a4aaec352e098c5a4e766cd (patch) | |
tree | 008039c5df9420c684a441c5bb7c9ef7dd83257a | |
parent | b2a307ec23487ae29706f3dd42eded453edfb814 (diff) | |
parent | f8e1f025230deec4a777b1cf96eb518fe2c475ef (diff) | |
download | Essentials-d1aea7dd359bacd82a4aaec352e098c5a4e766cd.tar Essentials-d1aea7dd359bacd82a4aaec352e098c5a4e766cd.tar.gz Essentials-d1aea7dd359bacd82a4aaec352e098c5a4e766cd.tar.lz Essentials-d1aea7dd359bacd82a4aaec352e098c5a4e766cd.tar.xz Essentials-d1aea7dd359bacd82a4aaec352e098c5a4e766cd.zip |
Merge branch 'refs/heads/master' into 3.0
Conflicts:
Essentials/src/com/earth2me/essentials/Util.java
5 files changed, 21 insertions, 14 deletions
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 300ff2294..3a2fb8b3f 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -177,7 +177,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser @Override public int compareTo(final User other) { - return this.getName().compareToIgnoreCase(other.getName()); + return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName())); } @Override diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index bfabf1b02..06407b41e 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -20,20 +20,17 @@ import org.bukkit.plugin.PluginManager; public class Util { - - private Util() { } private final static Logger logger = Logger.getLogger("Minecraft"); - private static Pattern unsafeChars = Pattern.compile("[^a-z0-9]"); public static String sanitizeFileName(String name) { return unsafeChars.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); } - + public static String sanitizeKey(String name) { return unsafeChars.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); @@ -497,7 +494,7 @@ public class Util return; } final PluginManager pluginManager = ess.getServer().getPluginManager(); - Permission basePerm = pluginManager.getPermission(path +".*"); + Permission basePerm = pluginManager.getPermission(path + ".*"); if (basePerm != null && !basePerm.getChildren().isEmpty()) { basePerm.getChildren().clear(); @@ -529,4 +526,15 @@ public class Util } basePerm.recalculatePermissibles(); } + 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(""); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java index 6266b5178..b48ac5bcb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java @@ -2,8 +2,8 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.Locale; -import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -31,9 +31,9 @@ public class Commandrealname extends EssentialsCommand { 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) - && !displayName.equals(ChatColor.stripColor(ess.getSettings().getNicknamePrefix()) + whois) + && !displayName.equals(Util.stripColor(ess.getSettings().getNicknamePrefix()) + whois) && !whois.equalsIgnoreCase(u.getName())) { continue; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index c5d10a2e8..7e211455e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.Locale; -import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -37,7 +36,7 @@ public class Commandwhois extends EssentialsCommand showhidden = true; } 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()) { final User user = ess.getUser(onlinePlayer); @@ -45,7 +44,7 @@ public class Commandwhois extends EssentialsCommand { continue; } - final String nickName = ChatColor.stripColor(user.getNickname()); + final String nickName = Util.stripColor(user.getNickname()); if (!whois.equalsIgnoreCase(nickName) && !whois.substring(prefixLength).equalsIgnoreCase(nickName) && !whois.equalsIgnoreCase(user.getName())) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index e82759655..f64b6f3f1 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -5,8 +5,8 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.*; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -147,7 +147,7 @@ public class SignProtection extends EssentialsSign { return SignProtectionState.OWNER; } - if (ChatColor.stripColor(sign.getLine(3)).equalsIgnoreCase(username)) + if (Util.stripColor(sign.getLine(3)).equalsIgnoreCase(username)) { return SignProtectionState.OWNER; } |