diff --git a/src/main/java/org/bitbiome/commands/TravelCommand.java b/src/main/java/org/bitbiome/commands/TravelCommand.java index 7df3aa3..0674010 100644 --- a/src/main/java/org/bitbiome/commands/TravelCommand.java +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -25,7 +25,7 @@ public class TravelCommand implements CommandAPI { public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad gezückt. Wohin möchtest du reisen?" + Colors.ANSI_RESET); JSONArray locations = travelEngine.getLocationList(); - String locationName; + String locationName = ""; String locationWueste = locations.getJSONObject(5).getString("name"); String locationGruenland = locations.getJSONObject(4).getString("name"); String locationWinterland = locations.getJSONObject(2).getString("name"); @@ -36,10 +36,7 @@ public class TravelCommand implements CommandAPI { System.out.println("- " + locationStrand + "\n" + "- " + locationGruenland + "\n" + "- " + locationBerge); locationName = scanner.nextLine(); - if (travelEngine.locationExistsWald(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 { + if (!travelEngine.locationExistsWald(locationName)) { exittravelCommand(); return; } @@ -48,10 +45,7 @@ public class TravelCommand implements CommandAPI { System.out.println("- " + locationWueste + "\n" + "- " + locationWald); 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 { + if (!travelEngine.locationExistsStrand(locationName)) { exittravelCommand(); return; } @@ -60,10 +54,7 @@ public class TravelCommand implements CommandAPI { System.out.println("- " + locationWueste + "\n" + "- " + locationWald + "\n" + "- " + locationWinterland); locationName = scanner.nextLine(); - if (travelEngine.locationExistsGruenland(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 { + if (!travelEngine.locationExistsGruenland(locationName)) { exittravelCommand(); return; } @@ -72,10 +63,7 @@ public class TravelCommand implements CommandAPI { System.out.println("- " + locationWald + "\n" + "- " + locationWinterland); locationName = scanner.nextLine(); - if (travelEngine.locationExistsBerge(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 { + if (!travelEngine.locationExistsBerge(locationName)) { exittravelCommand(); return; } @@ -84,10 +72,7 @@ public class TravelCommand implements CommandAPI { System.out.println("- " + locationGruenland + "\n" + "- " + locationBerge); 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 { + if (!travelEngine.locationExistsWinterland(locationName)) { exittravelCommand(); return; } @@ -96,13 +81,11 @@ public class TravelCommand implements CommandAPI { System.out.println("- " + locationStrand + "\n" + "- " + locationGruenland); locationName = scanner.nextLine(); - 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 { + if (!travelEngine.locationExistsWueste(locationName)) { exittravelCommand(); return; } - } + } 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); } }