Secondary world loading

This commit is contained in:
boy0001 2015-05-10 13:17:10 +10:00
parent a1af1d1ee3
commit 024aa995f6

View File

@ -20,6 +20,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
@ -31,12 +32,12 @@ import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.listeners.WorldEvents;
import com.intellectualcrafters.plot.util.ChunkManager;
public abstract class PlotGenerator extends ChunkGenerator {
private boolean loaded = false;
private short[][] result;
public int X;
public int Z;
@ -49,6 +50,8 @@ public abstract class PlotGenerator extends ChunkGenerator {
@SuppressWarnings("unchecked")
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
try {
if (!loaded) {
PlotSquared.loadWorld(WorldEvents.getName(world), this);
PlotWorld plotworld = PlotSquared.getPlotWorld(WorldEvents.getName(world));
if (!plotworld.MOB_SPAWNING) {
@ -67,26 +70,34 @@ public abstract class PlotGenerator extends ChunkGenerator {
world.setMonsterSpawnLimit(-1);
world.setWaterAnimalSpawnLimit(-1);
}
loaded = true;
return (List<BlockPopulator>)(List<?>) getPopulators(WorldEvents.getName(world));
}
}
catch (Exception e) {
e.printStackTrace();
}
return new ArrayList<BlockPopulator>();
}
@Override
public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid biomes) {
try {
if (!loaded) {
PlotSquared.loadWorld(WorldEvents.getName(world), this);
loaded = true;
}
final int prime = 13;
int h = 1;
h = (prime * h) + cx;
h = (prime * h) + cz;
this.random.state = h;
this.result = new short[16][];
PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName());
if (plotworld == null) {
plotworld = getNewPlotWorld(world.getName());
PlotSquared.addPlotWorld(world.getName(), plotworld, getPlotManager());
}
Biome biome = Biome.valueOf(plotworld.PLOT_BIOME);
this.X = cx << 4;
this.Z = cz << 4;
if (ChunkManager.FORCE_PASTE) {
PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName());
Biome biome = Biome.valueOf(plotworld.PLOT_BIOME);
for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) {
if (biomes != null) {
@ -117,6 +128,10 @@ public abstract class PlotGenerator extends ChunkGenerator {
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return result;
}