From 173b2a03b490d543ba95950f03f655e995392000 Mon Sep 17 00:00:00 2001 From: Tanja Herche Date: Sun, 5 Feb 2023 21:45:47 +0100 Subject: [PATCH] Changed traveloptions Strand --- src/main/java/org/bitbiome/classes/TravelEngine.java | 8 ++++++++ .../java/org/bitbiome/commands/TravelCommand.java | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index 2bc81cb..06b2140 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -52,6 +52,14 @@ public class TravelEngine { } return found; } + public boolean locationExistsStrand(String name) { + boolean found = false; + for (int i = 0; i < locations.length(); i++) + if (locations.getJSONObject(5).getString("name").equals(name) | locations.getJSONObject(0).getString("name").equals(name)) { + found = true; + } + return found; + } public Location getLocationByName(String name) { JsonParser jp = new JsonParser(); diff --git a/src/main/java/org/bitbiome/commands/TravelCommand.java b/src/main/java/org/bitbiome/commands/TravelCommand.java index eeb452a..abd132b 100644 --- a/src/main/java/org/bitbiome/commands/TravelCommand.java +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -29,6 +29,17 @@ public class TravelCommand implements CommandAPI { System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET); } + } else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Strand")) { + System.out.println("- " + locations.getJSONObject(5).getString("name") + "\n" + "- " + locations.getJSONObject(0).getString("name")); + + String locationName = scanner.nextLine(); + if (travelEngine.locationExistsStrand(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 { + 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"));