Fix ban modal and clean console output
Build Plugin / build-and-release (push) Successful in 5m26s

This commit is contained in:
asminme committed 2026-11-08 01:10:55 +01:00
1 parent 5d42b48c8b
commit 8731c80227
1 file changed
+8 -5
@@ -61,6 +61,7 @@ import com.sun.net.httpserver.HttpServer;
public final class AsminDiscordBridge extends JavaPlugin { public final class AsminDiscordBridge extends JavaPlugin {
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)§[0-9A-FK-OR]"); 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 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 JDA jda;
private LuckPerms luckPerms; private LuckPerms luckPerms;
@@ -279,7 +280,7 @@ public final class AsminDiscordBridge extends JavaPlugin {
} }
private void openKickModal(StringSelectInteractionEvent event, String playerName) { 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") .setPlaceholder("Podaj powód kicka")
.setRequired(true) .setRequired(true)
.setMaxLength(200) .setMaxLength(200)
@@ -290,18 +291,18 @@ public final class AsminDiscordBridge extends JavaPlugin {
} }
private void openBanModal(StringSelectInteractionEvent event, String playerName) { 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") .setPlaceholder("Podaj powód bana")
.setRequired(true) .setRequired(true)
.setMaxLength(200) .setMaxLength(200)
.build(); .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") .setPlaceholder("tak lub nie")
.setRequired(true) .setRequired(true)
.setMaxLength(3) .setMaxLength(3)
.build(); .build();
event.replyModal(Modal.create("admin:ban-modal:" + playerName, "Ban Player: " + playerName) 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(); .build()).queue();
} }
@@ -678,7 +679,9 @@ public final class AsminDiscordBridge extends JavaPlugin {
public void append(LogEvent event) { public void append(LogEvent event) {
String message = event.getMessage() == null ? null : event.getMessage().getFormattedMessage(); String message = event.getMessage() == null ? null : event.getMessage().getFormattedMessage();
if (message == null || message.isBlank()) return; 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) { private void add(String line) {