Skip to content

Make CompanionMenu Database Calls async #195

@Zoriot

Description

@Zoriot

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());
}
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestreworkImprovements and changes of an already existing feature

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions