like the todo from cinna said.
|
public static boolean hasContinentView() { |
|
// TODO: make this run async |
|
return Arrays.stream(Continent.values()).map(continent -> DataProvider.COUNTRY.getCountriesByContinent(continent).size()).filter(count -> count > 0).count() > 1; |
|
} |
|
|
|
/** |
|
* Determine what menu to open for the player |
|
* |
|
* @param player player to open the menu for |
|
*/ |
|
public static void open(Player player) { |
|
if (hasContinentView()) { |
|
new ContinentMenu(player); |
|
} else { |
|
// TODO: make this run async |
|
Optional<Continent> continent = Arrays.stream(Continent.values()).filter(c -> !DataProvider.COUNTRY.getCountriesByContinent(c).isEmpty()).findFirst(); |
|
|
|
if (continent.isEmpty()) { |
|
player.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(player, LangPaths.Message.Error.ERROR_OCCURRED))); |
|
return; |
|
} |
|
|
|
new CountryMenu(player, continent.get()); |
|
} |
|
} |
like the todo from cinna said.
Plot-System/src/main/java/com/alpsbte/plotsystem/core/menus/companion/CompanionMenu.java
Lines 48 to 72 in 57b021e