From a4bb55f061c4fea32d1b9e859544425c55f16cce Mon Sep 17 00:00:00 2001 From: Tanja Herche Date: Sun, 5 Feb 2023 22:18:05 +0100 Subject: [PATCH] Changed traveloptions Wueste --- src/main/java/org/bitbiome/classes/TravelEngine.java | 9 +++++++++ src/main/java/org/bitbiome/commands/TravelCommand.java | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index edfc47d..322fdd6 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -89,6 +89,15 @@ public class TravelEngine { return found; } + public boolean locationExistsWueste(String name) { + boolean found = false; + for (int i = 0; i < locations.length(); i++) + if (locations.getJSONObject(1).getString("name").equals(name) | locations.getJSONObject(4).getString("name").equals(name)) { + found = true; + } + return found; + } + public Location getLocationByName(String name) { JsonParser jp = new JsonParser(); JSONObject gameconfig = jp.getJSONObject("gameconfig.json"); diff --git a/src/main/java/org/bitbiome/commands/TravelCommand.java b/src/main/java/org/bitbiome/commands/TravelCommand.java index f4313bf..fe414c7 100644 --- a/src/main/java/org/bitbiome/commands/TravelCommand.java +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -73,12 +73,11 @@ public class TravelCommand implements CommandAPI { System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET); } - } else { - for (int i = 0; i < locations.length(); i++) { - System.out.println("- " + locations.getJSONObject(i).getString("name")); - } + } else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Wueste")) { + System.out.println("- " + locations.getJSONObject(1).getString("name") + "\n" + "- " + locations.getJSONObject(4).getString("name")); + String locationName = scanner.nextLine(); - if (travelEngine.locationExists(locationName)) { + if (travelEngine.locationExistsWueste(locationName)) { travelEngine.travelTo(new Location(locationName, new ArrayList(), new ArrayList())); System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET); } else {