Browse Source

refactoring: Outsourced System.out.println

remotes/origin/develop
David Hermann 2 years ago
parent
commit
9ebe7ea258
  1. 13
      src/main/java/org/bitbiome/commands/TravelCommand.java

13
src/main/java/org/bitbiome/commands/TravelCommand.java

@ -16,18 +16,23 @@ public class TravelCommand implements CommandAPI {
@Override
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);
print(Colors.ANSI_BLUE + "Du hast dein Travel-Pad gezückt. Wohin möchtest du reisen?" + Colors.ANSI_RESET);
JSONArray locations = travelEngine.getLocationList();
for (int i = 0; i < locations.length(); i++) {
System.out.println("- " + locations.getJSONObject(i).getString("name"));
print("- " + locations.getJSONObject(i).getString("name"));
}
String locationName = scanner.nextLine();
if (travelEngine.locationExists(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
print(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);
print(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
}
}
public String print(String message) {
System.out.println(message);
return message;
}
}
Loading…
Cancel
Save