Add EssentialsX Discord Support

This commit is contained in:
Josh Roy 2021-08-07 22:27:32 -04:00
parent a49f856470
commit a18c722f27
No known key found for this signature in database
GPG Key ID: 86A69D08540BC29A
3 changed files with 36 additions and 10 deletions

20
pom.xml
View File

@ -96,6 +96,10 @@
<id>bungeecord-repo</id> <id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository> </repository>
<repository>
<id>essentialsx-repo</id>
<url>https://repo.essentialsx.net/snapshots/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
@ -150,6 +154,22 @@
<version>0.96.7.0</version> <version>0.96.7.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsXDiscord</artifactId>
<version>2.19.0-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId> <artifactId>bungeecord-api</artifactId>

View File

@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.util.Set; import java.util.Set;
import net.essentialsx.api.v2.services.discord.DiscordService;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -33,6 +34,7 @@ import mineverse.Aust1n46.chat.utilities.Format;
//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting. //This class listens to chat through the chat event and handles the bulk of the chat channels and formatting.
public class ChatListener implements Listener { public class ChatListener implements Listener {
private final boolean essentialsDiscordHook = Bukkit.getPluginManager().isPluginEnabled("EssentialsDiscord");
private MineverseChat plugin = MineverseChat.getInstance(); private MineverseChat plugin = MineverseChat.getInstance();
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
@ -525,6 +527,10 @@ public class ChatListener implements Listener {
Format.sendPacketPlayOutChat(p, packet); Format.sendPacketPlayOutChat(p, packet);
} }
Bukkit.getConsoleSender().sendMessage(consoleChat); Bukkit.getConsoleSender().sendMessage(consoleChat);
if (essentialsDiscordHook && channel.isDefaultchannel()) {
Bukkit.getServicesManager().load(DiscordService.class).sendChatMessage(mcp.getPlayer(), chat);
}
return; return;
} }
else { else {

View File

@ -3,19 +3,19 @@ version: ${project.version}
api-version: 1.13 api-version: 1.13
main: mineverse.Aust1n46.chat.MineverseChat main: mineverse.Aust1n46.chat.MineverseChat
depend: [Vault, ProtocolLib, PlaceholderAPI] depend: [Vault, ProtocolLib, PlaceholderAPI]
softdepend: [Towny, Factions, Heroes] softdepend: [Towny, Factions, Heroes, EssentialsDiscord]
author: Aust1n46 author: Aust1n46
website: https://bitbucket.org/Aust1n46/venturechat/ website: https://bitbucket.org/Aust1n46/venturechat/
description: #1 Channels Chat plugin! Spigot + Bungee. Supports PlaceholderAPI + JSON formatting. Moderation GUI! description: #1 Channels Chat plugin! Spigot + Bungee. Supports PlaceholderAPI + JSON formatting. Moderation GUI!
commands: commands:
mute: mute:
usage: /mute [playername] [channel] usage: /mute [playername] [channel]
aliases: [mp,vmute] aliases: [mp,vmute]
description: Mutes player in a channel so they cannot talk. description: Mutes player in a channel so they cannot talk.
permission-message: You don't have <permission> permission-message: You don't have <permission>
unmute: unmute:
usage: /unmute [playername] [channel] usage: /unmute [playername] [channel]
aliases: [ump,vunmute] aliases: [ump,vunmute]
description: Unmutes player in a channel so they can talk again. description: Unmutes player in a channel so they can talk again.
permission-message: You don't have <permission> permission-message: You don't have <permission>
msg: msg: