minor tweaks
Working on JDA dependency incompatibility
This commit is contained in:
Binary file not shown.
94
pom.xml
94
pom.xml
@@ -5,8 +5,8 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.example</groupId>
|
<groupId>com.example</groupId>
|
||||||
<artifactId>minecraft-chatbot</artifactId>
|
<artifactId>MCdiscord_bot</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1be01</version>
|
||||||
<packaging>jar</packaging> <!-- Specify the correct packaging type here -->
|
<packaging>jar</packaging> <!-- Specify the correct packaging type here -->
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -21,9 +21,28 @@
|
|||||||
<name>spigot-1.20.4</name>
|
<name>spigot-1.20.4</name>
|
||||||
<url>https://repo.rosewooddev.io/repository/public/</url>
|
<url>https://repo.rosewooddev.io/repository/public/</url>
|
||||||
</repository>
|
</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>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<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 -->
|
<!-- Spigot API dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
@@ -46,7 +65,12 @@
|
|||||||
<groupId>tritonus</groupId>
|
<groupId>tritonus</groupId>
|
||||||
<artifactId>tritonus-dsp</artifactId>
|
<artifactId>tritonus-dsp</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>club.minnced</groupId>
|
||||||
|
<artifactId>opus-java</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Logging-->
|
<!-- Logging-->
|
||||||
@@ -78,31 +102,49 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- Maven Compiler Plugin configuration -->
|
<plugin>
|
||||||
<plugin>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<version>3.3.0</version> <!-- Adjust version as needed -->
|
||||||
<version>3.13.0</version> <!-- Use the appropriate version -->
|
<configuration>
|
||||||
<executions>
|
<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>
|
<execution>
|
||||||
<configuration>
|
<id>make-assembly</id>
|
||||||
<rules>
|
<phase>package</phase>
|
||||||
<requireMavenVersion>
|
<goals>
|
||||||
<version>3.0</version>
|
<goal>single</goal>
|
||||||
</requireMavenVersion>
|
</goals>
|
||||||
</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>
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Add other plugins as needed -->
|
</plugins>
|
||||||
</plugins>
|
</build>
|
||||||
</build>
|
|
||||||
</project>
|
</project>
|
@@ -1,68 +1,29 @@
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
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 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 {
|
public class disMCbot {
|
||||||
|
private static TextChannel updateChannel;
|
||||||
private TextChannel updateChannel; // Define the channel where updates will be posted
|
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(disMCbot.class);
|
private static final Logger logger = LogManager.getLogger(disMCbot.class);
|
||||||
|
|
||||||
public static void main(String[] args) throws LoginException {
|
public static void main(String[] args) throws LoginException {
|
||||||
logger.info("Starting Discord Comms...");
|
logger.info("Starting Discord Bot...");
|
||||||
JDABuilder builder = JDABuilder
|
String token = "MTIyNjY1NTgxODU0NDMxNjQxNw.GXAYvx.m2_ZmH-J5-iGhqdkW3M2VViG1wBQguKq-OjN80";
|
||||||
.createDefault("MTIyNjY1NTgxODU0NDMxNjQxNw.GALTlL.vPRJyKTEJNqN1Snfj5G-_2306lBKFdOYB1eDXE");
|
JDABuilder builder = JDABuilder.createDefault(token);
|
||||||
builder.addEventListeners(new disMCbot());
|
builder.addEventListeners(new MinecraftEventListener(updateChannel));
|
||||||
builder.build();
|
builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setUpdateChannel(TextChannel channel) {
|
||||||
public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
|
disMCbot.updateChannel = channel;
|
||||||
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) {
|
// Other methods and event listeners can be added as needed
|
||||||
this.updateChannel = channel;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
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
|
groupId=com.example
|
||||||
version=1.0
|
version=1.1be01
|
||||||
|
@@ -1 +1,2 @@
|
|||||||
disMCbot.class
|
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\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