Search in sources :

Example 1 with WarpCategoryDataNode

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())));
}
Also used : WarpCategoryDataNode(io.github.nucleuspowered.nucleus.configurate.datatypes.WarpCategoryDataNode) LocationDataModule(io.github.nucleuspowered.nucleus.dataservices.modular.LocationDataModule) Location(org.spongepowered.api.world.Location) Collection(java.util.Collection) BiFunction(java.util.function.BiFunction) Vector3d(com.flowpowered.math.vector.Vector3d) WarpCategoryDataNode(io.github.nucleuspowered.nucleus.configurate.datatypes.WarpCategoryDataNode) UUID(java.util.UUID) LocationData(io.github.nucleuspowered.nucleus.internal.LocationData) Maps(com.google.common.collect.Maps) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) Warp(io.github.nucleuspowered.nucleus.api.nucleusdata.Warp) WarpNode(io.github.nucleuspowered.nucleus.configurate.datatypes.WarpNode) TextSerializers(org.spongepowered.api.text.serializer.TextSerializers) Text(org.spongepowered.api.text.Text) WarpCategory(io.github.nucleuspowered.nucleus.api.nucleusdata.WarpCategory) World(org.spongepowered.api.world.World) Map(java.util.Map) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) Util(io.github.nucleuspowered.nucleus.Util) DataKey(io.github.nucleuspowered.nucleus.dataservices.modular.DataKey) Nullable(javax.annotation.Nullable) ModularGeneralService(io.github.nucleuspowered.nucleus.dataservices.modular.ModularGeneralService) TextSerializers(org.spongepowered.api.text.serializer.TextSerializers)

Aggregations

Vector3d (com.flowpowered.math.vector.Vector3d)1 Preconditions (com.google.common.base.Preconditions)1 Maps (com.google.common.collect.Maps)1 Util (io.github.nucleuspowered.nucleus.Util)1 Warp (io.github.nucleuspowered.nucleus.api.nucleusdata.Warp)1 WarpCategory (io.github.nucleuspowered.nucleus.api.nucleusdata.WarpCategory)1 WarpCategoryDataNode (io.github.nucleuspowered.nucleus.configurate.datatypes.WarpCategoryDataNode)1 WarpNode (io.github.nucleuspowered.nucleus.configurate.datatypes.WarpNode)1 DataKey (io.github.nucleuspowered.nucleus.dataservices.modular.DataKey)1 LocationDataModule (io.github.nucleuspowered.nucleus.dataservices.modular.LocationDataModule)1 ModularGeneralService (io.github.nucleuspowered.nucleus.dataservices.modular.ModularGeneralService)1 LocationData (io.github.nucleuspowered.nucleus.internal.LocationData)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 BiFunction (java.util.function.BiFunction)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1