diff --git a/.vscode/launch.json b/.vscode/launch.json index 66b88f3..6582d41 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,13 +11,6 @@ "request": "launch", "mainClass": "${file}" }, - { - "type": "java", - "name": "MCbot", - "request": "launch", - "mainClass": "MCbot", - "projectName": "minecraft-chatbot" - }, { "type": "java", "name": "MCchatbotyt", diff --git a/pom.xml b/pom.xml index 9bee479..33cae7d 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,15 @@ google-api-client 2.4.0 + + + + + net.dv8tion + JDA + 5.0.0-beta.22 + + diff --git a/src/main/java/MCbot.java b/src/main/java/MCbot.java index fc590f5..53c8c60 100644 --- a/src/main/java/MCbot.java +++ b/src/main/java/MCbot.java @@ -1,7 +1,6 @@ import java.io.*; import java.net.*; -import java.util.List; -import java.util.stream.Collectors; +import java.util.*; import org.bukkit.Bukkit; import org.bukkit.Statistic; @@ -51,7 +50,7 @@ public class MCbot extends JavaPlugin { // Example: If command is "!players", return player list from Minecraft server if (command.equals("!players")) { // Use Spigot API to get player list - List onlinePlayers = Bukkit.getServer().getOnlinePlayers().stream().collect(Collectors.toList())); + List onlinePlayers = Bukkit.getServer().getOnlinePlayers().stream().collect(Collectors.toList()); if (onlinePlayers.isEmpty()) { return "No players are currently online."; diff --git a/src/main/java/disMCbot.java b/src/main/java/disMCbot.java new file mode 100644 index 0000000..65c544e --- /dev/null +++ b/src/main/java/disMCbot.java @@ -0,0 +1,31 @@ +import net.dv8tion.jda.api.*; + +public class DisMCBot { + public static void main(String[] args) { + String token = "YOUR_BOT_TOKEN_HERE"; // Replace with your actual bot token + new DiscordBot(token); + } + public void onMessageReceived(MessageReceivedEvent event) { + String messageContent = event.getMessage().getContentRaw(); + // Parse message content to detect player updates + if (messageContent.contains("died")) { + event.getChannel().sendMessage("A player has died!").queue(); + } else if (messageContent.contains("Exp")) { + // Parse and extract player name, Exp, and other details + // You can use regular expressions or other parsing methods + event.getChannel().sendMessage("Player gained experience!").queue(); + } + } + public DiscordBot(String token) { + try { + JDABuilder.createDefault(token) + .addEventListeners(new BotEventListener()) // Create this class next + .setActivity(Activity.playing("Minecraft")) + .build(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + +} diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 72da7f6..70e0eaf 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,2 +1,3 @@ C:\Users\hbmann\Documents\Projects\__MCchatbot\MCbot_bryce\src\main\java\MCbot.java +C:\Users\hbmann\Documents\Projects\__MCchatbot\MCbot_bryce\src\main\java\disMCbot.java C:\Users\hbmann\Documents\Projects\__MCchatbot\MCbot_bryce\src\main\java\MCchatbotyt.java