diff --git a/src/main/java/ac/grim/grimac/manager/DiscordManager.java b/src/main/java/ac/grim/grimac/manager/DiscordManager.java index b5c734465f..471ed59cd6 100644 --- a/src/main/java/ac/grim/grimac/manager/DiscordManager.java +++ b/src/main/java/ac/grim/grimac/manager/DiscordManager.java @@ -19,6 +19,7 @@ public class DiscordManager implements Initable { private static WebhookClient client; private int embedColor; private String staticContent = ""; + private String embedTitle = ""; public static final Pattern WEBHOOK_PATTERN = Pattern.compile("(?:https?://)?(?:\\w+\\.)?\\w+\\.\\w+/api(?:/v\\d+)?/webhooks/(\\d+)/([\\w-]+)(?:/(?:\\w+)?)?"); @@ -40,6 +41,8 @@ public void start() { client = WebhookClient.withId(Long.parseUnsignedLong(matcher.group(1)), matcher.group(2)); client.setTimeout(15000); // Requests expire after 15 seconds + embedTitle = GrimAPI.INSTANCE.getConfigManager().getConfig().getStringElse("embed-title", "**Grim Alert**"); + try { embedColor = Color.decode(GrimAPI.INSTANCE.getConfigManager().getConfig().getStringElse("embed-color", "#00FFFF")).getRGB(); } catch (NumberFormatException e) { @@ -70,7 +73,7 @@ private List getDefaultContents() { public void sendAlert(GrimPlayer player, String verbose, String checkName, String violations) { if (client != null) { - String content = staticContent + ""; + String content = staticContent; content = content.replace("%check%", checkName); content = content.replace("%violations%", violations); content = GrimAPI.INSTANCE.getExternalAPI().replaceVariables(player, content, false); @@ -80,7 +83,7 @@ public void sendAlert(GrimPlayer player, String verbose, String checkName, Strin .setImageUrl("https://i.stack.imgur.com/Fzh0w.png") // Constant width .setThumbnailUrl("https://crafthead.net/helm/" + player.user.getProfile().getUUID()) .setColor(embedColor) - .setTitle(new WebhookEmbed.EmbedTitle("**Grim Alert**", null)) + .setTitle(new WebhookEmbed.EmbedTitle(embedTitle, null)) .setDescription(content) .setTimestamp(Instant.now()) .setFooter(new WebhookEmbed.EmbedFooter("", "https://grim.ac/images/grim.png")); diff --git a/src/main/resources/discord/de.yml b/src/main/resources/discord/de.yml index bbbd5bbf47..7c2f3a4209 100644 --- a/src/main/resources/discord/de.yml +++ b/src/main/resources/discord/de.yml @@ -1,6 +1,7 @@ # Ob Discord Webhook aktiviert werden soll enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Spieler**: %player%" diff --git a/src/main/resources/discord/en.yml b/src/main/resources/discord/en.yml index 3e8ec153fe..db8a07c9f5 100644 --- a/src/main/resources/discord/en.yml +++ b/src/main/resources/discord/en.yml @@ -1,5 +1,6 @@ enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Player**: %player%" diff --git a/src/main/resources/discord/es.yml b/src/main/resources/discord/es.yml index e8bff28b17..c671557743 100644 --- a/src/main/resources/discord/es.yml +++ b/src/main/resources/discord/es.yml @@ -7,6 +7,8 @@ enabled: false # La URL del webhook. webhook: "" +embed-title: "**Grim Alert**" + # El color del embed que se mandara por este webhook. embed-color: "#00FFFF" diff --git a/src/main/resources/discord/fr.yml b/src/main/resources/discord/fr.yml index 4eff964c8d..667ec70b47 100644 --- a/src/main/resources/discord/fr.yml +++ b/src/main/resources/discord/fr.yml @@ -1,5 +1,6 @@ enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Joueur**: %player%" diff --git a/src/main/resources/discord/it.yml b/src/main/resources/discord/it.yml index 682fcc6ea6..3dbcaa0183 100644 --- a/src/main/resources/discord/it.yml +++ b/src/main/resources/discord/it.yml @@ -1,5 +1,6 @@ enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Giocatore**: %player%" diff --git a/src/main/resources/discord/nl.yml b/src/main/resources/discord/nl.yml index 7175b28ed3..816a7a4df0 100644 --- a/src/main/resources/discord/nl.yml +++ b/src/main/resources/discord/nl.yml @@ -1,5 +1,6 @@ enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Speler**: %player%" diff --git a/src/main/resources/discord/pt.yml b/src/main/resources/discord/pt.yml index 7fe4458072..e1fd1732bb 100644 --- a/src/main/resources/discord/pt.yml +++ b/src/main/resources/discord/pt.yml @@ -1,5 +1,6 @@ enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Jogador**: %player%" diff --git a/src/main/resources/discord/ru.yml b/src/main/resources/discord/ru.yml index 0a195dfb99..49c6d73122 100644 --- a/src/main/resources/discord/ru.yml +++ b/src/main/resources/discord/ru.yml @@ -1,6 +1,7 @@ # Включать ли веб-крючок discord enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**Игрок**: %player%" diff --git a/src/main/resources/discord/zh.yml b/src/main/resources/discord/zh.yml index 82a34f6111..14b9fc8f98 100644 --- a/src/main/resources/discord/zh.yml +++ b/src/main/resources/discord/zh.yml @@ -1,6 +1,7 @@ # 是否启用discord webhook enabled: false webhook: "" +embed-title: "**Grim Alert**" embed-color: "#00FFFF" violation-content: - "**玩家名**: %player%"