Search in sources :

Example 1 with FileSuffixFilter

use of ivorius.reccomplex.files.loading.FileSuffixFilter in project RecurrentComplex by Ivorforce.

the class CommandRetrogen method existingRegions.

public static Stream<Pair<Integer, Integer>> existingRegions(File worldDir) {
    File regionsDirectory = RCFiles.getValidatedFolder(new File(worldDir, "region"), false);
    if (regionsDirectory == null)
        return Stream.empty();
    String[] mcas = regionsDirectory.list(new FileSuffixFilter("mca"));
    if (mcas == null)
        throw new IllegalStateException();
    return Arrays.stream(mcas).map(s -> s.split("\\.")).filter(// Is region file
    p -> p.length == 4 && p[0].equals("r")).map(p -> Pair.of(Integer.parseInt(p[1]), Integer.parseInt(p[2]))).filter(// Has coords
    rfc -> rfc.getLeft() != null && rfc.getRight() != null);
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) Random(java.util.Random) IvStreams(ivorius.ivtoolkit.util.IvStreams) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) Pair(org.apache.commons.lang3.tuple.Pair) RCFiles(ivorius.reccomplex.files.RCFiles) WorldServer(net.minecraft.world.WorldServer) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) RegionFileCache(net.minecraft.world.chunk.storage.RegionFileCache) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) ChunkPos(net.minecraft.util.math.ChunkPos) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) File(java.io.File) FileSuffixFilter(ivorius.reccomplex.files.loading.FileSuffixFilter) List(java.util.List) Stream(java.util.stream.Stream) ICommandSender(net.minecraft.command.ICommandSender) WorldGenStructures(ivorius.reccomplex.world.gen.feature.WorldGenStructures) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) FileSuffixFilter(ivorius.reccomplex.files.loading.FileSuffixFilter) File(java.io.File)

Aggregations

IvStreams (ivorius.ivtoolkit.util.IvStreams)1 RCConfig (ivorius.reccomplex.RCConfig)1 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)1 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)1 RCFiles (ivorius.reccomplex.files.RCFiles)1 FileSuffixFilter (ivorius.reccomplex.files.loading.FileSuffixFilter)1 ServerTranslations (ivorius.reccomplex.utils.ServerTranslations)1 WorldGenStructures (ivorius.reccomplex.world.gen.feature.WorldGenStructures)1 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)1 File (java.io.File)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Random (java.util.Random)1 Predicate (java.util.function.Predicate)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 CommandBase (net.minecraft.command.CommandBase)1 CommandException (net.minecraft.command.CommandException)1