commit 395ab1e3ae60ab667fb8967189b92b10bf3db5e3 Author: Bryce Date: Sat Apr 13 02:12:12 2024 +0000 initial commit diff --git a/disMCbot.java b/disMCbot.java new file mode 100644 index 0000000..d3e9b0f --- /dev/null +++ b/disMCbot.java @@ -0,0 +1,64 @@ +import net.dv8tion.jda.api.JDABuilder; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.entities.TextChannel; + +import javax.security.auth.login.LoginException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +public class disMCbot extends ListenerAdapter { + + private TextChannel updateChannel; // Define the channel where updates will be posted + + 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()); + builder.build(); + } + + @Override + public void onMessageReceived(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; + } +} + + \ No newline at end of file diff --git a/log4j2.xml b/log4j2.xml new file mode 100644 index 0000000..d36b4f7 --- /dev/null +++ b/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f5c94c2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + com.example + minecraft-chatbot + 1.0 + + + + 21 + 21 + + + + + + org.spigotmc + spigot-api + 1.20.4-R0.1-SNAPSHOT + provided + + + + net.dv8tion + JDA + 1.2.2_139 + + + jflac + jflac + + + tritonus + tritonus-dsp + + + + + + org.apache.logging.log4j + log4j-core + 2.23.1 + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 21 + 21 + + --enable-preview + + + + + + + \ No newline at end of file diff --git a/spigot-api-1.20.4-R0.1-SNAPSHOT.jar b/spigot-api-1.20.4-R0.1-SNAPSHOT.jar new file mode 100644 index 0000000..325d585 Binary files /dev/null and b/spigot-api-1.20.4-R0.1-SNAPSHOT.jar differ