using shading on the Jar
switched to Discord4j instead of JDA getEventDispatcher() not working NEW be04 version
This commit is contained in:
Binary file not shown.
93
dependency-reduced-pom.xml
Normal file
93
dependency-reduced-pom.xml
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>MCdiscord_bot</artifactId>
|
||||
<version>1.1be04</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>net.dv8tion:JDA</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.dv8tion</pattern>
|
||||
<shadedPattern>com.example.MCdiscordbot.shaded.net.dv8tion</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<name>spigot-1.20.4</name>
|
||||
<url>https://repo.rosewooddev.io/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>buk-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>discordJDA</id>
|
||||
<name>JDA for Discord</name>
|
||||
<url>https://github.com/DV8FromTheWorld/JDA</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.23.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.23.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.katsstuff</groupId>
|
||||
<artifactId>ackcord-data_sjs1_2.13</artifactId>
|
||||
<version>2.0.0.0-M1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
</properties>
|
||||
</project>
|
98
pom.xml
98
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>MCdiscord_bot</artifactId>
|
||||
<version>1.1be02</version>
|
||||
<version>1.1be04</version>
|
||||
<packaging>jar</packaging> <!-- Specify the correct packaging type here -->
|
||||
|
||||
<properties>
|
||||
@@ -33,12 +33,6 @@
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>discordJDA</id>
|
||||
<name>JDA for Discord</name>
|
||||
<url>https://github.com/DV8FromTheWorld/JDA</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -55,29 +49,14 @@
|
||||
<version>1.20.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--(Java Discord API) with JFlac and Tritonus-dsp -->
|
||||
<dependency>
|
||||
<!-- https://mvnrepository.com/artifact/net.dv8tion/JDA -->
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>5.0.0-alpha.4</version><!-- Update version to the latest stable version -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>jflac</groupId>
|
||||
<artifactId>jflac</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>tritonus</groupId>
|
||||
<artifactId>tritonus-dsp</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>club.minnced</groupId>
|
||||
<artifactId>opus-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
<!--(Java Discord API) -->
|
||||
<dependency>
|
||||
<groupId>com.discord4j</groupId>
|
||||
<artifactId>discord4j-core</artifactId>
|
||||
<version>3.3.0-RC1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Logging-->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
@@ -104,46 +83,33 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.3.0</version> <!-- Adjust version as needed -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.2</version> <!-- Use the latest version -->
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>disMCbot</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Class-Path>.</Class-Path>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>club.minced.discord4j</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>club.minced</pattern>
|
||||
<shadedPattern>com.example.MCdiscordbot.shaded.club.minced</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@@ -1,29 +1,39 @@
|
||||
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import discord4j.core.DiscordClient;
|
||||
import discord4j.core.DiscordClientBuilder;
|
||||
import discord4j.core.event.domain.lifecycle.ReadyEvent;
|
||||
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||
import discord4j.core.object.presence.Activity;
|
||||
import discord4j.core.object.presence.Presence;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import listeners.MinecraftEventListener;
|
||||
|
||||
public class disMCbot {
|
||||
private static TextChannel updateChannel;
|
||||
private static final Logger logger = LogManager.getLogger(disMCbot.class);
|
||||
|
||||
public static void main(String[] args) throws LoginException {
|
||||
public static void main(String[] args) {
|
||||
logger.info("Starting Discord Bot...");
|
||||
String token = "MTIyNjY1NTgxODU0NDMxNjQxNw.GXAYvx.m2_ZmH-J5-iGhqdkW3M2VViG1wBQguKq-OjN80";
|
||||
JDABuilder builder = JDABuilder.createDefault(token);
|
||||
builder.addEventListeners(new MinecraftEventListener(updateChannel));
|
||||
builder.build();
|
||||
}
|
||||
|
||||
public void setUpdateChannel(TextChannel channel) {
|
||||
disMCbot.updateChannel = channel;
|
||||
}
|
||||
DiscordClient client = DiscordClientBuilder.create(token).build();
|
||||
client.login().block();
|
||||
|
||||
client.getEventDispatcher().on(ReadyEvent.class)
|
||||
.subscribe(ready -> {
|
||||
System.out.println("Logged in as: " + ready.getSelf().getUsername());
|
||||
client.updatePresence(Presence.online(Activity.playing("Minecraft")));
|
||||
});
|
||||
|
||||
client.getEventDispatcher().on(MessageCreateEvent.class)
|
||||
.subscribe(event -> {
|
||||
String messageContent = event.getMessage().getContent();
|
||||
if (messageContent.equalsIgnoreCase("!ping")) {
|
||||
event.getMessage().getChannel().block().createMessage("Pong!").block();
|
||||
}
|
||||
// Add more commands as needed
|
||||
});
|
||||
|
||||
client.onDisconnect().block();
|
||||
}
|
||||
// Other methods and event listeners can be added as needed
|
||||
}
|
@@ -4,12 +4,13 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import discord4j.core.object.entity.channel.TextChannel;
|
||||
|
||||
|
||||
|
||||
public class MinecraftEventListener implements Listener {
|
||||
|
||||
private final TextChannel updateChannel; // Discord channel to send updates
|
||||
private final discord4j.core.object.entity.channel.TextChannel updateChannel; // Discord channel to send updates
|
||||
|
||||
public MinecraftEventListener(TextChannel updateChannel) {
|
||||
this.updateChannel = updateChannel;
|
||||
@@ -18,12 +19,12 @@ public class MinecraftEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
String playerName = event.getPlayer().getName();
|
||||
updateChannel.sendMessage("Player " + playerName + " has joined the server.").queue();
|
||||
updateChannel.createMessage("Player " + playerName + " has joined the server.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
String playerName = event.getPlayer().getName();
|
||||
updateChannel.sendMessage("Player " + playerName + " has left the server.").queue();
|
||||
updateChannel.createMessage("Player " + playerName + " has left the server.");
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
name: MCdiscord_bot-1
|
||||
version: 1.1be02
|
||||
version: 1.1be04
|
||||
main: MCdiscord_bot-1.src.main.java.disMCbot
|
||||
description: A Discord bot plugin for Minecraft.
|
||||
author: Bryce
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
name: MCdiscord_bot-1
|
||||
version: 1.1be02
|
||||
version: 1.1be04
|
||||
main: MCdiscord_bot-1.src.main.java.disMCbot
|
||||
description: A Discord bot plugin for Minecraft.
|
||||
author: Bryce
|
||||
|
@@ -1,3 +0,0 @@
|
||||
artifactId=MCdiscord_bot
|
||||
groupId=com.example
|
||||
version=1.1be02
|
@@ -1,2 +0,0 @@
|
||||
disMCbot.class
|
||||
listeners\MinecraftEventListener.class
|
||||
|
Reference in New Issue
Block a user