From aed5d0711f76083854e4fdd13d1582cab68b845d Mon Sep 17 00:00:00 2001 From: Leqends Date: Thu, 10 Oct 2024 23:33:39 -0700 Subject: [PATCH] Initial commit: Add Project files. --- README.md | 25 ++++++++++ main.js | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 7 +++ plugins.json | 6 +++ 4 files changed, 165 insertions(+) create mode 100644 README.md create mode 100644 main.js create mode 100644 package.json create mode 100644 plugins.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..d895bf8 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# Hive Auto Queue for Latite Client + +## Description +This project is a simple plugin that allows the user to automatically queue up for games in the Hive Minecraft server. It is designed to be used only with Latite Client. + +--- + +## How to Install + +1. **Download the zip from releases** +2. **Extract the zip file** +3. **Move the extracted folder to ```%localappdata%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\RoamingState\LatiteRecode\Plugins```** +4. **Launch Latite Client and enable the plugin in the mods menu** + +--- + +## How It Works +The plugin works by running the /connection command on every dimension load. It then takes the game name by the "SERVER-NAME" text in the chat and then filters out the numbers in the text. +It then stores the game name as the current game. It then detects for "Game" or "Victory" text in the title event, and if its shown it will then queue to the next game. + +Currently, the plugin only works for Victory screen and will not work for auto queue on death. This is done in favor of the upcoming party system to the plugin. + +--- + +> "The only way to do great work is to love what you do." — Steve Jobs diff --git a/main.js b/main.js new file mode 100644 index 0000000..c182710 --- /dev/null +++ b/main.js @@ -0,0 +1,127 @@ +//@ts-check +"use strict"; + +// Setup +let hiveAutoQueue = new Module("HiveAutoQueue", + "Hive Auto Queue", "A plugin to automatically queue into the next game in Hive"); + +// This adds the input box for which maps to dodge +let mapDodger = new hiveAutoQueue.addTextSetting("mapDodger", + "Map Dodge List", "The map to dodge", ""); + +// Current game mode +let gameMode = null; + +let partyMembers = new hiveAutoQueue.addTextSetting("partyMembers", + "Party Members", "The members of the party, this is automatically managed", ""); + +let deadMembers = []; +let aliveMembers = []; + +client.getModuleManager().registerModule(hiveAutoQueue); + +/** + * Function to find the current game mode by using connection command + * and listening to the chat message provided by the command to get the game + */ +function findGamemode() { + game.executeCommand("/connection"); + + client.on("receive-chat", chat => { + let message = chat.message; + if(chat.sender === "") { + chat.cancel = message.includes("You are connected to public IP") || + message.includes("You are connected to internal IP"); + + if(message.includes("You are connected to server name")) { + chat.cancel = true; + gameMode = message.split("You are connected to server name")[1]; + gameMode = gameMode.replace(/\d+/g,"").trim(); + } else { + chat.cancel = false; + } + + chat.cancel = message.includes("You are connected to server"); + } + }); +} + +/** + * Function to queue into the next game + */ +function queueNextGame() { + if(!gameMode) { + game.executeCommand("/q " + gameMode); + } +} + +/** + * Function to find the party members + */ +function findPartyMembers() { + game.executeCommand("/party list"); + + /** + * TODO: Detection of party members + */ + + client.on("receive-chat", chat => { + let message = chat.message; + if(chat.sender === "") { + chat.cancel = message.includes("You're issuing commands too quickly, try again later.") || + message.includes("Unknown command. Sorry!"); + } + }); +} + +/** + * Listen for title content to detect if the game is over + */ +client.on("title", title => { + let titleText = title.text; + let server = game.getFeaturedServer(); + if(hiveAutoQueue.isEnabled()) { + if(server.includes("hive")) { + /** + * TODO: Check if the player is solo and queue if the player is dead + */ + if (titleText.includes("Over") || titleText.includes("Victory")) { + queueNextGame(); + } + } + } +}); + +client.on("receive-chat", chat => { + let message = chat.message; + let mapDodgerArray = mapDodger.getValue().split(","); + if(hiveAutoQueue.isEnabled()) { + if (chat.sender === "") { + + /** + * TODO: Do party death detection + */ + if (message.includes("won with") && message.includes("votes!")) { + let mapName = message.split(" ")[1]; + for (let i = 0; i < mapDodgerArray.length; i++) { + if (mapName === mapDodgerArray[i]) { + queueNextGame(); + } + } + } + } + } +}); + +client.on("change-dimension", chat => { + if(hiveAutoQueue.isEnabled()) { + findGamemode(); + client.on("receive-chat", chat => { + let message = chat.message; + if (chat.sender === "") { + chat.cancel = message.includes("You're issuing commands too quickly, try again later.") || + message.includes("Unknown command. Sorry!"); + } + }); + } +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..c7a94b7 --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "LatiteHiveAutoQueue", + "version": "1.0.0", + "devDependencies": { + "@latitescripting/latiteapi": "^2.1.1" + } +} diff --git a/plugins.json b/plugins.json new file mode 100644 index 0000000..d60891f --- /dev/null +++ b/plugins.json @@ -0,0 +1,6 @@ +{ + "name": "Hive Auto Queue", + "author": "Leqends", + "version": "1.0.0", + "description": "Automatically queues up for games on the Hive" +}