diff --git a/pom.xml b/pom.xml
index 8fbe723..7cd291d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,6 +27,15 @@
placeholderapi
https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+ dv8tion
+ m2-dv8tion
+ https://m2.dv8tion.net/releases
+
+
+ Scarsz-Nexus
+ https://nexus.scarsz.me/content/groups/public/
+
@@ -56,6 +65,12 @@
2.11.1
provided
+
+ com.discordsrv
+ discordsrv
+ 1.25.1
+ provided
+
diff --git a/src/main/java/me/oskar3123/staffchat/spigot/listener/ChatListener.java b/src/main/java/me/oskar3123/staffchat/spigot/listener/ChatListener.java
index c3862de..b1808d2 100644
--- a/src/main/java/me/oskar3123/staffchat/spigot/listener/ChatListener.java
+++ b/src/main/java/me/oskar3123/staffchat/spigot/listener/ChatListener.java
@@ -3,6 +3,8 @@ package me.oskar3123.staffchat.spigot.listener;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
+import github.scarsz.discordsrv.DiscordSRV;
+import github.scarsz.discordsrv.util.DiscordUtil;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
@@ -68,6 +70,9 @@ public class ChatListener implements Listener, PluginMessageListener {
format = format.replaceAll("\\{MESSAGE}", StringUtils.sanitize(message));
final String finalMessage = format;
+ if (plugin.getConfig().getBoolean("discordsrv.enable")) {
+ sendDiscordMessage(event.getPlayer(), message);
+ }
if (plugin.getConfig().getBoolean("settings.sendmessagestoallservers")) {
sendForwardPluginMessage(event.getPlayer(), finalMessage);
}
@@ -130,6 +135,21 @@ public class ChatListener implements Listener, PluginMessageListener {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
+ private void sendDiscordMessage(Player player, String message) {
+ if (Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) {
+ String format =
+ plugin
+ .replacePlaceholders(player, plugin.getConfig().getString("discordsrv.format", ""))
+ .replaceAll("\\{NAME}", StringUtils.sanitize(player.getName()))
+ .replaceAll("\\{MESSAGE}", StringUtils.sanitize(message));
+ DiscordUtil.sendMessage(
+ DiscordSRV.getPlugin()
+ .getOptionalTextChannel(
+ plugin.getConfig().getString("discordsrv.channel", "staffchat")),
+ format);
+ }
+ }
+
public boolean togglePlayer(@NotNull UUID player) {
if (toggledPlayers.contains(player)) {
toggledPlayers.remove(player);
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 5937826..c08d403 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -11,3 +11,7 @@ messages:
toggled: 'You toggled auto staffchat %s'
onstring: 'on'
offstring: 'off'
+discordsrv:
+ enable: false
+ channel: 'staffchat'
+ format: '{NAME} ยป {MESSAGE}'
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 7fca06b..2688390 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -3,7 +3,7 @@ authors: [ oskar3123 ]
main: me.oskar3123.staffchat.spigot.Main
api-version: 1.13
version: SNAPSHOT
-softdepend: [ PlaceholderAPI ]
+softdepend: [ PlaceholderAPI, DiscordSRV ]
commands:
staffchat:
usage: /