2 Commits
Author SHA1 Message Date
asminme 8731c80227 Fix ban modal and clean console output
Build Plugin / build-and-release (push) Successful in 5m26s
2026-11-08 01:10:55 +01:00
asminme 5d42b48c8b Fix hex rank prefixes in player list
Build Plugin / build-and-release (push) Successful in 5m37s
2026-11-08 00:34:18 +01:00
@@ -60,6 +60,8 @@ import com.sun.net.httpserver.HttpServer;
public final class AsminDiscordBridge extends JavaPlugin {
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)§[0-9A-FK-OR]");
private static final Pattern HEX_COLOR = Pattern.compile("(?i)&#[0-9A-F]{6}");
private static final Pattern ANSI_COLOR = Pattern.compile("(?:\\u001B\\[|\\[)[0-9;]*m");
private JDA jda;
private LuckPerms luckPerms;
@@ -278,7 +280,7 @@ public final class AsminDiscordBridge extends JavaPlugin {
}
private void openKickModal(StringSelectInteractionEvent event, String playerName) {
TextInput reason = TextInput.create("reason", "Powód", TextInputStyle.SHORT)
TextInput reason = TextInput.create("reason", "Wpisz powód kicka", TextInputStyle.SHORT)
.setPlaceholder("Podaj powód kicka")
.setRequired(true)
.setMaxLength(200)
@@ -289,18 +291,18 @@ public final class AsminDiscordBridge extends JavaPlugin {
}
private void openBanModal(StringSelectInteractionEvent event, String playerName) {
TextInput reason = TextInput.create("reason", "Powód", TextInputStyle.SHORT)
TextInput reason = TextInput.create("reason", "Wpisz powód bana", TextInputStyle.SHORT)
.setPlaceholder("Podaj powód bana")
.setRequired(true)
.setMaxLength(200)
.build();
TextInput banIp = TextInput.create("ban-ip", "Ban IP? (tak/nie)", TextInputStyle.SHORT)
TextInput banIp = TextInput.create("ban-ip", "Czy chcesz też bana na IP? (tak/nie)", TextInputStyle.SHORT)
.setPlaceholder("tak lub nie")
.setRequired(true)
.setMaxLength(3)
.build();
event.replyModal(Modal.create("admin:ban-modal:" + playerName, "Ban Player: " + playerName)
.addComponents(ActionRow.of(reason, banIp))
.addComponents(ActionRow.of(reason), ActionRow.of(banIp))
.build()).queue();
}
@@ -498,9 +500,11 @@ public final class AsminDiscordBridge extends JavaPlugin {
}
private String formatPrefix(String prefix) {
String translated = ChatColor.translateAlternateColorCodes('&', prefix);
String plain = ChatColor.stripColor(translated);
if (plain == null || plain.isEmpty()) return "";
if (prefix == null) return "";
String translated = HEX_COLOR.matcher(prefix).replaceAll("");
translated = ChatColor.translateAlternateColorCodes('&', translated);
String plain = ChatColor.stripColor(translated).trim();
if (plain.isEmpty()) return "";
return LEGACY_COLOR.matcher(translated).find() && translated.matches("(?s).*§[lL].*")
? "**" + plain + "** " : plain + " ";
}
@@ -675,7 +679,9 @@ public final class AsminDiscordBridge extends JavaPlugin {
public void append(LogEvent event) {
String message = event.getMessage() == null ? null : event.getMessage().getFormattedMessage();
if (message == null || message.isBlank()) return;
add(ChatColor.stripColor(message));
message = ANSI_COLOR.matcher(ChatColor.stripColor(message)).replaceAll("").trim();
if (message.isEmpty() || message.startsWith("CONSOLE issued server command:")) return;
add(message);
}
private void add(String line) {