From 07f1a3064dfdeb86c4a27b2a0592327facf356af Mon Sep 17 00:00:00 2001 From: Fesaa <77553571+Fesaa@users.noreply.github.com> Date: Sat, 27 Jul 2024 16:02:01 +0200 Subject: [PATCH] Drop generator support It was not maintainable. --- .../core/commands/GameMapInfoCommand.java | 2 +- .../subconfig/GameMapInfoSubConfig.java | 8 ------- .../core/listener/KeyEventListener.java | 2 +- .../submanagers/GameMapInfoManager.java | 19 ++++----------- .../addons/cubepanion/core/utils/Utils.java | 24 ++++--------------- .../core/utils/gamemaps/CrossGameMap.java | 5 ++-- .../utils/gamemaps/DoubleCrossGameMap.java | 5 ++-- .../core/utils/gamemaps/SquareGameMap.java | 5 ++-- .../utils/gamemaps/TriangleEggWarsMap.java | 5 ++-- .../utils/gamemaps/base/LoadedGameMap.java | 12 +--------- .../cubepanion/core/weave/GameMapAPI.java | 11 +-------- 11 files changed, 20 insertions(+), 78 deletions(-) diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/commands/GameMapInfoCommand.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/commands/GameMapInfoCommand.java index c2ecde8..62aa9d7 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/commands/GameMapInfoCommand.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/commands/GameMapInfoCommand.java @@ -39,7 +39,7 @@ public boolean execute(String prefix, String[] arguments) { } boolean check = this.addon.getManager().getGameMapInfoManager() - .doGameMapLayout(mapName, false); + .doGameMapLayout(mapName); if (!check) { this.displayMessage( Component.translatable() diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/config/subconfig/GameMapInfoSubConfig.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/config/subconfig/GameMapInfoSubConfig.java index b4ba8cf..a4f75ca 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/config/subconfig/GameMapInfoSubConfig.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/config/subconfig/GameMapInfoSubConfig.java @@ -25,10 +25,6 @@ public class GameMapInfoSubConfig extends Config { @SpriteSlot(x = 6, y = 2) private final ConfigProperty buildLimit = new ConfigProperty<>(true); - @SwitchSetting - @SpriteSlot(y = 2, x = 1) - private final ConfigProperty genLayout = new ConfigProperty<>(true); - public ConfigProperty isEnabled() { return this.enabled; } @@ -45,8 +41,4 @@ public ConfigProperty getBuildLimit() { return this.buildLimit; } - public ConfigProperty getGenLayout() { - return genLayout; - } - } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/listener/KeyEventListener.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/listener/KeyEventListener.java index 6a6344a..5c68485 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/listener/KeyEventListener.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/listener/KeyEventListener.java @@ -58,7 +58,7 @@ public void onKeyEvent(KeyEvent keyEvent) { && GameMapAPI.getInstance().hasMaps(this.addon.getManager().getDivision())) { if (keyEvent.state() == State.PRESS) { this.addon.getManager().getGameMapInfoManager() - .doGameMapLayout(this.addon.getManager().getMapName(), true); + .doGameMapLayout(this.addon.getManager().getMapName()); } } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/managers/submanagers/GameMapInfoManager.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/managers/submanagers/GameMapInfoManager.java index f7a1eaa..13e529d 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/managers/submanagers/GameMapInfoManager.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/managers/submanagers/GameMapInfoManager.java @@ -22,7 +22,7 @@ public GameMapInfoManager(Cubepanion addon) { this.gameMapInfoSubConfig = addon.configuration().getGameMapInfoSubConfig(); } - private void displayGameMapLayout(LoadedGameMap map, boolean genLayout) { + private void displayGameMapLayout(LoadedGameMap map) { ChatExecutor chat = this.addon.labyAPI().minecraft().chatExecutor(); if (addon.getManager().getMapName().equals(map.getName())) { @@ -50,27 +50,16 @@ private void displayGameMapLayout(LoadedGameMap map, boolean genLayout) { .append(buildLimit); } - if (genLayout) { - Component component = map.getGenLayoutComponent(); - if (component != null) { - display = display - .append(Component.newline()) - .append(this.addon.prefix()) - .append(component); - } - - } - chat.displayClientMessage(display.append(Component.newline())); } - public boolean doGameMapLayout(String mapName, boolean keyBind) { + public boolean doGameMapLayout(String mapName) { LoadedGameMap map = GameMapAPI.getInstance().getGameMapFromCache(this.addon.getManager().getDivision(), mapName); GameMapInfoSubConfig config = this.addon.configuration().getGameMapInfoSubConfig(); if (map == null) { return false; } - this.displayGameMapLayout(map, config.getGenLayout().get() && !keyBind); + this.displayGameMapLayout(map); return true; } @@ -84,7 +73,7 @@ public void doGameMapLayout() { return; } - this.displayGameMapLayout(map, false); + this.displayGameMapLayout(map); } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/Utils.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/Utils.java index 43cd258..f7255aa 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/Utils.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/Utils.java @@ -8,11 +8,9 @@ import art.ameliah.laby.addons.cubepanion.core.utils.gamemaps.TriangleEggWarsMap; import art.ameliah.laby.addons.cubepanion.core.utils.gamemaps.base.GenLayout; import art.ameliah.laby.addons.cubepanion.core.utils.gamemaps.base.GenLayout.Location; -import art.ameliah.laby.addons.cubepanion.core.utils.gamemaps.base.GenLayout.MapGenerator; import art.ameliah.laby.addons.cubepanion.core.utils.gamemaps.base.LoadedGameMap; import art.ameliah.laby.addons.cubepanion.core.weave.ChestAPI.ChestLocation; import art.ameliah.laby.addons.cubepanion.core.weave.GameMapAPI.GameMap; -import art.ameliah.laby.addons.cubepanion.core.weave.GameMapAPI.Generator; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -51,20 +49,6 @@ public class Utils { } public static @Nullable LoadedGameMap fromAPIMap(GameMap map) { - Generator[] gens = map.generators(); - GenLayout layout = null; - // EggWars Map - if (gens != null) { - List mapGenerators = new ArrayList<>(); - for (Generator gen : gens) { - MapGenerator mapGen = new MapGenerator(transformGen(gen.gen_type()), - transformLoc(gen.gen_location()), gen.level(), gen.count()); - mapGenerators.add(mapGen); - } - layout = new GenLayout(mapGenerators); - } - - CubeGame game = CubeGame.stringToGame(map.game()); if (game.equals(CubeGame.NONE)) { return null; @@ -72,19 +56,19 @@ public class Utils { switch (map.layout()) { case "square" -> { - return new SquareGameMap(game, map.map_name(), map.team_size(), map.build_limit(), layout, + return new SquareGameMap(game, map.map_name(), map.team_size(), map.build_limit(), twoDeepStringList(transformColours(map))); } case "cross" -> { - return new CrossGameMap(game, map.map_name(), map.team_size(), map.build_limit(), layout, + return new CrossGameMap(game, map.map_name(), map.team_size(), map.build_limit(), oneDeepStringList(transformColours(map))); } case "doublecross" -> { - return new DoubleCrossGameMap(game, map.map_name(), map.team_size(), map.build_limit(), layout, + return new DoubleCrossGameMap(game, map.map_name(), map.team_size(), map.build_limit(), twoDeepStringList(transformColours(map))); } case "triangle" -> { - return new TriangleEggWarsMap(game, map.map_name(), map.team_size(), map.build_limit(), layout, + return new TriangleEggWarsMap(game, map.map_name(), map.team_size(), map.build_limit(), twoDeepStringList(transformColours(map))); } default -> { diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/CrossGameMap.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/CrossGameMap.java index 29745eb..d7e1efe 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/CrossGameMap.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/CrossGameMap.java @@ -15,9 +15,8 @@ public class CrossGameMap extends LoadedGameMap { private String teamRight = ""; private String teamBefore = ""; - public CrossGameMap(CubeGame game, String mapName, int teamSize, int buildLimit, GenLayout genLayout, - List teamColours) { - super(game, mapName, teamSize, buildLimit, genLayout); + public CrossGameMap(CubeGame game, String mapName, int teamSize, int buildLimit, List teamColours) { + super(game, mapName, teamSize, buildLimit); this.teamColours = teamColours; this.setCurrentTeamColour(this.teamColours.get(0)); } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/DoubleCrossGameMap.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/DoubleCrossGameMap.java index 0367eec..3fe4c20 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/DoubleCrossGameMap.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/DoubleCrossGameMap.java @@ -19,9 +19,8 @@ public class DoubleCrossGameMap extends LoadedGameMap { private String teamAcrossLeft = ""; private String teamAcrossRight = ""; - public DoubleCrossGameMap(CubeGame game,String mapName, int teamSize, int buildLimit, GenLayout genLayout, - List> teamColours) { - super(game, mapName, teamSize, buildLimit, genLayout); + public DoubleCrossGameMap(CubeGame game,String mapName, int teamSize, int buildLimit, List> teamColours) { + super(game, mapName, teamSize, buildLimit); this.teamColours = teamColours; this.setCurrentTeamColour(this.teamColours.get(0).get(0)); } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/SquareGameMap.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/SquareGameMap.java index c779e88..1ca2741 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/SquareGameMap.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/SquareGameMap.java @@ -16,9 +16,8 @@ public class SquareGameMap extends LoadedGameMap { private String teamAcross = ""; private String teamAcrossSide = ""; - public SquareGameMap(CubeGame game,String mapName, int teamSize, int buildLimit, GenLayout genLayout, - List> teamColours) { - super(game, mapName, teamSize, buildLimit, genLayout); + public SquareGameMap(CubeGame game,String mapName, int teamSize, int buildLimit, List> teamColours) { + super(game, mapName, teamSize, buildLimit); this.teamColours = teamColours; this.setCurrentTeamColour(this.teamColours.get(0).get(0)); } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/TriangleEggWarsMap.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/TriangleEggWarsMap.java index 0fe18a6..08a0f77 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/TriangleEggWarsMap.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/TriangleEggWarsMap.java @@ -18,9 +18,8 @@ public class TriangleEggWarsMap extends LoadedGameMap { String teamUpRight = ""; int triangleLocation = -1; - public TriangleEggWarsMap(CubeGame game,String mapName, int teamSize, int buildLimit, GenLayout genLayout, - List> teamColours) { - super(game, mapName, teamSize, buildLimit, genLayout); + public TriangleEggWarsMap(CubeGame game,String mapName, int teamSize, int buildLimit, List> teamColours) { + super(game, mapName, teamSize, buildLimit); this.teamColours = teamColours; this.setCurrentTeamColour(this.teamColours.getFirst().getFirst()); } diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/base/LoadedGameMap.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/base/LoadedGameMap.java index 961cdc2..8a714a2 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/base/LoadedGameMap.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/utils/gamemaps/base/LoadedGameMap.java @@ -15,15 +15,13 @@ public abstract class LoadedGameMap { protected final String mapName; protected final int teamSize; protected final int buildLimit; - protected final @Nullable GenLayout genLayout; protected String currentTeamColour = ""; - public LoadedGameMap(CubeGame game, String mapName, int teamSize, int buildLimit, @Nullable GenLayout genLayout) { + public LoadedGameMap(CubeGame game, String mapName, int teamSize, int buildLimit) { this.game = game; this.mapName = mapName; this.teamSize = teamSize; this.buildLimit = buildLimit; - this.genLayout = genLayout; } protected static Component spaceMaker(int n) { @@ -34,14 +32,6 @@ public int getBuildLimit() { return buildLimit; } - @Nullable - public Component getGenLayoutComponent() { - if (this.genLayout == null) { - return null; - } - return this.genLayout.getLayoutComponent(); - } - public abstract Component getMapLayoutComponent(); public Component getBuildLimitMessage() { diff --git a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/weave/GameMapAPI.java b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/weave/GameMapAPI.java index 9c67b72..445f7f0 100644 --- a/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/weave/GameMapAPI.java +++ b/core/src/main/java/art/ameliah/laby/addons/cubepanion/core/weave/GameMapAPI.java @@ -113,16 +113,7 @@ public CompletableFuture getAllGameMaps() { */ public record GameMap(String game, String unique_name, String map_name, String layout, int team_size, int build_limit, - String colours, Generator[] generators) { - - } - - /** - * Generator - */ - public record Generator(String unique_name, int ordering, String gen_type, String gen_location, - int level, - int count) { + String colours) { }