minor tweaks
Working on JDA dependency incompatibility
This commit is contained in:
Binary file not shown.
82
pom.xml
82
pom.xml
@@ -5,8 +5,8 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>minecraft-chatbot</artifactId>
|
||||
<version>1.0</version>
|
||||
<artifactId>MCdiscord_bot</artifactId>
|
||||
<version>1.1be01</version>
|
||||
<packaging>jar</packaging> <!-- Specify the correct packaging type here -->
|
||||
|
||||
<properties>
|
||||
@@ -21,9 +21,28 @@
|
||||
<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>
|
||||
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version> <!-- Update to the appropriate version -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Spigot API dependency -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@@ -46,7 +65,12 @@
|
||||
<groupId>tritonus</groupId>
|
||||
<artifactId>tritonus-dsp</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>club.minnced</groupId>
|
||||
<artifactId>opus-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging-->
|
||||
@@ -78,31 +102,49 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Maven Compiler Plugin configuration -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version> <!-- Use the appropriate version -->
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.3.0</version> <!-- Adjust version as needed -->
|
||||
<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>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>3.0</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
<source>21</source> <!-- Update to the Java version you're using -->
|
||||
<target>21</target> <!-- Update to the Java version you're using -->
|
||||
<compilerArgs>
|
||||
<arg>--enable-preview</arg> <!-- Enable preview features -->
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Add other plugins as needed -->
|
||||
</plugins>
|
||||
</build>
|
||||
</build>
|
||||
|
||||
</project>
|
@@ -1,68 +1,29 @@
|
||||
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import org.apache.logging.log4j.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import listeners.MinecraftEventListener;
|
||||
|
||||
public class disMCbot extends ListenerAdapter {
|
||||
|
||||
private TextChannel updateChannel; // Define the channel where updates will be posted
|
||||
|
||||
public class disMCbot {
|
||||
private static TextChannel updateChannel;
|
||||
private static final Logger logger = LogManager.getLogger(disMCbot.class);
|
||||
|
||||
public static void main(String[] args) throws LoginException {
|
||||
logger.info("Starting Discord Comms...");
|
||||
JDABuilder builder = JDABuilder
|
||||
.createDefault("MTIyNjY1NTgxODU0NDMxNjQxNw.GALTlL.vPRJyKTEJNqN1Snfj5G-_2306lBKFdOYB1eDXE");
|
||||
builder.addEventListeners(new disMCbot());
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
|
||||
if (event.getAuthor().isBot()) return; // Ignore messages from bots
|
||||
|
||||
String message = event.getMessage().getContentRaw();
|
||||
// Check for conditions or events triggering updates
|
||||
if (message.contains("Player1 died")) {
|
||||
// Log It
|
||||
logger.info("Player1 died - detected");
|
||||
// Post update to the specified channel
|
||||
if (updateChannel != null) {
|
||||
updateChannel.sendMessage("Player1 has died in Minecraft!").queue();
|
||||
// Log It
|
||||
logger.info("Message Posted in Discord.");
|
||||
}
|
||||
} else if (message.contains("Player1 Exp")) {
|
||||
// Log It
|
||||
logger.info("Player1 Exp Gained");
|
||||
// Post another type of update
|
||||
if (updateChannel != null) {
|
||||
updateChannel.sendMessage("Player1 gained experience in Minecraft!").queue();
|
||||
// Log It
|
||||
logger.info("Message sent to Discord.");
|
||||
}
|
||||
} else if (message.contains("drowned")) {
|
||||
// Log It
|
||||
logger.info("Player1 has drowned");
|
||||
// Post another type of update
|
||||
if (updateChannel != null) {
|
||||
updateChannel.sendMessage("Player1 has drowned - they got thirsty!").queue();
|
||||
// Log It
|
||||
logger.info("Message sent to Discord.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpdateChannel(TextChannel channel) {
|
||||
this.updateChannel = channel;
|
||||
disMCbot.updateChannel = channel;
|
||||
}
|
||||
|
||||
// Other methods and event listeners can be added as needed
|
||||
}
|
||||
|
||||
|
29
src/main/java/listeners/MinecraftEventListener.java
Normal file
29
src/main/java/listeners/MinecraftEventListener.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package listeners;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public class MinecraftEventListener implements Listener {
|
||||
|
||||
private final TextChannel updateChannel; // Discord channel to send updates
|
||||
|
||||
public MinecraftEventListener(TextChannel updateChannel) {
|
||||
this.updateChannel = updateChannel;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
String playerName = event.getPlayer().getName();
|
||||
updateChannel.sendMessage("Player " + playerName + " has joined the server.").queue();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
String playerName = event.getPlayer().getName();
|
||||
updateChannel.sendMessage("Player " + playerName + " has left the server.").queue();
|
||||
}
|
||||
}
|
29
src/main/resources/plugin.yml
Normal file
29
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
name: MCdiscord_bot-1
|
||||
version: 1.1be01
|
||||
main: MCdiscord_bot-1.src.main.java.disMCbot
|
||||
description: A Discord bot plugin for Minecraft.
|
||||
author: Bryce
|
||||
api-version: 1.20.4
|
||||
depend: [JDA]
|
||||
|
||||
# Listener Configuration
|
||||
listeners:
|
||||
- MCdiscordbot-1.src.main.java.listeners.MinecraftEventListener
|
||||
|
||||
# Discord Bot Configuration
|
||||
discord:
|
||||
token: "MTIyNjY1NTgxODU0NDMxNjQxNw.GXAYvx.m2_ZmH-J5-iGhqdkW3M2VViG1wBQguKq-OjN80"
|
||||
server:
|
||||
id: "710784165460836402"
|
||||
name: "Bryce & Evee's Community Server"
|
||||
channel: "1226860741592743977"
|
||||
logChannel: "1226860741592743977"
|
||||
|
||||
# Minecraft Event Settings
|
||||
minecraft:
|
||||
events:
|
||||
- type: playerJoin
|
||||
discordChannel: "mc_bot-spam"
|
||||
- type: playerQuit
|
||||
discordChannel: "mc_bot-spam"
|
||||
# Add more event types and their corresponding Discord channels as needed
|
BIN
target/MCdiscord_bot-1.1be01.jar
Normal file
BIN
target/MCdiscord_bot-1.1be01.jar
Normal file
Binary file not shown.
BIN
target/archive-tmp/MCdiscord_bot-1.1be01.jar
Normal file
BIN
target/archive-tmp/MCdiscord_bot-1.1be01.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/listeners/MinecraftEventListener.class
Normal file
BIN
target/classes/listeners/MinecraftEventListener.class
Normal file
Binary file not shown.
29
target/classes/plugin.yml
Normal file
29
target/classes/plugin.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
name: MCdiscord_bot-1
|
||||
version: 1.1be01
|
||||
main: MCdiscord_bot-1.src.main.java.disMCbot
|
||||
description: A Discord bot plugin for Minecraft.
|
||||
author: Bryce
|
||||
api-version: 1.20.4
|
||||
depend: [JDA]
|
||||
|
||||
# Listener Configuration
|
||||
listeners:
|
||||
- MCdiscordbot-1.src.main.java.listeners.MinecraftEventListener
|
||||
|
||||
# Discord Bot Configuration
|
||||
discord:
|
||||
token: "MTIyNjY1NTgxODU0NDMxNjQxNw.GXAYvx.m2_ZmH-J5-iGhqdkW3M2VViG1wBQguKq-OjN80"
|
||||
server:
|
||||
id: "710784165460836402"
|
||||
name: "Bryce & Evee's Community Server"
|
||||
channel: "1226860741592743977"
|
||||
logChannel: "1226860741592743977"
|
||||
|
||||
# Minecraft Event Settings
|
||||
minecraft:
|
||||
events:
|
||||
- type: playerJoin
|
||||
discordChannel: "mc_bot-spam"
|
||||
- type: playerQuit
|
||||
discordChannel: "mc_bot-spam"
|
||||
# Add more event types and their corresponding Discord channels as needed
|
@@ -1,3 +1,3 @@
|
||||
artifactId=minecraft-chatbot
|
||||
artifactId=MCdiscord_bot
|
||||
groupId=com.example
|
||||
version=1.0
|
||||
version=1.1be01
|
||||
|
@@ -1 +1,2 @@
|
||||
disMCbot.class
|
||||
listeners\MinecraftEventListener.class
|
||||
|
@@ -1 +1,2 @@
|
||||
C:\Users\hbmann\Documents\Projects\_MCdiscord-bot\MCdiscord_bot-1\src\main\java\disMCbot.java
|
||||
C:\Users\hbmann\Documents\Projects\_MCdiscord-bot\MCdiscord_bot-1\src\main\java\listeners\MinecraftEventListener.java
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user