Skip to content

Commit

Permalink
discordsrv
Browse files Browse the repository at this point in the history
  • Loading branch information
Telesphoreo committed Jan 25, 2024
1 parent d04e6de commit 2721096
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 88 deletions.
Empty file added README.md
Empty file.
16 changes: 13 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ repositories {
url = uri("https://nexus.telesphoreo.me/repository/plex/")
}

maven {
url = uri("https://m2.dv8tion.net/releases")
}

maven {
url = uri("https://nexus.scarsz.me/content/groups/public/")
}


mavenCentral()
}

Expand All @@ -20,11 +29,12 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.30")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("dev.plex:server:1.4-SNAPSHOT")
compileOnly("com.discordsrv:discordsrv:1.27.0")
}

group = "dev.plex"
version = "1.0"
description = "ExampleModule"
version = "1.4-SNAPSHOT"
description = "Module-DiscordSRV"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
Expand All @@ -39,7 +49,7 @@ publishing {
}

tasks.getByName<Jar>("jar") {
archiveBaseName.set("Module-ExampleModule")
archiveBaseName.set("Module-DiscordSRV")
archiveVersion.set("")
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "plexmodule-template"
rootProject.name = "Module-DiscordSRV"
21 changes: 0 additions & 21 deletions src/main/java/dev/plex/ExampleModule.java

This file was deleted.

42 changes: 0 additions & 42 deletions src/main/java/dev/plex/command/ExampleCommand.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/dev/plex/discordsrv/DiscordSRV.java
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 src/main/java/dev/plex/discordsrv/listener/DiscordListener.java
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!");
}
}
}
17 changes: 0 additions & 17 deletions src/main/java/dev/plex/listener/ExampleListener.java

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/resources/module.yml
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

0 comments on commit 2721096

Please sign in to comment.