mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-12-27 17:37:34 +01:00
Fixed sign lookups displaying incorrectly when containing hex colors
This commit is contained in:
parent
66e32c02bf
commit
12f2000085
@ -4,6 +4,8 @@ import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,6 +20,8 @@ import net.coreprotect.utility.Util;
|
||||
|
||||
public class SignMessageLookup {
|
||||
|
||||
static Pattern pattern = Pattern.compile("§x(§[a-fA-F0-9]){6}");
|
||||
|
||||
public static List<String> performLookup(String command, Statement statement, Location l, CommandSender commandSender, int page, int limit) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
@ -98,6 +102,14 @@ public class SignMessageLookup {
|
||||
}
|
||||
}
|
||||
|
||||
String parsedMessage = message.toString();
|
||||
if (parsedMessage.contains("§x")) {
|
||||
for (Matcher matcher = pattern.matcher(parsedMessage); matcher.find(); matcher = pattern.matcher(parsedMessage)) {
|
||||
String color = parsedMessage.substring(matcher.start(), matcher.end());
|
||||
parsedMessage = parsedMessage.replace(color, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||
}
|
||||
@ -109,7 +121,7 @@ public class SignMessageLookup {
|
||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.SIGN_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "").toString());
|
||||
}
|
||||
found = true;
|
||||
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n" + message.toString() + Color.WHITE);
|
||||
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n" + parsedMessage + Color.WHITE);
|
||||
PluginChannelListener.getInstance().sendMessageData(commandSender, resultTime, resultUser, message.toString(), true, x, y, z, worldId);
|
||||
}
|
||||
results.close();
|
||||
|
Loading…
Reference in New Issue
Block a user