diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index 51c5cae..edfc47d 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -80,6 +80,15 @@ public class TravelEngine { return found; } + public boolean locationExistsWinterland(String name) { + boolean found = false; + for (int i = 0; i < locations.length(); i++) + if (locations.getJSONObject(4).getString("name").equals(name) | locations.getJSONObject(3).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 1135aa4..f4313bf 100644 --- a/src/main/java/org/bitbiome/commands/TravelCommand.java +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -62,6 +62,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("Winterland")) { + System.out.println("- " + locations.getJSONObject(4).getString("name") + "\n" + "- " + locations.getJSONObject(3).getString("name")); + + String locationName = scanner.nextLine(); + if (travelEngine.locationExistsWinterland(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"));