#5: DiscordSRV support #12
@@ -27,6 +27,15 @@
|
|||||||
<id>placeholderapi</id>
|
<id>placeholderapi</id>
|
||||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>dv8tion</id>
|
||||||
|
<name>m2-dv8tion</name>
|
||||||
|
<url>https://m2.dv8tion.net/releases</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>Scarsz-Nexus</id>
|
||||||
|
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -56,6 +65,12 @@
|
|||||||
<version>2.11.1</version>
|
<version>2.11.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.discordsrv</groupId>
|
||||||
|
<artifactId>discordsrv</artifactId>
|
||||||
|
<version>1.25.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package me.oskar3123.staffchat.spigot.listener;
|
|||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import github.scarsz.discordsrv.DiscordSRV;
|
||||||
|
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
@@ -68,6 +70,9 @@ public class ChatListener implements Listener, PluginMessageListener {
|
|||||||
format = format.replaceAll("\\{MESSAGE}", StringUtils.sanitize(message));
|
format = format.replaceAll("\\{MESSAGE}", StringUtils.sanitize(message));
|
||||||
final String finalMessage = format;
|
final String finalMessage = format;
|
||||||
|
|
||||||
|
if (plugin.getConfig().getBoolean("discordsrv.enable")) {
|
||||||
|
sendDiscordMessage(event.getPlayer(), message);
|
||||||
|
}
|
||||||
if (plugin.getConfig().getBoolean("settings.sendmessagestoallservers")) {
|
if (plugin.getConfig().getBoolean("settings.sendmessagestoallservers")) {
|
||||||
sendForwardPluginMessage(event.getPlayer(), finalMessage);
|
sendForwardPluginMessage(event.getPlayer(), finalMessage);
|
||||||
}
|
}
|
||||||
@@ -130,6 +135,21 @@ public class ChatListener implements Listener, PluginMessageListener {
|
|||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
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) {
|
public boolean togglePlayer(@NotNull UUID player) {
|
||||||
if (toggledPlayers.contains(player)) {
|
if (toggledPlayers.contains(player)) {
|
||||||
toggledPlayers.remove(player);
|
toggledPlayers.remove(player);
|
||||||
|
|||||||
@@ -11,3 +11,7 @@ messages:
|
|||||||
toggled: 'You toggled auto staffchat %s'
|
toggled: 'You toggled auto staffchat %s'
|
||||||
onstring: 'on'
|
onstring: 'on'
|
||||||
offstring: 'off'
|
offstring: 'off'
|
||||||
|
discordsrv:
|
||||||
|
enable: false
|
||||||
|
channel: 'staffchat'
|
||||||
|
format: '{NAME} » {MESSAGE}'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ authors: [ oskar3123 ]
|
|||||||
main: me.oskar3123.staffchat.spigot.Main
|
main: me.oskar3123.staffchat.spigot.Main
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
version: SNAPSHOT
|
version: SNAPSHOT
|
||||||
softdepend: [ PlaceholderAPI ]
|
softdepend: [ PlaceholderAPI, DiscordSRV ]
|
||||||
commands:
|
commands:
|
||||||
staffchat:
|
staffchat:
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
|||||||
Reference in New Issue
Block a user