From 5bd6139cd6bed136a349215a0df95318ab7ed14d Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sun, 19 May 2024 11:49:33 -0400 Subject: [PATCH 1/3] Make TerminalSolver interface sealed --- .../skyblocker/skyblock/dungeon/terminal/ColorTerminal.java | 2 +- .../skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java | 2 +- .../skyblocker/skyblock/dungeon/terminal/OrderTerminal.java | 2 +- .../skyblock/dungeon/terminal/StartsWithTerminal.java | 2 +- .../skyblocker/skyblock/dungeon/terminal/TerminalSolver.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java index 833e85a30c..074980a44c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java @@ -16,7 +16,7 @@ import java.util.*; -public class ColorTerminal extends ContainerSolver implements TerminalSolver { +public non-sealed class ColorTerminal extends ContainerSolver implements TerminalSolver { private static final Logger LOGGER = LoggerFactory.getLogger(ColorTerminal.class.getName()); private static final Map colorFromName; private DyeColor targetColor; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java index 67b51c22c6..f7cc19d096 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java @@ -13,7 +13,7 @@ * * This doesn't solve the terminal because you don't need a solver for it, but rather to simply allow for click blocking. */ -public class LightsOnTerminal extends ContainerSolver implements TerminalSolver { +public non-sealed class LightsOnTerminal extends ContainerSolver implements TerminalSolver { private static final List EMPTY = List.of(); public LightsOnTerminal() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java index e980a13669..b62d452b3b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java @@ -11,7 +11,7 @@ import java.util.Collections; import java.util.List; -public class OrderTerminal extends ContainerSolver implements TerminalSolver { +public non-sealed class OrderTerminal extends ContainerSolver implements TerminalSolver { private final int PANES_NUM = 14; private int[] orderedSlots; private int currentNum = Integer.MAX_VALUE; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java index 51a778a529..d21a5c85a9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.function.Predicate; -public class StartsWithTerminal extends ContainerSolver implements TerminalSolver { +public non-sealed class StartsWithTerminal extends ContainerSolver implements TerminalSolver { private final Int2ObjectOpenHashMap trackedItemStates = new Int2ObjectOpenHashMap<>(); private int lastKnownScreenId = Integer.MIN_VALUE; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/TerminalSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/TerminalSolver.java index 7a7cd6bb02..f20c35b5f7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/TerminalSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/TerminalSolver.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; -public interface TerminalSolver { +public sealed interface TerminalSolver permits ColorTerminal, LightsOnTerminal, OrderTerminal, StartsWithTerminal { default boolean shouldBlockIncorrectClicks() { return SkyblockerConfigManager.get().dungeons.terminals.blockIncorrectClicks; From 235a11157082b239ab5a911f8dca1793f49c663c Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 20 May 2024 01:23:29 -0400 Subject: [PATCH 2/3] Make ExperimentSolver class sealed --- .../skyblocker/skyblock/experiment/ChronomatronSolver.java | 3 +-- .../hysky/skyblocker/skyblock/experiment/ExperimentSolver.java | 2 +- .../hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java | 3 +-- .../skyblocker/skyblock/experiment/UltrasequencerSolver.java | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java index f43b1842af..fb24fd40dc 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java @@ -2,7 +2,6 @@ import com.google.common.collect.ImmutableMap; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.configs.HelperConfig; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -17,7 +16,7 @@ import java.util.ArrayList; import java.util.List; -public class ChronomatronSolver extends ExperimentSolver { +public non-sealed class ChronomatronSolver extends ExperimentSolver { public static final ImmutableMap TERRACOTTA_TO_GLASS = ImmutableMap.ofEntries( new AbstractMap.SimpleImmutableEntry<>(Items.RED_TERRACOTTA, Items.RED_STAINED_GLASS), new AbstractMap.SimpleImmutableEntry<>(Items.ORANGE_TERRACOTTA, Items.ORANGE_STAINED_GLASS), diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/ExperimentSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/ExperimentSolver.java index f91055c733..ad2800e07c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/ExperimentSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/ExperimentSolver.java @@ -11,7 +11,7 @@ import java.util.HashMap; import java.util.Map; -public abstract class ExperimentSolver extends ContainerSolver { +public sealed abstract class ExperimentSolver extends ContainerSolver permits ChronomatronSolver, SuperpairsSolver, UltrasequencerSolver { public enum State { REMEMBER, WAIT, SHOW, END } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java index f4850bf8b4..5bc884790f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java @@ -1,6 +1,5 @@ package de.hysky.skyblocker.skyblock.experiment; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.configs.HelperConfig; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -11,7 +10,7 @@ import java.util.*; -public class SuperpairsSolver extends ExperimentSolver { +public non-sealed class SuperpairsSolver extends ExperimentSolver { private int superpairsPrevClickedSlot; private ItemStack superpairsCurrentSlot; private final Set superpairsDuplicatedSlots = new HashSet<>(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java index 88f0e5c3e8..01c11fb84c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java @@ -1,6 +1,5 @@ package de.hysky.skyblocker.skyblock.experiment; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.configs.HelperConfig; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -12,7 +11,7 @@ import java.util.ArrayList; import java.util.List; -public class UltrasequencerSolver extends ExperimentSolver { +public non-sealed class UltrasequencerSolver extends ExperimentSolver { public static final UltrasequencerSolver INSTANCE = new UltrasequencerSolver(); private int ultrasequencerNextSlot; From c3164592be49a7fb255f76c157d33de0db5109aa Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 20 May 2024 14:50:13 -0400 Subject: [PATCH 3/3] Use final over non-sealed --- .../skyblocker/skyblock/dungeon/terminal/ColorTerminal.java | 2 +- .../skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java | 2 +- .../skyblocker/skyblock/dungeon/terminal/OrderTerminal.java | 2 +- .../skyblock/dungeon/terminal/StartsWithTerminal.java | 2 +- .../skyblocker/skyblock/experiment/ChronomatronSolver.java | 2 +- .../hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java | 2 +- .../skyblocker/skyblock/experiment/UltrasequencerSolver.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java index 074980a44c..2abe518323 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/ColorTerminal.java @@ -16,7 +16,7 @@ import java.util.*; -public non-sealed class ColorTerminal extends ContainerSolver implements TerminalSolver { +public final class ColorTerminal extends ContainerSolver implements TerminalSolver { private static final Logger LOGGER = LoggerFactory.getLogger(ColorTerminal.class.getName()); private static final Map colorFromName; private DyeColor targetColor; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java index f7cc19d096..4975b90b16 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/LightsOnTerminal.java @@ -13,7 +13,7 @@ * * This doesn't solve the terminal because you don't need a solver for it, but rather to simply allow for click blocking. */ -public non-sealed class LightsOnTerminal extends ContainerSolver implements TerminalSolver { +public final class LightsOnTerminal extends ContainerSolver implements TerminalSolver { private static final List EMPTY = List.of(); public LightsOnTerminal() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java index b62d452b3b..0599898815 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/OrderTerminal.java @@ -11,7 +11,7 @@ import java.util.Collections; import java.util.List; -public non-sealed class OrderTerminal extends ContainerSolver implements TerminalSolver { +public final class OrderTerminal extends ContainerSolver implements TerminalSolver { private final int PANES_NUM = 14; private int[] orderedSlots; private int currentNum = Integer.MAX_VALUE; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java index d21a5c85a9..8b0f18018c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/terminal/StartsWithTerminal.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.function.Predicate; -public non-sealed class StartsWithTerminal extends ContainerSolver implements TerminalSolver { +public final class StartsWithTerminal extends ContainerSolver implements TerminalSolver { private final Int2ObjectOpenHashMap trackedItemStates = new Int2ObjectOpenHashMap<>(); private int lastKnownScreenId = Integer.MIN_VALUE; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java index fb24fd40dc..308452ef14 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/ChronomatronSolver.java @@ -16,7 +16,7 @@ import java.util.ArrayList; import java.util.List; -public non-sealed class ChronomatronSolver extends ExperimentSolver { +public final class ChronomatronSolver extends ExperimentSolver { public static final ImmutableMap TERRACOTTA_TO_GLASS = ImmutableMap.ofEntries( new AbstractMap.SimpleImmutableEntry<>(Items.RED_TERRACOTTA, Items.RED_STAINED_GLASS), new AbstractMap.SimpleImmutableEntry<>(Items.ORANGE_TERRACOTTA, Items.ORANGE_STAINED_GLASS), diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java index 5bc884790f..5c2ed152eb 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/SuperpairsSolver.java @@ -10,7 +10,7 @@ import java.util.*; -public non-sealed class SuperpairsSolver extends ExperimentSolver { +public final class SuperpairsSolver extends ExperimentSolver { private int superpairsPrevClickedSlot; private ItemStack superpairsCurrentSlot; private final Set superpairsDuplicatedSlots = new HashSet<>(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java index 01c11fb84c..a4d1e4b6d1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/experiment/UltrasequencerSolver.java @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; -public non-sealed class UltrasequencerSolver extends ExperimentSolver { +public final class UltrasequencerSolver extends ExperimentSolver { public static final UltrasequencerSolver INSTANCE = new UltrasequencerSolver(); private int ultrasequencerNextSlot;