use of io.github.nucleuspowered.nucleus.configurate.datatypes.WarpCategoryDataNode in project Nucleus by NucleusPowered.
the class WarpGeneralDataModule method getWarpCategory.
public Optional<WarpCategory> getWarpCategory(String category) {
Preconditions.checkArgument(category != null && !category.isEmpty());
if (warps.values().stream().noneMatch(x -> x.getCategory().orElse("").equalsIgnoreCase(category))) {
return Optional.empty();
}
WarpCategoryDataNode w = warpCategories.get(category);
if (w == null) {
w = new WarpCategoryDataNode();
updateOrSetWarpCategory(category.toLowerCase(), null, null);
}
return Optional.of(new WarpCategoryData(category, w.getDisplayName().map(TextSerializers.JSON::deserialize).orElse(Text.of(category)), w.getDescription().map(TextSerializers.JSON::deserialize).orElse(null), () -> getWarps().values().stream().filter(x -> x.getCategory().map(y -> y.equals(category)).orElse(false)).collect(Collectors.toList())));
}
Aggregations