mirror of
https://github.com/plexusorg/Module-DiscordSRV.git
synced 2024-12-22 09:57:40 +00:00
discordsrv
This commit is contained in:
parent
d04e6de1e7
commit
2721096577
@ -12,6 +12,15 @@ repositories {
|
|||||||
url = uri("https://nexus.telesphoreo.me/repository/plex/")
|
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()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +29,12 @@ dependencies {
|
|||||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("dev.plex:server:1.4-SNAPSHOT")
|
compileOnly("dev.plex:server:1.4-SNAPSHOT")
|
||||||
|
compileOnly("com.discordsrv:discordsrv:1.27.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.plex"
|
group = "dev.plex"
|
||||||
version = "1.0"
|
version = "1.4-SNAPSHOT"
|
||||||
description = "ExampleModule"
|
description = "Module-DiscordSRV"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
@ -39,7 +49,7 @@ publishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.getByName<Jar>("jar") {
|
tasks.getByName<Jar>("jar") {
|
||||||
archiveBaseName.set("Module-ExampleModule")
|
archiveBaseName.set("Module-DiscordSRV")
|
||||||
archiveVersion.set("")
|
archiveVersion.set("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
rootProject.name = "plexmodule-template"
|
rootProject.name = "Module-DiscordSRV"
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package dev.plex;
|
|
||||||
|
|
||||||
import dev.plex.command.ExampleCommand;
|
|
||||||
import dev.plex.listener.ExampleListener;
|
|
||||||
import dev.plex.module.PlexModule;
|
|
||||||
|
|
||||||
public class ExampleModule extends PlexModule
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void enable()
|
|
||||||
{
|
|
||||||
registerCommand(new ExampleCommand());
|
|
||||||
registerListener(new ExampleListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable()
|
|
||||||
{
|
|
||||||
// Unregistering listeners / commands is handled by Plex
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package dev.plex.command;
|
|
||||||
|
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
@CommandParameters(name = "examplemodule", description = "An example command provided by Plex's example module")
|
|
||||||
@CommandPermissions(permission = "plex.module.command")
|
|
||||||
public class ExampleCommand extends PlexCommand
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] strings)
|
|
||||||
{
|
|
||||||
return Component.text("Example module command");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
if (silentCheckPermission(sender, this.getPermission()))
|
|
||||||
{
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
return Arrays.asList("option1", "option2", "option3");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2)
|
|
||||||
{
|
|
||||||
return Arrays.asList("option3", "option4");
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
19
src/main/java/dev/plex/discordsrv/DiscordSRV.java
Normal file
19
src/main/java/dev/plex/discordsrv/DiscordSRV.java
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
package dev.plex.listener;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class ExampleListener extends PlexListener
|
|
||||||
{
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.sendMessage(Component.text("This is a message from Plex's example module!").color(NamedTextColor.GOLD));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
name: Module-Example
|
name: Module-DiscordSRV
|
||||||
main: dev.plex.ExampleModule
|
main: dev.plex.discordsrv.DiscordSRV
|
||||||
description: An example module for Plex
|
description: DiscordSRV module for Plex
|
||||||
version: 1.0
|
version: 1.4-SNAPSHOT
|
Loading…
Reference in New Issue
Block a user