Search in sources :

Example 1 with SquarePlotWorld

use of com.plotsquared.core.generator.SquarePlotWorld in project PlotSquared by IntellectualSites.

the class PlotModificationManager method setBiome.

/**
 * Sets the biome for a plot asynchronously.
 *
 * @param biome    The biome e.g. "forest"
 * @param whenDone The task to run when finished, or null
 */
public void setBiome(@Nullable final BiomeType biome, @NonNull final Runnable whenDone) {
    final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.plot.getRegions());
    final int extendBiome;
    if (this.plot.getArea() instanceof SquarePlotWorld) {
        extendBiome = (((SquarePlotWorld) this.plot.getArea()).ROAD_WIDTH > 0) ? 1 : 0;
    } else {
        extendBiome = 0;
    }
    Runnable run = new Runnable() {

        @Override
        public void run() {
            if (regions.isEmpty()) {
                TaskManager.runTask(whenDone);
                return;
            }
            CuboidRegion region = regions.poll();
            PlotSquared.platform().regionManager().setBiome(region, extendBiome, biome, plot.getArea(), this);
        }
    };
    run.run();
}
Also used : SquarePlotWorld(com.plotsquared.core.generator.SquarePlotWorld) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) ArrayDeque(java.util.ArrayDeque)

Aggregations

SquarePlotWorld (com.plotsquared.core.generator.SquarePlotWorld)1 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 ArrayDeque (java.util.ArrayDeque)1