mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-19 00:55:32 +01:00
Fix sorting of users in /who
This commit is contained in:
parent
a63c116590
commit
f8e1f02523
@ -175,7 +175,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
|
||||
|
@ -477,4 +477,15 @@ public class Util
|
||||
}
|
||||
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("");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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()))
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user