diff --git a/src/main/java/net/pistonmaster/serverwrecker/ServerWrecker.java b/src/main/java/net/pistonmaster/serverwrecker/ServerWrecker.java index c154d1b45..0b7851091 100644 --- a/src/main/java/net/pistonmaster/serverwrecker/ServerWrecker.java +++ b/src/main/java/net/pistonmaster/serverwrecker/ServerWrecker.java @@ -92,6 +92,7 @@ public class ServerWrecker { public static final Logger LOGGER = LoggerFactory.getLogger(ServerWrecker.class); public static final Path DATA_FOLDER = Path.of(System.getProperty("user.home"), ".serverwrecker"); public static final PlainTextComponentSerializer PLAIN_MESSAGE_SERIALIZER; + public static final Gson GENERAL_GSON = new Gson(); // Static, but the preloading happens in ResourceData since we don't wanna init any constructors static { @@ -103,7 +104,6 @@ public class ServerWrecker { ).build(); } - public static final Gson GENERAL_GSON = new Gson(); private final Injector injector = new InjectorBuilder() .addDefaultHandlers("net.pistonmaster.serverwrecker") .create(); diff --git a/src/main/java/net/pistonmaster/serverwrecker/gui/libs/HintManager.java b/src/main/java/net/pistonmaster/serverwrecker/gui/libs/HintManager.java index 23ad62faf..cf50eea11 100644 --- a/src/main/java/net/pistonmaster/serverwrecker/gui/libs/HintManager.java +++ b/src/main/java/net/pistonmaster/serverwrecker/gui/libs/HintManager.java @@ -45,6 +45,9 @@ public class HintManager { private static final List hintPanels = new ArrayList<>(); + private HintManager() { + } + public static void showHint(Hint hint) { // check whether user already closed the hint if (GUIClientProps.getBoolean(hint.prefsKey, false)) { @@ -82,6 +85,9 @@ private static class HintPanel private final Hint hint; private JPanel popup; + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JLabel hintLabel; + private JButton gotItButton; private HintPanel(Hint hint) { this.hint = hint; @@ -229,10 +235,6 @@ private void initComponents() { add(gotItButton, "cell 0 1,alignx right,growx 0"); // JFormDesigner - End of component initialization //GEN-END:initComponents } - - // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JLabel hintLabel; - private JButton gotItButton; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/src/main/java/net/pistonmaster/serverwrecker/pathfinding/graph/MinecraftGraph.java b/src/main/java/net/pistonmaster/serverwrecker/pathfinding/graph/MinecraftGraph.java index a7cf4ef18..5147b7d0e 100644 --- a/src/main/java/net/pistonmaster/serverwrecker/pathfinding/graph/MinecraftGraph.java +++ b/src/main/java/net/pistonmaster/serverwrecker/pathfinding/graph/MinecraftGraph.java @@ -103,6 +103,121 @@ public record MinecraftGraph(TagsState tagsState) { } } + private static PlayerMovement registerMovement(Object2ObjectMap> blockSubscribers, + PlayerMovement movement, int movementIndex) { + { + var blockId = 0; + for (var freeBlock : movement.listRequiredFreeBlocks()) { + blockSubscribers.computeIfAbsent(freeBlock, CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE, blockId++)); + } + } + + { + var safeBlocks = movement.listCheckSafeMineBlocks(); + for (var i = 0; i < safeBlocks.length; i++) { + var savedBlock = safeBlocks[i]; + if (savedBlock == null) { + continue; + } + + for (var block : savedBlock) { + blockSubscribers.computeIfAbsent(block.position(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_BREAK_SAFETY_CHECK, i, block.type())); + } + } + } + + { + blockSubscribers.computeIfAbsent(movement.requiredSolidBlock(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_SOLID)); + } + + { + for (var addCostIfSolidBlock : movement.listAddCostIfSolidBlocks()) { + blockSubscribers.computeIfAbsent(addCostIfSolidBlock, CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_ADD_CORNER_COST_IF_SOLID)); + } + } + + { + for (var againstBlock : movement.possibleBlocksToPlaceAgainst()) { + blockSubscribers.computeIfAbsent(againstBlock.againstPos(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_AGAINST_PLACE_SOLID, againstBlock)); + } + } + + return movement; + } + + private static ParkourMovement registerParkourMovement(Object2ObjectMap> blockSubscribers, + ParkourMovement movement, int movementIndex) { + { + var blockId = 0; + for (var freeBlock : movement.listRequiredFreeBlocks()) { + blockSubscribers.computeIfAbsent(freeBlock, CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE, blockId++)); + } + } + + { + blockSubscribers.computeIfAbsent(movement.requiredUnsafeBlock(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.PARKOUR_UNSAFE_TO_STAND_ON)); + } + + { + blockSubscribers.computeIfAbsent(movement.requiredSolidBlock(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_SOLID)); + } + + return movement; + } + + private static DownMovement registerDownMovement(Object2ObjectMap> blockSubscribers, + DownMovement movement, int movementIndex) { + { + for (var safetyBlock : movement.listSafetyCheckBlocks()) { + blockSubscribers.computeIfAbsent(safetyBlock, CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.DOWN_SAFETY_CHECK)); + } + } + + { + blockSubscribers.computeIfAbsent(movement.blockToBreak(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE)); + } + + return movement; + } + + private static UpMovement registerUpMovement(Object2ObjectMap> blockSubscribers, + UpMovement movement, int movementIndex) { + { + var blockId = 0; + for (var freeBlock : movement.listRequiredFreeBlocks()) { + blockSubscribers.computeIfAbsent(freeBlock, CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE, blockId++)); + } + } + + { + var safeBlocks = movement.listCheckSafeMineBlocks(); + for (var i = 0; i < safeBlocks.length; i++) { + var savedBlock = safeBlocks[i]; + if (savedBlock == null) { + continue; + } + + for (var block : savedBlock) { + blockSubscribers.computeIfAbsent(block.position(), CREATE_MISSING_FUNCTION) + .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_BREAK_SAFETY_CHECK, i, block.type())); + } + } + } + + return movement; + } + public GraphInstructions[] getActions(BotEntityState node) { var actions = new GraphAction[ACTIONS_TEMPLATE.length]; @@ -413,121 +528,6 @@ public GraphInstructions[] getActions(BotEntityState node) { return results; } - private static PlayerMovement registerMovement(Object2ObjectMap> blockSubscribers, - PlayerMovement movement, int movementIndex) { - { - var blockId = 0; - for (var freeBlock : movement.listRequiredFreeBlocks()) { - blockSubscribers.computeIfAbsent(freeBlock, CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE, blockId++)); - } - } - - { - var safeBlocks = movement.listCheckSafeMineBlocks(); - for (var i = 0; i < safeBlocks.length; i++) { - var savedBlock = safeBlocks[i]; - if (savedBlock == null) { - continue; - } - - for (var block : savedBlock) { - blockSubscribers.computeIfAbsent(block.position(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_BREAK_SAFETY_CHECK, i, block.type())); - } - } - } - - { - blockSubscribers.computeIfAbsent(movement.requiredSolidBlock(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_SOLID)); - } - - { - for (var addCostIfSolidBlock : movement.listAddCostIfSolidBlocks()) { - blockSubscribers.computeIfAbsent(addCostIfSolidBlock, CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_ADD_CORNER_COST_IF_SOLID)); - } - } - - { - for (var againstBlock : movement.possibleBlocksToPlaceAgainst()) { - blockSubscribers.computeIfAbsent(againstBlock.againstPos(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_AGAINST_PLACE_SOLID, againstBlock)); - } - } - - return movement; - } - - private static ParkourMovement registerParkourMovement(Object2ObjectMap> blockSubscribers, - ParkourMovement movement, int movementIndex) { - { - var blockId = 0; - for (var freeBlock : movement.listRequiredFreeBlocks()) { - blockSubscribers.computeIfAbsent(freeBlock, CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE, blockId++)); - } - } - - { - blockSubscribers.computeIfAbsent(movement.requiredUnsafeBlock(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.PARKOUR_UNSAFE_TO_STAND_ON)); - } - - { - blockSubscribers.computeIfAbsent(movement.requiredSolidBlock(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_SOLID)); - } - - return movement; - } - - private static DownMovement registerDownMovement(Object2ObjectMap> blockSubscribers, - DownMovement movement, int movementIndex) { - { - for (var safetyBlock : movement.listSafetyCheckBlocks()) { - blockSubscribers.computeIfAbsent(safetyBlock, CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.DOWN_SAFETY_CHECK)); - } - } - - { - blockSubscribers.computeIfAbsent(movement.blockToBreak(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE)); - } - - return movement; - } - - private static UpMovement registerUpMovement(Object2ObjectMap> blockSubscribers, - UpMovement movement, int movementIndex) { - { - var blockId = 0; - for (var freeBlock : movement.listRequiredFreeBlocks()) { - blockSubscribers.computeIfAbsent(freeBlock, CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_FREE, blockId++)); - } - } - - { - var safeBlocks = movement.listCheckSafeMineBlocks(); - for (var i = 0; i < safeBlocks.length; i++) { - var savedBlock = safeBlocks[i]; - if (savedBlock == null) { - continue; - } - - for (var block : savedBlock) { - blockSubscribers.computeIfAbsent(block.position(), CREATE_MISSING_FUNCTION) - .add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_BREAK_SAFETY_CHECK, i, block.type())); - } - } - } - - return movement; - } - enum SubscriptionType { MOVEMENT_FREE, MOVEMENT_BREAK_SAFETY_CHECK, diff --git a/src/main/java/net/pistonmaster/serverwrecker/util/VelocityConstants.java b/src/main/java/net/pistonmaster/serverwrecker/util/VelocityConstants.java index 24b3c83ff..533fc3d3b 100644 --- a/src/main/java/net/pistonmaster/serverwrecker/util/VelocityConstants.java +++ b/src/main/java/net/pistonmaster/serverwrecker/util/VelocityConstants.java @@ -24,15 +24,14 @@ * Taken from Velocity */ public class VelocityConstants { - private VelocityConstants() { - } - public static final String VELOCITY_IP_FORWARDING_CHANNEL = "velocity:player_info"; public static final int MODERN_FORWARDING_DEFAULT = 1; public static final int MODERN_FORWARDING_WITH_KEY = 2; public static final int MODERN_FORWARDING_WITH_KEY_V2 = 3; public static final int MODERN_LAZY_SESSION = 4; public static final int MODERN_FORWARDING_MAX_VERSION = MODERN_LAZY_SESSION; - public static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; + + private VelocityConstants() { + } }