generated from plexusorg/ExampleModule
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d04e6de
commit 2721096
Showing
9 changed files
with
65 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
rootProject.name = "plexmodule-template" | ||
rootProject.name = "Module-DiscordSRV" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package dev.plex.discordsrv; | ||
|
||
import dev.plex.discordsrv.listener.DiscordListener; | ||
import dev.plex.module.PlexModule; | ||
|
||
public class DiscordSRV extends PlexModule | ||
{ | ||
@Override | ||
public void enable() | ||
{ | ||
registerListener(new DiscordListener()); | ||
} | ||
|
||
@Override | ||
public void disable() | ||
{ | ||
// Unregistering listeners / commands is handled by Plex | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/plex/discordsrv/listener/DiscordListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.plex.discordsrv.listener; | ||
|
||
import dev.plex.listener.PlexListener; | ||
import dev.plex.util.PlexLog; | ||
import github.scarsz.discordsrv.DiscordSRV; | ||
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.server.BroadcastMessageEvent; | ||
|
||
public class DiscordListener extends PlexListener | ||
{ | ||
@EventHandler | ||
public void onBroadcastMessage(BroadcastMessageEvent event) | ||
{ | ||
Component message = event.message(); | ||
TextChannel textChannel = DiscordSRV.getPlugin().getDestinationTextChannelForGameChannelName("global"); | ||
if (textChannel != null) | ||
{ | ||
textChannel.sendMessage(LegacyComponentSerializer.legacyAmpersand().serialize(message)).queue(); | ||
} | ||
else | ||
{ | ||
PlexLog.debug("Error sending message to channel!"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Module-Example | ||
main: dev.plex.ExampleModule | ||
description: An example module for Plex | ||
version: 1.0 | ||
name: Module-DiscordSRV | ||
main: dev.plex.discordsrv.DiscordSRV | ||
description: DiscordSRV module for Plex | ||
version: 1.4-SNAPSHOT |