├── .gitignore ├── assets ├── game.png ├── controls.png └── keybindings.png ├── client ├── src │ └── main │ │ ├── resources │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ └── org │ │ │ └── trainer │ │ │ └── client │ │ │ └── control-panel-view.fxml │ │ └── java │ │ ├── org │ │ └── trainer │ │ │ ├── payloads │ │ │ ├── Payload.java │ │ │ ├── PlayerInfoPayload.java │ │ │ ├── PartyStatsPayload.java │ │ │ ├── CommandPayload.java │ │ │ ├── ResponsePayload.java │ │ │ ├── SetPropertyPayload.java │ │ │ ├── PayloadDeserializer.java │ │ │ └── TogglePropertyPayload.java │ │ │ ├── Launcher.java │ │ │ ├── gameinfo │ │ │ ├── Player.java │ │ │ └── Pokemon.java │ │ │ └── client │ │ │ ├── Client.java │ │ │ └── ControlPanelController.java │ │ └── module-info.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /assets/game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yzsvdu/RedTrainer/HEAD/assets/game.png -------------------------------------------------------------------------------- /assets/controls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yzsvdu/RedTrainer/HEAD/assets/controls.png -------------------------------------------------------------------------------- /assets/keybindings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yzsvdu/RedTrainer/HEAD/assets/keybindings.png -------------------------------------------------------------------------------- /client/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: org.trainer.Launcher 3 | 4 | -------------------------------------------------------------------------------- /client/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yzsvdu/RedTrainer/HEAD/client/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/Payload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | public interface Payload { 4 | String getType(); 5 | String getMessage(); 6 | } 7 | -------------------------------------------------------------------------------- /client/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/Launcher.java: -------------------------------------------------------------------------------- 1 | package org.trainer; 2 | 3 | import org.trainer.client.Client; 4 | 5 | public class Launcher { 6 | public static void main(String[] args) { 7 | Client.main(args); 8 | System.exit(0); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/PlayerInfoPayload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | public class PlayerInfoPayload implements Payload { 4 | private String type = "PLAYER-INFO"; 5 | 6 | @Override 7 | public String getType() { 8 | return this.type; 9 | } 10 | 11 | @Override 12 | public String getMessage() { 13 | return "Player Info Payload"; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /client/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module org.trainer.client { 2 | requires javafx.controls; 3 | requires javafx.fxml; 4 | 5 | requires org.controlsfx.controls; 6 | requires com.google.gson; 7 | requires java.desktop; 8 | 9 | opens org.trainer.client to javafx.fxml; 10 | opens org.trainer.payloads to com.google.gson; 11 | opens org.trainer.gameinfo to com.google.gson; 12 | exports org.trainer.client; 13 | exports org.trainer.payloads; 14 | } -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/gameinfo/Player.java: -------------------------------------------------------------------------------- 1 | package org.trainer.gameinfo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Player { 7 | private String name; 8 | private List party; 9 | 10 | public Player(String name) { 11 | this.name = name; 12 | this.party = new ArrayList<>(); 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public List getParty() { 24 | return party; 25 | } 26 | 27 | public void setParty(List party) { 28 | this.party = party; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/PartyStatsPayload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | import org.trainer.gameinfo.Pokemon; 4 | 5 | import java.util.List; 6 | 7 | public class PartyStatsPayload implements Payload { 8 | private String type = "PARTY-STATS"; 9 | private List partyPokemons; 10 | 11 | public PartyStatsPayload(List partyPokemons) { 12 | this.partyPokemons = partyPokemons; 13 | } 14 | @Override 15 | public String getType() { 16 | return this.type; 17 | } 18 | 19 | @Override 20 | public String getMessage() { 21 | return "Party Statistics Payload"; 22 | } 23 | 24 | public List getPartyPokemons() { 25 | return partyPokemons; 26 | } 27 | 28 | public void setPartyPokemons(List partyPokemons) { 29 | this.partyPokemons = partyPokemons; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/CommandPayload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | public class CommandPayload implements Payload { 4 | 5 | private String type = "COMMAND"; 6 | 7 | private String exitCommand = "EXIT"; 8 | 9 | private String cmd; 10 | 11 | @Override 12 | public String getType() { 13 | return type; 14 | } 15 | 16 | @Override 17 | public String getMessage() { 18 | return null; 19 | } 20 | 21 | public void setType(String type) { 22 | this.type = type; 23 | } 24 | 25 | public String getCmd() { 26 | return cmd; 27 | } 28 | 29 | public void setCmd(String cmd) { 30 | this.cmd = cmd; 31 | } 32 | 33 | public String getExitCommand() { 34 | return exitCommand; 35 | } 36 | 37 | public void setExitCommand(String exitCommand) { 38 | this.exitCommand = exitCommand; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/gameinfo/Pokemon.java: -------------------------------------------------------------------------------- 1 | package org.trainer.gameinfo; 2 | 3 | public class Pokemon { 4 | private final String name; 5 | private final int level; 6 | private final int currentHp; 7 | private final int maxHp; 8 | 9 | public Pokemon(String name, int level, int currentHp, int maxHp) { 10 | this.name = name; 11 | this.level = level; 12 | this.currentHp = currentHp; 13 | this.maxHp = maxHp; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public int getLevel() { 21 | return level; 22 | } 23 | 24 | public int getCurrentHp() { 25 | return currentHp; 26 | } 27 | 28 | public int getMaxHp() { 29 | return maxHp; 30 | } 31 | 32 | public String getDescription() { 33 | return "Lv. " + this.level + " " + this.name + " " + this.currentHp + " / " + this.maxHp; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/ResponsePayload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | public class ResponsePayload implements Payload { 3 | private String type = "RESPONSE"; 4 | private String message; 5 | private long timestampMillis; // Using long to store milliseconds 6 | 7 | // Constructors, getters, and setters for EventLogPayload 8 | 9 | 10 | public void setType(String type) { 11 | this.type = type; 12 | } 13 | 14 | public void setMessage(String message) { 15 | this.message = message; 16 | } 17 | 18 | public long getTimestampMillis() { 19 | return timestampMillis; 20 | } 21 | 22 | public void setTimestampMillis(long timestampMillis) { 23 | this.timestampMillis = timestampMillis; 24 | } 25 | 26 | // Other methods... 27 | 28 | @Override 29 | public String getType() { 30 | return type; 31 | } 32 | 33 | @Override 34 | public String getMessage() { 35 | return message; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/SetPropertyPayload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | public class SetPropertyPayload implements Payload { 4 | public String type = "SET-PROPERTY"; 5 | public String propertyName; 6 | public Object value; 7 | 8 | public SetPropertyPayload(String propertyName, Object value) { 9 | this.propertyName = propertyName; 10 | this.value = value; 11 | } 12 | 13 | @Override 14 | public String getType() { 15 | return type; 16 | } 17 | 18 | @Override 19 | public String getMessage() { 20 | return null; 21 | } 22 | 23 | public void setType(String type) { 24 | this.type = type; 25 | } 26 | 27 | public String getPropertyName() { 28 | return propertyName; 29 | } 30 | 31 | public void setPropertyName(String propertyName) { 32 | this.propertyName = propertyName; 33 | } 34 | 35 | public Object getValue() { 36 | return value; 37 | } 38 | 39 | public void setValue(Object value) { 40 | this.value = value; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/PayloadDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | import com.google.gson.*; 4 | 5 | public class PayloadDeserializer implements JsonDeserializer { 6 | @Override 7 | public Payload deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { 8 | JsonObject jsonObject = json.getAsJsonObject(); 9 | String type = jsonObject.get("type").getAsString(); 10 | 11 | switch (type) { 12 | case "TOGGLE-PROPERTY": 13 | return context.deserialize(json, TogglePropertyPayload.class); 14 | case "SET-PROPERTY": 15 | return context.deserialize(json, SetPropertyPayload.class); 16 | case "RESPONSE": 17 | return context.deserialize(json, ResponsePayload.class); 18 | case "PARTY-STATS": 19 | return context.deserialize(json, PartyStatsPayload.class); 20 | default: 21 | throw new JsonParseException("Unknown payload type: " + type); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Vincent Duong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/payloads/TogglePropertyPayload.java: -------------------------------------------------------------------------------- 1 | package org.trainer.payloads; 2 | 3 | public class TogglePropertyPayload implements Payload { 4 | private String type = "TOGGLE-PROPERTY"; 5 | private String propertyName; 6 | private int propertyStatus; 7 | 8 | // Constructors, getters, and setters for TogglePropertyPayload 9 | 10 | 11 | public TogglePropertyPayload(String propertyName, int propertyStatus) { 12 | this.propertyName = propertyName; 13 | this.propertyStatus = propertyStatus; 14 | } 15 | 16 | public void setType(String type) { 17 | this.type = type; 18 | } 19 | 20 | public String getPropertyName() { 21 | return propertyName; 22 | } 23 | 24 | public void setPropertyName(String propertyName) { 25 | this.propertyName = propertyName; 26 | } 27 | 28 | public int getPropertyStatus() { 29 | return propertyStatus; 30 | } 31 | 32 | public void setPropertyStatus(int propertyStatus) { 33 | this.propertyStatus = propertyStatus; 34 | } 35 | 36 | @Override 37 | public String getType() { 38 | return type; 39 | } 40 | 41 | @Override 42 | public String getMessage() { 43 | // Customize as needed 44 | return "TogglePropertyPayload message"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Red Trainer by vnnsnnt 2 | 3 | 4 | ## 🎃 Halloween Update Fix Poll 🎃 [**Go to Poll**](https://github.com/yzsvdu/RedTrainer/discussions/8) 5 | 6 | 7 | 8 | ## A PokeMMO Bot Client 9 | 10 | Control Panel 11 | 12 | 13 | 14 | ## Features 15 | 1. **Runs while the game window is unfocused.** 16 | 2. **Auto Walk** (movement timing may be bugged sometimes, so use it in enclosed spaces) 17 | 3. **Auto Fish** (keybind 4, false swipe is necessary right now) 18 | 4. **Auto Catch** (use false swipe for best results) 19 | 5. **Auto Battle** (payday, level up, with **Custom Move Order**) 20 | 21 | ## How to Use 22 | 23 | ### Requirements 24 | - **Java 17 Runtime** 25 | - [Download Java 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) 26 | 27 | ### Windows 28 | 1. Download the latest `windows_build` from the [release](https://github.com/yzsvdu/RedTrainer/releases). 29 | 2. Copy and paste all files from the build into `C:\Program Files\PokeMMO`. 30 | 3. Start the game with `windows_start.cmd`. 31 | 4. Start the client by running `client.jar`. 32 | 33 | ### MacOS 34 | 1. Download the latest `macos_build` from the [release](https://github.com/yzsvdu/RedTrainer/releases). 35 | 2. Copy and paste all files from the build into `/Users/(your-user-folder)/Library/Application Support/com.pokeemu.macos/pokemmo-client-live`. 36 | 3. Start the game by running `./macos_start.sh`. 37 | 4. Start the client by running `client.jar`. 38 | 39 | ### Warning 40 | 1. Movement key binds must be set to **WASD**. 41 | 2. Primary Key (A) should be set to Space 42 | 3. Fishing Rod must be set to **4** to use Auto Fish. 43 | 44 |
45 | Key Bindings 46 |
47 | -------------------------------------------------------------------------------- /client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.trainer 8 | client 9 | 1.0-SNAPSHOT 10 | client 11 | 12 | 13 | UTF-8 14 | 5.10.0 15 | 16 | 17 | 18 | org.openjfx 19 | javafx-controls 20 | 17.0.6 21 | 22 | 23 | org.openjfx 24 | javafx-fxml 25 | 17.0.6 26 | 27 | 28 | org.controlsfx 29 | controlsfx 30 | 11.1.2 31 | 32 | 33 | org.junit.jupiter 34 | junit-jupiter-api 35 | ${junit.version} 36 | test 37 | 38 | 39 | org.junit.jupiter 40 | junit-jupiter-engine 41 | ${junit.version} 42 | test 43 | 44 | 45 | com.google.code.gson 46 | gson 47 | 2.8.8 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 3.11.0 57 | 58 | 17 59 | 17 60 | 61 | 62 | 63 | org.openjfx 64 | javafx-maven-plugin 65 | 0.0.8 66 | 67 | 68 | 69 | default-cli 70 | 71 | org.trainer.client/org.trainer.client.Client 72 | app 73 | app 74 | app 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/client/Client.java: -------------------------------------------------------------------------------- 1 | package org.trainer.client; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import javafx.application.Application; 6 | import javafx.application.Platform; 7 | import javafx.fxml.FXMLLoader; 8 | import javafx.scene.Scene; 9 | import javafx.stage.Stage; 10 | import org.trainer.payloads.PartyStatsPayload; 11 | import org.trainer.payloads.Payload; 12 | import org.trainer.payloads.PayloadDeserializer; 13 | import org.trainer.payloads.ResponsePayload; 14 | 15 | import java.io.BufferedReader; 16 | import java.io.IOException; 17 | import java.io.InputStreamReader; 18 | import java.io.PrintWriter; 19 | import java.net.Socket; 20 | 21 | public class Client extends Application { 22 | 23 | private static Client instance; 24 | private static String serverAddress = "localhost"; 25 | private static int serverPort = 12343; 26 | private PrintWriter agentWriter; 27 | private ControlPanelController controller; 28 | private boolean isConnectedToServer = false; 29 | private Thread connectionThread; // Add a reference to the connection thread 30 | 31 | @Override 32 | public void start(Stage stage) throws IOException { 33 | instance = this; // Set the instance to this Client object 34 | FXMLLoader fxmlLoader = new FXMLLoader(Client.class.getResource("control-panel-view.fxml")); 35 | Scene scene = new Scene(fxmlLoader.load()); 36 | stage.setTitle("Red Trainer Control Panel"); 37 | stage.setScene(scene); 38 | stage.show(); 39 | 40 | // Set up a close request handler to clean up resources 41 | stage.setOnCloseRequest(event -> { 42 | if (connectionThread != null) { 43 | connectionThread.interrupt(); // Interrupt the connection thread if it's running 44 | } 45 | Platform.exit(); // Shutdown JavaFX application 46 | System.exit(0); // Ensure the application exits completely 47 | }); 48 | 49 | controller = fxmlLoader.getController(); 50 | connectionThread = new Thread(this::connectToAgent); // Use method reference for clarity 51 | connectionThread.start(); 52 | } 53 | 54 | public static Client getInstance() { 55 | return instance; 56 | } 57 | 58 | public static void main(String[] args) { 59 | launch(); 60 | } 61 | 62 | private void connectToAgent() { 63 | while (true) { // Keep trying to connect indefinitely 64 | try { 65 | System.out.println("Attempting to connect to the server..."); 66 | Socket socket = new Socket(serverAddress, serverPort); 67 | isConnectedToServer = true; 68 | Platform.runLater(() -> controller.updateConnectionStatus(isConnectedToServer)); 69 | 70 | // Create input and output streams for communication 71 | agentWriter = new PrintWriter(socket.getOutputStream(), true); 72 | BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); 73 | Gson gson = new GsonBuilder().registerTypeAdapter(Payload.class, new PayloadDeserializer()).create(); 74 | 75 | // Listen for messages from the server 76 | listenToServer(reader, gson, socket); 77 | 78 | } catch (IOException e) { 79 | System.out.println("Failed to connect to server. Retrying in 5 seconds..."); 80 | isConnectedToServer = false; 81 | Platform.runLater(() -> controller.updateConnectionStatus(isConnectedToServer)); 82 | try { 83 | Thread.sleep(5000); // Wait for 5 seconds before retrying 84 | } catch (InterruptedException ie) { 85 | Thread.currentThread().interrupt(); // Restore interrupted status 86 | return; 87 | } 88 | } 89 | } 90 | } 91 | 92 | private void listenToServer(BufferedReader reader, Gson gson, Socket socket) { 93 | try { 94 | String line; 95 | while ((line = reader.readLine()) != null) { 96 | Payload receivedPayload = gson.fromJson(line, Payload.class); 97 | if (receivedPayload == null) continue; 98 | 99 | switch (receivedPayload.getType()) { 100 | case "RESPONSE": 101 | ResponsePayload responsePayload = (ResponsePayload) receivedPayload; 102 | Platform.runLater(() -> controller.updateConsoleLog(responsePayload)); 103 | break; 104 | case "PARTY-STATS": 105 | PartyStatsPayload partyStatsPayload = (PartyStatsPayload) receivedPayload; 106 | Platform.runLater(() -> controller.updatePartyStats(partyStatsPayload)); 107 | break; 108 | } 109 | } 110 | } catch (IOException e) { 111 | e.printStackTrace(); 112 | } finally { 113 | try { 114 | System.out.println("Disconnected from server. Attempting to reconnect..."); 115 | socket.close(); 116 | } catch (IOException e) { 117 | e.printStackTrace(); 118 | } 119 | isConnectedToServer = false; 120 | Platform.runLater(() -> controller.updateConnectionStatus(isConnectedToServer)); 121 | } 122 | } 123 | 124 | 125 | 126 | void sendPayload(Payload payload) { 127 | if (agentWriter != null) { 128 | String jsonPayload = new Gson().toJson(payload); 129 | agentWriter.println(jsonPayload); 130 | 131 | } else { 132 | System.out.println("Error: PrintWriter is not initialized."); 133 | 134 | } 135 | } 136 | 137 | 138 | } 139 | 140 | -------------------------------------------------------------------------------- /client/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /client/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /usr/local/etc/mavenrc ] ; then 40 | . /usr/local/etc/mavenrc 41 | fi 42 | 43 | if [ -f /etc/mavenrc ] ; then 44 | . /etc/mavenrc 45 | fi 46 | 47 | if [ -f "$HOME/.mavenrc" ] ; then 48 | . "$HOME/.mavenrc" 49 | fi 50 | 51 | fi 52 | 53 | # OS specific support. $var _must_ be set to either true or false. 54 | cygwin=false; 55 | darwin=false; 56 | mingw=false 57 | case "`uname`" in 58 | CYGWIN*) cygwin=true ;; 59 | MINGW*) mingw=true;; 60 | Darwin*) darwin=true 61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 63 | if [ -z "$JAVA_HOME" ]; then 64 | if [ -x "/usr/libexec/java_home" ]; then 65 | export JAVA_HOME="`/usr/libexec/java_home`" 66 | else 67 | export JAVA_HOME="/Library/Java/Home" 68 | fi 69 | fi 70 | ;; 71 | esac 72 | 73 | if [ -z "$JAVA_HOME" ] ; then 74 | if [ -r /etc/gentoo-release ] ; then 75 | JAVA_HOME=`java-config --jre-home` 76 | fi 77 | fi 78 | 79 | if [ -z "$M2_HOME" ] ; then 80 | ## resolve links - $0 may be a link to maven's home 81 | PRG="$0" 82 | 83 | # need this for relative symlinks 84 | while [ -h "$PRG" ] ; do 85 | ls=`ls -ld "$PRG"` 86 | link=`expr "$ls" : '.*-> \(.*\)$'` 87 | if expr "$link" : '/.*' > /dev/null; then 88 | PRG="$link" 89 | else 90 | PRG="`dirname "$PRG"`/$link" 91 | fi 92 | done 93 | 94 | saveddir=`pwd` 95 | 96 | M2_HOME=`dirname "$PRG"`/.. 97 | 98 | # make it fully qualified 99 | M2_HOME=`cd "$M2_HOME" && pwd` 100 | 101 | cd "$saveddir" 102 | # echo Using m2 at $M2_HOME 103 | fi 104 | 105 | # For Cygwin, ensure paths are in UNIX format before anything is touched 106 | if $cygwin ; then 107 | [ -n "$M2_HOME" ] && 108 | M2_HOME=`cygpath --unix "$M2_HOME"` 109 | [ -n "$JAVA_HOME" ] && 110 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 111 | [ -n "$CLASSPATH" ] && 112 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 113 | fi 114 | 115 | # For Mingw, ensure paths are in UNIX format before anything is touched 116 | if $mingw ; then 117 | [ -n "$M2_HOME" ] && 118 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 119 | [ -n "$JAVA_HOME" ] && 120 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 121 | fi 122 | 123 | if [ -z "$JAVA_HOME" ]; then 124 | javaExecutable="`which javac`" 125 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 126 | # readlink(1) is not available as standard on Solaris 10. 127 | readLink=`which readlink` 128 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 129 | if $darwin ; then 130 | javaHome="`dirname \"$javaExecutable\"`" 131 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 132 | else 133 | javaExecutable="`readlink -f \"$javaExecutable\"`" 134 | fi 135 | javaHome="`dirname \"$javaExecutable\"`" 136 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 137 | JAVA_HOME="$javaHome" 138 | export JAVA_HOME 139 | fi 140 | fi 141 | fi 142 | 143 | if [ -z "$JAVACMD" ] ; then 144 | if [ -n "$JAVA_HOME" ] ; then 145 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 146 | # IBM's JDK on AIX uses strange locations for the executables 147 | JAVACMD="$JAVA_HOME/jre/sh/java" 148 | else 149 | JAVACMD="$JAVA_HOME/bin/java" 150 | fi 151 | else 152 | JAVACMD="`\\unset -f command; \\command -v java`" 153 | fi 154 | fi 155 | 156 | if [ ! -x "$JAVACMD" ] ; then 157 | echo "Error: JAVA_HOME is not defined correctly." >&2 158 | echo " We cannot execute $JAVACMD" >&2 159 | exit 1 160 | fi 161 | 162 | if [ -z "$JAVA_HOME" ] ; then 163 | echo "Warning: JAVA_HOME environment variable is not set." 164 | fi 165 | 166 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 167 | 168 | # traverses directory structure from process work directory to filesystem root 169 | # first directory with .mvn subdirectory is considered project base directory 170 | find_maven_basedir() { 171 | 172 | if [ -z "$1" ] 173 | then 174 | echo "Path not specified to find_maven_basedir" 175 | return 1 176 | fi 177 | 178 | basedir="$1" 179 | wdir="$1" 180 | while [ "$wdir" != '/' ] ; do 181 | if [ -d "$wdir"/.mvn ] ; then 182 | basedir=$wdir 183 | break 184 | fi 185 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 186 | if [ -d "${wdir}" ]; then 187 | wdir=`cd "$wdir/.."; pwd` 188 | fi 189 | # end of workaround 190 | done 191 | echo "${basedir}" 192 | } 193 | 194 | # concatenates all lines of a file 195 | concat_lines() { 196 | if [ -f "$1" ]; then 197 | echo "$(tr -s '\n' ' ' < "$1")" 198 | fi 199 | } 200 | 201 | BASE_DIR=`find_maven_basedir "$(pwd)"` 202 | if [ -z "$BASE_DIR" ]; then 203 | exit 1; 204 | fi 205 | 206 | ########################################################################################## 207 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 208 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 209 | ########################################################################################## 210 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Found .mvn/wrapper/maven-wrapper.jar" 213 | fi 214 | else 215 | if [ "$MVNW_VERBOSE" = true ]; then 216 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 217 | fi 218 | if [ -n "$MVNW_REPOURL" ]; then 219 | jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 220 | else 221 | jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 222 | fi 223 | while IFS="=" read key value; do 224 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 225 | esac 226 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 227 | if [ "$MVNW_VERBOSE" = true ]; then 228 | echo "Downloading from: $jarUrl" 229 | fi 230 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 231 | if $cygwin; then 232 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 233 | fi 234 | 235 | if command -v wget > /dev/null; then 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Found wget ... using wget" 238 | fi 239 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 240 | wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 241 | else 242 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 243 | fi 244 | elif command -v curl > /dev/null; then 245 | if [ "$MVNW_VERBOSE" = true ]; then 246 | echo "Found curl ... using curl" 247 | fi 248 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 249 | curl -o "$wrapperJarPath" "$jarUrl" -f 250 | else 251 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 252 | fi 253 | 254 | else 255 | if [ "$MVNW_VERBOSE" = true ]; then 256 | echo "Falling back to using Java to download" 257 | fi 258 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 259 | # For Cygwin, switch paths to Windows format before running javac 260 | if $cygwin; then 261 | javaClass=`cygpath --path --windows "$javaClass"` 262 | fi 263 | if [ -e "$javaClass" ]; then 264 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 265 | if [ "$MVNW_VERBOSE" = true ]; then 266 | echo " - Compiling MavenWrapperDownloader.java ..." 267 | fi 268 | # Compiling the Java class 269 | ("$JAVA_HOME/bin/javac" "$javaClass") 270 | fi 271 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 272 | # Running the downloader 273 | if [ "$MVNW_VERBOSE" = true ]; then 274 | echo " - Running MavenWrapperDownloader.java ..." 275 | fi 276 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 277 | fi 278 | fi 279 | fi 280 | fi 281 | ########################################################################################## 282 | # End of extension 283 | ########################################################################################## 284 | 285 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 286 | if [ "$MVNW_VERBOSE" = true ]; then 287 | echo $MAVEN_PROJECTBASEDIR 288 | fi 289 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 290 | 291 | # For Cygwin, switch paths to Windows format before running java 292 | if $cygwin; then 293 | [ -n "$M2_HOME" ] && 294 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 295 | [ -n "$JAVA_HOME" ] && 296 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 297 | [ -n "$CLASSPATH" ] && 298 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 299 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 300 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 301 | fi 302 | 303 | # Provide a "standardized" way to retrieve the CLI args that will 304 | # work with both Windows and non-Windows executions. 305 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 306 | export MAVEN_CMD_LINE_ARGS 307 | 308 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 309 | 310 | exec "$JAVACMD" \ 311 | $MAVEN_OPTS \ 312 | $MAVEN_DEBUG_OPTS \ 313 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 314 | "-Dmaven.home=${M2_HOME}" \ 315 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 316 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 317 | -------------------------------------------------------------------------------- /client/src/main/java/org/trainer/client/ControlPanelController.java: -------------------------------------------------------------------------------- 1 | package org.trainer.client; 2 | 3 | 4 | import javafx.application.Platform; 5 | import javafx.fxml.FXML; 6 | import javafx.fxml.Initializable; 7 | import javafx.scene.Node; 8 | import javafx.scene.control.*; 9 | import javafx.scene.layout.HBox; 10 | import javafx.scene.layout.VBox; 11 | import javafx.scene.shape.Line; 12 | import org.trainer.gameinfo.Pokemon; 13 | import org.trainer.payloads.*; 14 | 15 | 16 | import java.net.URL; 17 | import java.time.Instant; 18 | import java.time.LocalDateTime; 19 | import java.time.ZoneId; 20 | import java.time.format.DateTimeFormatter; 21 | import java.util.Arrays; 22 | import java.util.List; 23 | import java.util.ResourceBundle; 24 | 25 | public class ControlPanelController implements Initializable { 26 | @FXML 27 | private ToggleButton agentToggleButton; 28 | @FXML 29 | private CheckBox autoBattleCheckBox; 30 | @FXML 31 | private CheckBox autoCatchCheckBox; 32 | @FXML 33 | private CheckBox autoFishCheckBox; 34 | @FXML 35 | private CheckBox autoWalkCheckBox; 36 | @FXML 37 | private ComboBox pokemonComboBox; 38 | @FXML 39 | private ComboBox walkPatternComboBox; 40 | @FXML 41 | private VBox slot1mon; 42 | @FXML 43 | private VBox slot2mon; 44 | @FXML 45 | private VBox slot3mon; 46 | @FXML 47 | private VBox slot4mon; 48 | @FXML 49 | private VBox slot5mon; 50 | @FXML 51 | private VBox slot6mon; 52 | @FXML 53 | private TextArea consoleLogArea; 54 | @FXML 55 | private ComboBox move1priority; 56 | @FXML 57 | private ComboBox move2priority; 58 | @FXML 59 | private ComboBox move3priority; 60 | @FXML 61 | private ComboBox move4priority; 62 | @FXML 63 | private ComboBox walkRadiusComboBox; 64 | @FXML 65 | private Label connectionStatusLabel; 66 | 67 | @Override 68 | public void initialize(URL url, ResourceBundle resourceBundle) { 69 | pokemonComboBox.getItems().removeAll(pokemonComboBox.getItems()); 70 | pokemonComboBox.getItems().addAll("Any", "Magikarp", "Dratini", "Meowth"); 71 | pokemonComboBox.getSelectionModel().select("Any"); 72 | 73 | walkPatternComboBox.getItems().removeAll(walkPatternComboBox.getItems()); 74 | walkPatternComboBox.getItems().addAll("Left-Right", "Up-Down", "Circle", "Random"); 75 | walkPatternComboBox.getSelectionModel().select("Circle"); 76 | 77 | move1priority.getItems().addAll("FIRST", "SECOND", "THIRD", "FOURTH"); 78 | move1priority.getSelectionModel().select("FIRST"); 79 | 80 | move2priority.getItems().addAll("FIRST", "SECOND", "THIRD", "FOURTH"); 81 | move2priority.getSelectionModel().select("SECOND"); 82 | 83 | move3priority.getItems().addAll("FIRST", "SECOND", "THIRD", "FOURTH"); 84 | move3priority.getSelectionModel().select("THIRD"); 85 | 86 | move4priority.getItems().addAll("FIRST", "SECOND", "THIRD", "FOURTH"); 87 | move4priority.getSelectionModel().select("FOURTH"); 88 | 89 | walkRadiusComboBox.getItems().addAll( 1.0, 3.0, 7.0, 10.0); 90 | walkRadiusComboBox.getSelectionModel().select(3.0); 91 | 92 | pokemonComboBox.valueProperty().addListener((observable, oldValue, newValue) -> { 93 | onPokemonComboBoxChange(newValue); 94 | 95 | }); 96 | walkPatternComboBox.valueProperty().addListener((observable, oldValue, newValue) -> { 97 | onWalkPatternComboBoxChange(newValue); 98 | }); 99 | // Listeners for ComboBoxes 100 | move1priority.valueProperty().addListener((observable, oldValue, newValue) -> { 101 | handlePriorityChange(move1priority, oldValue, newValue); 102 | }); 103 | 104 | move2priority.valueProperty().addListener((observable, oldValue, newValue) -> { 105 | handlePriorityChange(move2priority, oldValue, newValue); 106 | }); 107 | 108 | move3priority.valueProperty().addListener((observable, oldValue, newValue) -> { 109 | handlePriorityChange(move3priority, oldValue, newValue); 110 | }); 111 | 112 | move4priority.valueProperty().addListener((observable, oldValue, newValue) -> { 113 | handlePriorityChange(move4priority, oldValue, newValue); 114 | }); 115 | 116 | walkRadiusComboBox.valueProperty().addListener((observable, oldValue, newValue) -> { 117 | handleWalkRadiusChange(newValue); 118 | }); 119 | } 120 | 121 | private void handleWalkRadiusChange(double newRadius) { 122 | String propertyName = "WalkRadius"; 123 | SetPropertyPayload setPropertyPayload = new SetPropertyPayload(propertyName, newRadius); 124 | sendPayloadToServer(setPropertyPayload); 125 | } 126 | 127 | // Method to handle swapping logic 128 | private void handlePriorityChange(ComboBox changedComboBox, String oldValue, String newValue) { 129 | // Check if any other ComboBox has the same new value 130 | if (move1priority != changedComboBox && move1priority.getValue().equals(newValue)) { 131 | move1priority.getSelectionModel().select(oldValue); 132 | } else if (move2priority != changedComboBox && move2priority.getValue().equals(newValue)) { 133 | move2priority.getSelectionModel().select(oldValue); 134 | } else if (move3priority != changedComboBox && move3priority.getValue().equals(newValue)) { 135 | move3priority.getSelectionModel().select(oldValue); 136 | } else if (move4priority != changedComboBox && move4priority.getValue().equals(newValue)) { 137 | move4priority.getSelectionModel().select(oldValue); 138 | } 139 | 140 | // After swapping, send all priorities 141 | sendAllMovePriorities(); 142 | } 143 | 144 | private void sendAllMovePriorities() { 145 | // Collecting all priorities 146 | String priority1 = move1priority.getValue(); 147 | String priority2 = move2priority.getValue(); 148 | String priority3 = move3priority.getValue(); 149 | String priority4 = move4priority.getValue(); 150 | 151 | // Sending payloads for all priorities 152 | sendPayloadToServer(new SetPropertyPayload("PRIORITY-SLOT-1", priority1)); 153 | sendPayloadToServer(new SetPropertyPayload("PRIORITY-SLOT-2", priority2)); 154 | sendPayloadToServer(new SetPropertyPayload("PRIORITY-SLOT-3", priority3)); 155 | sendPayloadToServer(new SetPropertyPayload("PRIORITY-SLOT-4", priority4)); 156 | } 157 | 158 | // Method to handle ComboBox value changes 159 | private void onPokemonComboBoxChange(String newValue) { 160 | String propertyName = "SearchforPokemon"; 161 | SetPropertyPayload setPropertyPayload = new SetPropertyPayload(propertyName, newValue); 162 | sendPayloadToServer(setPropertyPayload); 163 | } 164 | 165 | private void onWalkPatternComboBoxChange(String newValue) { 166 | String propertyName = "WalkPattern"; 167 | SetPropertyPayload setPropertyPayload = new SetPropertyPayload(propertyName, newValue); 168 | sendPayloadToServer(setPropertyPayload); 169 | } 170 | 171 | @FXML 172 | protected void onAgentToggleButtonClick() { 173 | if (agentToggleButton.isSelected()) { 174 | agentToggleButton.setText("Disable Bot"); 175 | agentToggleButton.setStyle("-fx-background-color: #e75050;"); 176 | TogglePropertyPayload togglePropertyPayload = new TogglePropertyPayload("AgentEnabled", 1); 177 | sendPayloadToServer(togglePropertyPayload); 178 | 179 | } else { 180 | agentToggleButton.setText("Enable Bot"); 181 | agentToggleButton.setStyle("-fx-background-color: #88e088;"); 182 | TogglePropertyPayload togglePropertyPayload = new TogglePropertyPayload("AgentEnabled", 0); 183 | sendPayloadToServer(togglePropertyPayload); 184 | } 185 | } 186 | 187 | @FXML 188 | protected void onAutoBattleCheckBoxClick() { 189 | boolean isSelected = autoBattleCheckBox.isSelected(); 190 | int propertyStatus; 191 | if(isSelected) propertyStatus = 1; 192 | else propertyStatus = 0; 193 | 194 | String propertyName = "AutoBattleEnabled"; 195 | TogglePropertyPayload togglePropertyPayload = new TogglePropertyPayload(propertyName, propertyStatus); 196 | sendPayloadToServer(togglePropertyPayload); 197 | } 198 | 199 | @FXML 200 | protected void onAutoWalkCheckBoxClick() { 201 | boolean isSelected = autoWalkCheckBox.isSelected(); 202 | int propertyStatus; 203 | if(isSelected) propertyStatus = 1; 204 | else propertyStatus = 0; 205 | 206 | String propertyName = "AutoWalkEnabled"; 207 | TogglePropertyPayload togglePropertyPayload = new TogglePropertyPayload(propertyName, propertyStatus); 208 | sendPayloadToServer(togglePropertyPayload); 209 | } 210 | 211 | @FXML 212 | protected void onAutoFishCheckBoxClick() { 213 | boolean isSelected = autoFishCheckBox.isSelected(); 214 | int propertyStatus; 215 | if(isSelected) propertyStatus = 1; 216 | else propertyStatus = 0; 217 | 218 | String propertyName = "AutoFishEnabled"; 219 | TogglePropertyPayload togglePropertyPayload = new TogglePropertyPayload(propertyName, propertyStatus); 220 | sendPayloadToServer(togglePropertyPayload); 221 | } 222 | 223 | @FXML 224 | protected void setAutoCatchCheckBox() { 225 | boolean isSelected = autoCatchCheckBox.isSelected(); 226 | int propertyStatus; 227 | if(isSelected) propertyStatus = 1; 228 | else propertyStatus = 0; 229 | 230 | String propertyName = "AutoCatchEnabled"; 231 | TogglePropertyPayload togglePropertyPayload = new TogglePropertyPayload(propertyName, propertyStatus); 232 | sendPayloadToServer(togglePropertyPayload); 233 | } 234 | 235 | private void sendPayloadToServer(Payload payload) { 236 | Client client = Client.getInstance(); // Get the instance of Client 237 | if (client != null) { 238 | client.sendPayload(payload); // Send the payload to the server 239 | } else { 240 | System.out.println("Error: Client instance is not available."); 241 | } 242 | } 243 | 244 | 245 | 246 | public void updatePartyStats(PartyStatsPayload partyStatsPayload) { 247 | List partyMons = partyStatsPayload.getPartyPokemons(); 248 | List slots = Arrays.asList(slot1mon, slot2mon, slot3mon, slot4mon, slot5mon, slot6mon); 249 | 250 | for (int i = 0; i < partyMons.size() && i < slots.size(); i++) { 251 | updateSlot(slots.get(i), partyMons.get(i)); 252 | } 253 | } 254 | 255 | private void updateSlot(VBox slot, Pokemon pokemon) { 256 | HBox hbox = null; 257 | Line currentHpLine = null; 258 | for (Node node : slot.getChildren()) { 259 | if (node instanceof HBox) { 260 | hbox = (HBox) node; 261 | } else if (node instanceof Line) { 262 | currentHpLine = (Line) node; 263 | break; 264 | } 265 | } 266 | if (hbox != null) { 267 | if (hbox.getChildren().size() >= 4) { 268 | Label name = (Label) hbox.getChildren().get(1); 269 | Label level = (Label) hbox.getChildren().get(2); 270 | Label health = (Label) hbox.getChildren().get(3); 271 | 272 | // Set text for the 2nd, 3rd, and 4th labels 273 | name.setText(pokemon.getName()); 274 | level.setText("Lv. " + pokemon.getLevel()); 275 | health.setText("HP: " + pokemon.getCurrentHp() + " / " + pokemon.getMaxHp()); 276 | if (currentHpLine != null) { 277 | currentHpLine.setEndX((double) pokemon.getCurrentHp() / pokemon.getMaxHp() * 200); 278 | } 279 | } else { 280 | System.out.println("Not enough labels in HBox."); 281 | } 282 | } else { 283 | System.out.println("HBox not found in VBox."); 284 | } 285 | } 286 | 287 | public void updateConsoleLog(Payload payload) { 288 | ResponsePayload responsePayload = (ResponsePayload) payload; 289 | LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(responsePayload.getTimestampMillis()), ZoneId.systemDefault()); 290 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd@HH:mm:ss"); 291 | String formattedDateTime = dateTime.format(formatter); 292 | String consoleLog = "[" + formattedDateTime + "] " + responsePayload.getMessage() + "\n"; 293 | Platform.runLater(() -> consoleLogArea.appendText(consoleLog)); 294 | } 295 | 296 | public void updateConnectionStatus(boolean isConnected) { 297 | if (isConnected) { 298 | connectionStatusLabel.setText("Connected to Agent"); 299 | connectionStatusLabel.setStyle("-fx-text-fill: #88e088;"); 300 | } else { 301 | connectionStatusLabel.setText("Disconnected from Agent"); 302 | connectionStatusLabel.setStyle("-fx-text-fill: #e75050;"); 303 | } 304 | } 305 | 306 | } -------------------------------------------------------------------------------- /client/src/main/resources/org/trainer/client/control-panel-view.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 |