diff --git a/MCbot.yml b/MCbot.yml index 06cd2e8..9396e62 100644 --- a/MCbot.yml +++ b/MCbot.yml @@ -1,6 +1,6 @@ name: MCbot version: 1.0 -main: src/MCbot.class +main: MCbot description: A custom bot for interacting with Minecraft server stats. author: Bryce api-version: 1.20.4 @@ -14,4 +14,3 @@ commands: death: description: update Death counter and post in chat [player has died [x] times] usage: /death - \ No newline at end of file diff --git a/MCbot_bryce.jar b/MCbot_bryce.jar deleted file mode 100644 index 1eae492..0000000 Binary files a/MCbot_bryce.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index 420bf5f..ed71727 100644 --- a/pom.xml +++ b/pom.xml @@ -23,60 +23,7 @@ provided - - - com.google.api-client - google-api-client - 2.4.0 - - - com.google.http-client - google-http-client - 1.44.1 - - - com.google.http-client - google-http-client-jackson2 - 1.44.1 - - - com.google.oauth-client - google-oauth-client - 1.35.0 - - - com.google.apis - google-api-services-youtube - v3-rev222-1.25.0 - - - - - - net.dv8tion - JDA - 1.2.2_139 - - - jflac - jflac - - - tritonus - tritonus-dsp - - - - - - org.apache.logging.log4j - log4j-core - 2.23.1 - - - - - + diff --git a/src/main/java/MCchatbotyt.java b/src/main/java/MCchatbotyt.java deleted file mode 100644 index 78b50b5..0000000 --- a/src/main/java/MCchatbotyt.java +++ /dev/null @@ -1,107 +0,0 @@ -import com.google.api.client.googleapis.auth.oauth2.Credential; -import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; -import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; -import com.google.api.client.googleapis.http.HttpRequest; -import com.google.api.client.googleapis.http.HttpRequestInitializer; -import com.google.api.client.googleapis.json.JsonFactory; -import com.google.api.client.googleapis.json.jackson2.JacksonFactory; -import com.google.api.services.youtube.YouTube; -import com.google.api.services.youtube.model.LiveChatMessage; -import com.google.api.services.youtube.model.LiveChatMessageListResponse; -import com.google.api.services.youtube.model.LiveChatMessageSnippet; -import com.google.api.services.youtube.model.LiveChatTextMessageDetails; -import com.google.api.services.youtube.model.LiveChatTextMessageDetails.MessageTextDetails; - -import java.io.*; -import java.net.*; -import java.security.GeneralSecurityException; -import java.util.List; - -public class MCchatbotyt { - - private static final String APPLICATION_NAME = "MC chatbot for YT"; - private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); - private static YouTube youtube; - - public static void main(String[] args) throws GeneralSecurityException, IOException { - // Set up credentials - Credential credential = authorize(); - - // Set up YouTube API client - youtube = new YouTube.Builder( - GoogleNetHttpTransport.newTrustedTransport(), - JSON_FACTORY, - new HttpRequestInitializer() { - @Override - public void initialize(HttpRequest request) throws IOException { - request.setInterceptor(credential); - } - }) - .setApplicationName(APPLICATION_NAME) - .build(); - - // Get live chat ID for your live stream - String liveChatId = getLiveChatId("5lAKSeFQS2M"); - - // Poll for new chat messages every few seconds - while (true) { - List messages = getLiveChatMessages(liveChatId); - for (LiveChatMessage message : messages) { - String author = message.getSnippet().getAuthorChannelId(); - String text = message.getSnippet().getDisplayMessage(); - System.out.println("New message from " + author + ": " + text); - // Add your logic to handle incoming messages here - } - - // Connect to the socket server in MCbot.java and send a command - try (Socket socket = new Socket("localhost", 8888); - PrintWriter out = new PrintWriter(socket.getOutputStream(), true); - BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) { - - // Send command to MCbot.java - out.println("!players"); - - // Receive response from MCbot.java - String response = in.readLine(); - System.out.println("Response from MCbot.java: " + response); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(5000); // Poll every 5 seconds - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - private static Credential authorize() throws IOException, GeneralSecurityException { - // Load client secrets JSON file (you need to create this file with your OAuth client ID and secret) - GoogleCredential credential = GoogleCredential.fromStream( - YouTubeLiveChatBot.class.getResourceAsStream("/client_secrets.json")) - .createScoped(List.of("https://www.googleapis.com/auth/youtube")); - - return credential; - } - - private static String getLiveChatId(String liveStreamId) throws IOException { - YouTube.LiveChatMessages.List liveChatRequest = youtube.liveChatMessages() - .list("id,snippet") - .setLiveChatId(liveStreamId); - LiveChatMessageListResponse response = liveChatRequest.execute(); - List messages = response.getItems(); - if (messages != null && !messages.isEmpty()) { - return messages.get(0).getSnippet().getLiveChatId(); - } - return null; - } - - private static List getLiveChatMessages(String liveChatId) throws IOException { - YouTube.LiveChatMessages.List liveChatRequest = youtube.liveChatMessages() - .list("id,snippet") - .setLiveChatId(liveChatId); - LiveChatMessageListResponse response = liveChatRequest.execute(); - return response.getItems(); - } -} \ No newline at end of file diff --git a/src/main/java/disMCbot.java b/src/main/java/disMCbot.java deleted file mode 100644 index b431253..0000000 --- a/src/main/java/disMCbot.java +++ /dev/null @@ -1,64 +0,0 @@ -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/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml deleted file mode 100644 index 35cbe90..0000000 --- a/src/main/resources/log4j2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/target/classes/log4j2.xml b/target/classes/log4j2.xml deleted file mode 100644 index 35cbe90..0000000 --- a/target/classes/log4j2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - -