diff --git a/src/main/java/ninjabrainbot/gui/mainwindow/alladvancements/AllAdvancementsPanel.java b/src/main/java/ninjabrainbot/gui/mainwindow/alladvancements/AllAdvancementsPanel.java index 385d767..eaaa2e8 100644 --- a/src/main/java/ninjabrainbot/gui/mainwindow/alladvancements/AllAdvancementsPanel.java +++ b/src/main/java/ninjabrainbot/gui/mainwindow/alladvancements/AllAdvancementsPanel.java @@ -10,6 +10,7 @@ import ninjabrainbot.gui.components.panels.ThemedPanel; import ninjabrainbot.gui.style.StyleManager; import ninjabrainbot.io.preferences.NinjabrainBotPreferences; +import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType; import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsDataState; import ninjabrainbot.model.input.IButtonInputHandler; @@ -31,14 +32,14 @@ public AllAdvancementsPanel(StyleManager styleManager, IButtonInputHandler butto super(styleManager); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(new AllAdvancementsHeader(styleManager)); - add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.strongholdInformation(), strongholdIcon, false, true, true)); - add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.spawnInformation(), shulkerIcon, true, true, true)); - add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.outpostInformation(), outpostIcon, true, true, true)); - add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.monumentInformation(), monumentIcon, true, true, true)); - oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.deepDarkInformation(), deepDarkIcon, true, true, true)); - oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.shulkerTransportInformation(), shulkerTransportIcon, true, true, false)); - oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.cityQueryInformation(), cityQueryIcon, true, true, false)); - oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.generalLocationInformation(), generalLocationIcon, true, false, false)); + add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.Stronghold), strongholdIcon, false, true, true)); + add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.Spawn), shulkerIcon, true, true, true)); + add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.Outpost), outpostIcon, true, true, true)); + add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.Monument), monumentIcon, true, true, true)); + oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.DeepDark), deepDarkIcon, true, true, true)); + oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.ShulkerTransport), shulkerTransportIcon, true, true, false)); + oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.CityQuery), cityQueryIcon, true, true, false)); + oneDotTwentyPlusPanels.add(new StructurePanel(styleManager, buttonInputHandler, allAdvancementsDataState.getStructureInformation(AllAdvancementsStructureType.GeneralLocation), generalLocationIcon, true, false, false)); for (StructurePanel panel : oneDotTwentyPlusPanels) { add(panel); } diff --git a/src/main/java/ninjabrainbot/gui/themeeditor/PreviewAllAdvancementsDataState.java b/src/main/java/ninjabrainbot/gui/themeeditor/PreviewAllAdvancementsDataState.java index 88047e0..0956bb9 100644 --- a/src/main/java/ninjabrainbot/gui/themeeditor/PreviewAllAdvancementsDataState.java +++ b/src/main/java/ninjabrainbot/gui/themeeditor/PreviewAllAdvancementsDataState.java @@ -1,5 +1,6 @@ package ninjabrainbot.gui.themeeditor; +import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType; import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsDataState; import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsPosition; import ninjabrainbot.model.datastate.common.DetachedDomainModel; @@ -25,77 +26,12 @@ public IDataComponent hasEnteredEnd() { } @Override - public IDataComponent spawnPosition() { + public IDataComponent getAllAdvancementsPosition(AllAdvancementsStructureType allAdvancementsStructureType) { return new DataComponent<>("", domainModel); } @Override - public IDataComponent outpostPosition() { - return new DataComponent<>("", domainModel); - } - - @Override - public IDataComponent monumentPosition() { - return new DataComponent<>("", domainModel); - } - - @Override - public IDataComponent deepDarkPosition() { - return new DataComponent<>("", domainModel); - } - - @Override - public IDataComponent cityQueryPosition() { - return new DataComponent<>("", domainModel); - } - - @Override - public IDataComponent shulkerTransportPosition() { - return new DataComponent<>("", domainModel); - } - - @Override - public IDataComponent generalLocationPosition() { - return new DataComponent<>("", domainModel); - } - - @Override - public IDomainModelComponent strongholdInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent spawnInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent outpostInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent monumentInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent deepDarkInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent cityQueryInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent shulkerTransportInformation() { - return new InferredComponent<>(null); - } - - @Override - public IDomainModelComponent generalLocationInformation() { + public IDomainModelComponent getStructureInformation(AllAdvancementsStructureType allAdvancementsStructureType) { return new InferredComponent<>(null); } } diff --git a/src/main/java/ninjabrainbot/io/api/queries/AllAdvancementsQuery.java b/src/main/java/ninjabrainbot/io/api/queries/AllAdvancementsQuery.java index 879ec5f..9369577 100644 --- a/src/main/java/ninjabrainbot/io/api/queries/AllAdvancementsQuery.java +++ b/src/main/java/ninjabrainbot/io/api/queries/AllAdvancementsQuery.java @@ -1,6 +1,7 @@ package ninjabrainbot.io.api.queries; import ninjabrainbot.model.datastate.IDataState; +import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType; import ninjabrainbot.model.datastate.common.StructureInformation; import org.json.JSONObject; @@ -19,10 +20,10 @@ public AllAdvancementsQuery(boolean isPretty) { public String get(IDataState dataState) { JSONObject rootObject = new JSONObject(); rootObject.put("isAllAdvancementsModeEnabled", dataState.allAdvancementsDataState().allAdvancementsModeEnabled().get()); - rootObject.put("strongholdPosition", convertPosition(dataState.allAdvancementsDataState().strongholdInformation().get())); - rootObject.put("spawnPosition", convertPosition(dataState.allAdvancementsDataState().spawnInformation().get())); - rootObject.put("outpostPosition", convertPosition(dataState.allAdvancementsDataState().outpostInformation().get())); - rootObject.put("monumentPosition", convertPosition(dataState.allAdvancementsDataState().monumentInformation().get())); + for (AllAdvancementsStructureType allAdvancementsStructureType : AllAdvancementsStructureType.values()){ + String key = mapAllAdvancementsStructureTypeName(allAdvancementsStructureType); + rootObject.put(key, convertPosition(dataState.allAdvancementsDataState().getStructureInformation(allAdvancementsStructureType).get())); + } return rootObject.toString(isPretty ? 4 : 0); } @@ -43,4 +44,26 @@ private JSONObject convertPosition(StructureInformation structureInformation) { return structurePositionObject; } + private String mapAllAdvancementsStructureTypeName(AllAdvancementsStructureType allAdvancementsStructureType){ + switch (allAdvancementsStructureType){ + case Spawn: + return "spawn"; + case Outpost: + return "outpost"; + case Monument: + return "monument"; + case Stronghold: + return "stronghold"; + case DeepDark: + return "deepDark"; + case CityQuery: + return "cityQuery"; + case ShulkerTransport: + return "shulkerTransport"; + case GeneralLocation: + return "generalLocation"; + } + throw new IllegalArgumentException("Unknown all advancements structure type: " + allAdvancementsStructureType); + } + } diff --git a/src/main/java/ninjabrainbot/model/actions/alladvancements/RemoveStructureAction.java b/src/main/java/ninjabrainbot/model/actions/alladvancements/RemoveStructureAction.java index caea083..e234d14 100644 --- a/src/main/java/ninjabrainbot/model/actions/alladvancements/RemoveStructureAction.java +++ b/src/main/java/ninjabrainbot/model/actions/alladvancements/RemoveStructureAction.java @@ -1,6 +1,7 @@ package ninjabrainbot.model.actions.alladvancements; import ninjabrainbot.model.actions.IAction; +import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType; import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsDataState; import ninjabrainbot.model.datastate.common.StructureInformation; @@ -16,33 +17,11 @@ public RemoveStructureAction(IAllAdvancementsDataState allAdvancementsDataState, @Override public void execute() { - if (allAdvancementsDataState.spawnInformation().get() == structureInformation) { - allAdvancementsDataState.spawnPosition().reset(); - return; - } - if (allAdvancementsDataState.outpostInformation().get() == structureInformation) { - allAdvancementsDataState.outpostPosition().reset(); - return; - } - if (allAdvancementsDataState.monumentInformation().get() == structureInformation) { - allAdvancementsDataState.monumentPosition().reset(); - return; - } - if (allAdvancementsDataState.shulkerTransportInformation().get() == structureInformation) { - allAdvancementsDataState.shulkerTransportPosition().reset(); - return; - } - if (allAdvancementsDataState.deepDarkInformation().get() == structureInformation) { - allAdvancementsDataState.deepDarkPosition().reset(); - return; - } - if (allAdvancementsDataState.cityQueryInformation().get() == structureInformation) { - allAdvancementsDataState.cityQueryPosition().reset(); - return; - } - if (allAdvancementsDataState.generalLocationInformation().get() == structureInformation) { - allAdvancementsDataState.generalLocationPosition().reset(); - return; + for (AllAdvancementsStructureType allAdvancementsStructureType : AllAdvancementsStructureType.values()) { + if (allAdvancementsDataState.getStructureInformation(allAdvancementsStructureType).get() == structureInformation) { + allAdvancementsDataState.getAllAdvancementsPosition(allAdvancementsStructureType).reset(); + return; + } } throw new IllegalArgumentException(String.format("Cannot remove structure position %s because it not present in the data state.", structureInformation)); } diff --git a/src/main/java/ninjabrainbot/model/actions/alladvancements/SetAllAdvancementsGeneralLocationAction.java b/src/main/java/ninjabrainbot/model/actions/alladvancements/SetAllAdvancementsGeneralLocationAction.java index 5f14764..a366bf7 100644 --- a/src/main/java/ninjabrainbot/model/actions/alladvancements/SetAllAdvancementsGeneralLocationAction.java +++ b/src/main/java/ninjabrainbot/model/actions/alladvancements/SetAllAdvancementsGeneralLocationAction.java @@ -2,6 +2,7 @@ import ninjabrainbot.model.actions.IAction; import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsPosition; +import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType; import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsDataState; import ninjabrainbot.model.datastate.endereye.F3IData; @@ -17,6 +18,6 @@ public SetAllAdvancementsGeneralLocationAction(IAllAdvancementsDataState allAdva @Override public void execute() { - allAdvancementsDataState.generalLocationPosition().set(allAdvancementsPosition); + allAdvancementsDataState.getAllAdvancementsPosition(AllAdvancementsStructureType.GeneralLocation).set(allAdvancementsPosition); } } diff --git a/src/main/java/ninjabrainbot/model/actions/alladvancements/TryAddAllAdvancementsStructureAction.java b/src/main/java/ninjabrainbot/model/actions/alladvancements/TryAddAllAdvancementsStructureAction.java index a1d1aef..07231b8 100644 --- a/src/main/java/ninjabrainbot/model/actions/alladvancements/TryAddAllAdvancementsStructureAction.java +++ b/src/main/java/ninjabrainbot/model/actions/alladvancements/TryAddAllAdvancementsStructureAction.java @@ -25,12 +25,12 @@ public TryAddAllAdvancementsStructureAction(IDataState dataState, IDetailedPlaye @Override public void execute() { AllAdvancementsStructureType structureType = getAllAdvancementStructureTypeFromPlayerPosition(playerPosition); - if (structureType == AllAdvancementsStructureType.Unknown) + if (structureType == null) return; IAllAdvancementsPosition structurePosition = getStructurePosition(structureType); - IDataComponent dataComponent = getDataComponentFromStructureType(structureType); + IDataComponent dataComponent = allAdvancementsDataState.getAllAdvancementsPosition(structureType); // Cities can be queried multiple times, so overwrite the position. if (structureType != AllAdvancementsStructureType.CityQuery && dataComponent.get() != null) return; @@ -40,10 +40,10 @@ public void execute() { private AllAdvancementsStructureType getAllAdvancementStructureTypeFromPlayerPosition(IDetailedPlayerPosition t) { if (t.isInNether()) - return AllAdvancementsStructureType.Unknown; + return null; if (t.isInEnd()) - return preferences.oneDotTwentyPlusAA.get() ? AllAdvancementsStructureType.ShulkerTransport : AllAdvancementsStructureType.Unknown; + return preferences.oneDotTwentyPlusAA.get() ? AllAdvancementsStructureType.ShulkerTransport : null; if (Math.abs(t.xInOverworld()) <= 300 && Math.abs(t.zInOverworld()) <= 300 && Math.abs(Math.round(t.yInPlayerDimension()) - t.yInPlayerDimension()) < 0.001) return AllAdvancementsStructureType.Spawn; @@ -100,26 +100,4 @@ private IAllAdvancementsPosition getCityRegionCentre(IDetailedPlayerPosition t) int cityRegionCentreZ = 24 * (int) Math.round((chunkZ - 8) / 24D) + 8; return new AllAdvancementsPosition(cityRegionCentreX * 16 + 8, cityRegionCentreZ * 16 + 8); } - - private IDataComponent getDataComponentFromStructureType(AllAdvancementsStructureType structureType) { - switch (structureType) { - case Spawn: - return allAdvancementsDataState.spawnPosition(); - case Outpost: - return allAdvancementsDataState.outpostPosition(); - case Monument: - return allAdvancementsDataState.monumentPosition(); - case DeepDark: - return allAdvancementsDataState.deepDarkPosition(); - case CityQuery: - return allAdvancementsDataState.cityQueryPosition(); - case ShulkerTransport: - return allAdvancementsDataState.shulkerTransportPosition(); - case GeneralLocation: - return allAdvancementsDataState.generalLocationPosition(); - default: - throw new IllegalArgumentException("Setting of structure type " + structureType + " is not supported."); - } - } - } diff --git a/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsDataState.java b/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsDataState.java index 7e14d23..b7446aa 100644 --- a/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsDataState.java +++ b/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsDataState.java @@ -1,5 +1,7 @@ package ninjabrainbot.model.datastate.alladvancements; +import java.util.HashMap; + import ninjabrainbot.event.DisposeHandler; import ninjabrainbot.event.IDisposable; import ninjabrainbot.event.IObservable; @@ -20,23 +22,10 @@ public class AllAdvancementsDataState implements IAllAdvancementsDataState, IDis private final IEnvironmentState environmentState; private final DataComponent hasEnteredEnd; - private final DataComponent spawnPosition; - private final DataComponent outpostPosition; - private final DataComponent monumentPosition; - private final DataComponent deepDarkPosition; - private final DataComponent cityQueryPosition; - private final DataComponent shulkerTransportPosition; - private final DataComponent generalLocationPosition; + private final HashMap> allAdvancementsPositionDataComponents; private final InferredComponent allAdvancementsModeEnabled; - private final InferredComponent strongholdInformation; - private final InferredComponent spawnInformation; - private final InferredComponent outpostInformation; - private final InferredComponent monumentInformation; - private final InferredComponent deepDarkInformation; - private final InferredComponent cityQueryInformation; - private final InferredComponent shulkerTransportInformation; - private final InferredComponent generalLocationInformation; + private final HashMap> structureInformationInferredComponents; private final DisposeHandler disposeHandler = new DisposeHandler(); @@ -45,35 +34,35 @@ public AllAdvancementsDataState(IDomainModelComponent currentSt this.environmentState = environmentState; hasEnteredEnd = new DataComponent<>("aa_toggle", domainModel, false); - spawnPosition = new DataComponent<>("aa_spawn", domainModel); - outpostPosition = new DataComponent<>("aa_outpost", domainModel); - monumentPosition = new DataComponent<>("aa_monument", domainModel); - deepDarkPosition = new DataComponent<>("aa_deep_dark", domainModel); - cityQueryPosition = new DataComponent<>("aa_city_query", domainModel); - shulkerTransportPosition = new DataComponent<>("aa_shulker_transport", domainModel); - generalLocationPosition = new DataComponent<>("aa_general_location", domainModel); - allAdvancementsModeEnabled = new InferredComponent<>(domainModel, false); - strongholdInformation = new InferredComponent<>(domainModel); - spawnInformation = new InferredComponent<>(domainModel); - outpostInformation = new InferredComponent<>(domainModel); - monumentInformation = new InferredComponent<>(domainModel); - deepDarkInformation = new InferredComponent<>(domainModel); - cityQueryInformation = new InferredComponent<>(domainModel); - shulkerTransportInformation = new InferredComponent<>(domainModel); - generalLocationInformation = new InferredComponent<>(domainModel); + + allAdvancementsPositionDataComponents = new HashMap<>(); + structureInformationInferredComponents = new HashMap<>(); + for (AllAdvancementsStructureType allAdvancementsStructureType : AllAdvancementsStructureType.values()){ + if (allAdvancementsStructureType != AllAdvancementsStructureType.Stronghold) { + IDataComponent dataComponent = addAllAdvancementsPositionDataComponent(allAdvancementsStructureType, domainModel); + InferredComponent inferredComponent = addStructureInformationInferredComponent(allAdvancementsStructureType, domainModel); + disposeHandler.add(createStructureInformationSubscription(dataComponent, inferredComponent)); + } else { + InferredComponent strongholdInformation = addStructureInformationInferredComponent(allAdvancementsStructureType, domainModel); + disposeHandler.add(currentStrongholdPrediction.subscribeInternal(strongholdInformation::set)); + } + } disposeHandler.add(environmentState.allAdvancementsModeEnabled().subscribeInternal(this::updateAllAdvancementsMode)); disposeHandler.add(hasEnteredEnd.subscribeInternal(this::updateAllAdvancementsMode)); - disposeHandler.add(currentStrongholdPrediction.subscribeInternal(strongholdInformation::set)); - - disposeHandler.add(createStructureInformationSubscription(spawnPosition, spawnInformation)); - disposeHandler.add(createStructureInformationSubscription(outpostPosition, outpostInformation)); - disposeHandler.add(createStructureInformationSubscription(monumentPosition, monumentInformation)); - disposeHandler.add(createStructureInformationSubscription(deepDarkPosition, deepDarkInformation)); - disposeHandler.add(createStructureInformationSubscription(cityQueryPosition, cityQueryInformation)); - disposeHandler.add(createStructureInformationSubscription(shulkerTransportPosition, shulkerTransportInformation)); - disposeHandler.add(createStructureInformationSubscription(generalLocationPosition, generalLocationInformation)); + } + + private DataComponent addAllAdvancementsPositionDataComponent(AllAdvancementsStructureType allAdvancementsStructureType, IDomainModel domainModel) { + DataComponent dataComponent = new DataComponent<>("aa_" + allAdvancementsStructureType.name(), domainModel); + allAdvancementsPositionDataComponents.put(allAdvancementsStructureType, dataComponent); + return dataComponent; + } + + private InferredComponent addStructureInformationInferredComponent(AllAdvancementsStructureType allAdvancementsStructureType, IDomainModel domainModel) { + InferredComponent inferredComponent = new InferredComponent<>(domainModel); + structureInformationInferredComponents.put(allAdvancementsStructureType, inferredComponent); + return inferredComponent; } private Subscription createStructureInformationSubscription(IDataComponent allAdvancementsPosition, InferredComponent structureInformation) { @@ -100,78 +89,15 @@ public IDataComponent hasEnteredEnd() { } @Override - public IDataComponent spawnPosition() { - return spawnPosition; - } - - @Override - public IDataComponent outpostPosition() { - return outpostPosition; - } - - @Override - public IDataComponent monumentPosition() { - return monumentPosition; - } - - @Override - public IDataComponent deepDarkPosition() { - return deepDarkPosition; - } - - @Override - public IDataComponent cityQueryPosition() { - return cityQueryPosition; - } - - @Override - public IDataComponent shulkerTransportPosition() { - return shulkerTransportPosition; - } - - @Override - public IDataComponent generalLocationPosition() { - return generalLocationPosition; - } - - @Override - public IDomainModelComponent strongholdInformation() { - return strongholdInformation; - } - - @Override - public IDomainModelComponent spawnInformation() { - return spawnInformation; - } - - @Override - public IDomainModelComponent outpostInformation() { - return outpostInformation; - } - - @Override - public IDomainModelComponent monumentInformation() { - return monumentInformation; - } - - @Override - public IDomainModelComponent deepDarkInformation() { - return deepDarkInformation; - } - - @Override - public IDomainModelComponent cityQueryInformation() { - return cityQueryInformation; - } - - @Override - public IDomainModelComponent shulkerTransportInformation() { - return shulkerTransportInformation; + public IDataComponent getAllAdvancementsPosition(AllAdvancementsStructureType allAdvancementsStructureType) { + if (allAdvancementsStructureType == AllAdvancementsStructureType.Stronghold) + throw new IllegalArgumentException("There is no IDataComponent for AllAdvancementsStructureType.Stronghold"); + return allAdvancementsPositionDataComponents.get(allAdvancementsStructureType); } @Override - public IDomainModelComponent generalLocationInformation() { - return generalLocationInformation; + public IDomainModelComponent getStructureInformation(AllAdvancementsStructureType allAdvancementsStructureType) { + return structureInformationInferredComponents.get(allAdvancementsStructureType); } @Override diff --git a/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsStructureType.java b/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsStructureType.java index 5d86393..7889c31 100644 --- a/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsStructureType.java +++ b/src/main/java/ninjabrainbot/model/datastate/alladvancements/AllAdvancementsStructureType.java @@ -1,5 +1,12 @@ package ninjabrainbot.model.datastate.alladvancements; public enum AllAdvancementsStructureType { - Spawn, Outpost, Monument, Stronghold, DeepDark, CityQuery, ShulkerTransport, GeneralLocation, Unknown + Spawn, + Outpost, + Monument, + Stronghold, + DeepDark, + CityQuery, + ShulkerTransport, + GeneralLocation } diff --git a/src/main/java/ninjabrainbot/model/datastate/alladvancements/IAllAdvancementsDataState.java b/src/main/java/ninjabrainbot/model/datastate/alladvancements/IAllAdvancementsDataState.java index 19e4e6e..9f3b346 100644 --- a/src/main/java/ninjabrainbot/model/datastate/alladvancements/IAllAdvancementsDataState.java +++ b/src/main/java/ninjabrainbot/model/datastate/alladvancements/IAllAdvancementsDataState.java @@ -1,5 +1,7 @@ package ninjabrainbot.model.datastate.alladvancements; +import java.util.Iterator; + import ninjabrainbot.model.datastate.common.StructureInformation; import ninjabrainbot.model.domainmodel.IDataComponent; import ninjabrainbot.model.domainmodel.IDomainModelComponent; @@ -10,34 +12,15 @@ public interface IAllAdvancementsDataState { IDataComponent hasEnteredEnd(); - IDataComponent spawnPosition(); - - IDataComponent outpostPosition(); - - IDataComponent monumentPosition(); - - IDataComponent deepDarkPosition(); - - IDataComponent cityQueryPosition(); - - IDataComponent shulkerTransportPosition(); - - IDataComponent generalLocationPosition(); - - IDomainModelComponent strongholdInformation(); - - IDomainModelComponent spawnInformation(); - - IDomainModelComponent outpostInformation(); - - IDomainModelComponent monumentInformation(); - - IDomainModelComponent deepDarkInformation(); - - IDomainModelComponent cityQueryInformation(); - - IDomainModelComponent shulkerTransportInformation(); + /** + * Returns the IDataComponent corresponding to the given structure type. Throws IllegalArgumentException if + * allAdvancementsStructureType equals Stronghold. + */ + IDataComponent getAllAdvancementsPosition(AllAdvancementsStructureType allAdvancementsStructureType); - IDomainModelComponent generalLocationInformation(); + /** + * Returns the IDomainModelComponent corresponding to the given structure type. + */ + IDomainModelComponent getStructureInformation(AllAdvancementsStructureType allAdvancementsStructureType); } diff --git a/src/test/java/ninjabrainbot/integrationtests/ApiV1IntegrationTests.java b/src/test/java/ninjabrainbot/integrationtests/ApiV1IntegrationTests.java index 5e1c0b3..c81ed79 100644 --- a/src/test/java/ninjabrainbot/integrationtests/ApiV1IntegrationTests.java +++ b/src/test/java/ninjabrainbot/integrationtests/ApiV1IntegrationTests.java @@ -107,31 +107,43 @@ void allAdvancements() throws IOException { // Assert Assertions.assertEquals(HttpURLConnection.HTTP_OK, exchange.getResponseCode()); -// System.out.println(exchange.getResponseBodyAsString()); + System.out.println(exchange.getResponseBodyAsString()); String expectedResult = - ("{" + - " \"spawnPosition\":{" + - " \"overworldDistance\":5007," + - " \"xInOverworld\":-215," + - " \"zInOverworld\":185," + - " \"travelAngle\":137.57282532371786" + - " }," + - " \"monumentPosition\":{" + - " \"overworldDistance\":1," + - " \"xInOverworld\":3357," + - " \"zInOverworld\":3693," + - " \"travelAngle\":179.88264305940854" + - " }," + - " \"strongholdPosition\":{" + - " \"overworldDistance\":4247," + - " \"xInOverworld\":2212," + - " \"zInOverworld\":-396," + - " \"travelAngle\":142.2910279309858" + - " }," + - " \"outpostPosition\":{" + - " " + - " }," + - " \"isAllAdvancementsModeEnabled\":true" + + ("{\n" + + " \"generalLocation\":{\n" + + " \n" + + " },\n" + + " \"spawn\":{\n" + + " \"overworldDistance\":5007,\n" + + " \"xInOverworld\":-215,\n" + + " \"zInOverworld\":185,\n" + + " \"travelAngle\":137.57282532371786\n" + + " },\n" + + " \"cityQuery\":{\n" + + " \n" + + " },\n" + + " \"monument\":{\n" + + " \"overworldDistance\":1,\n" + + " \"xInOverworld\":3357,\n" + + " \"zInOverworld\":3693,\n" + + " \"travelAngle\":179.88264305940854\n" + + " },\n" + + " \"shulkerTransport\":{\n" + + " \n" + + " },\n" + + " \"stronghold\":{\n" + + " \"overworldDistance\":4247,\n" + + " \"xInOverworld\":2212,\n" + + " \"zInOverworld\":-396,\n" + + " \"travelAngle\":142.2910279309858\n" + + " },\n" + + " \"deepDark\":{\n" + + " \n" + + " },\n" + + " \"isAllAdvancementsModeEnabled\":true,\n" + + " \"outpost\":{\n" + + " \n" + + " }\n" + "}").replaceAll("\\s+", ""); Assertions.assertEquals(expectedResult, exchange.getResponseBodyAsString()); }