mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Secondary world loading
This commit is contained in:
parent
a1af1d1ee3
commit
024aa995f6
@ -20,6 +20,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -31,12 +32,12 @@ import org.bukkit.generator.BlockPopulator;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
|
||||||
public abstract class PlotGenerator extends ChunkGenerator {
|
public abstract class PlotGenerator extends ChunkGenerator {
|
||||||
|
|
||||||
|
private boolean loaded = false;
|
||||||
private short[][] result;
|
private short[][] result;
|
||||||
public int X;
|
public int X;
|
||||||
public int Z;
|
public int Z;
|
||||||
@ -49,6 +50,8 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||||
|
try {
|
||||||
|
if (!loaded) {
|
||||||
PlotSquared.loadWorld(WorldEvents.getName(world), this);
|
PlotSquared.loadWorld(WorldEvents.getName(world), this);
|
||||||
PlotWorld plotworld = PlotSquared.getPlotWorld(WorldEvents.getName(world));
|
PlotWorld plotworld = PlotSquared.getPlotWorld(WorldEvents.getName(world));
|
||||||
if (!plotworld.MOB_SPAWNING) {
|
if (!plotworld.MOB_SPAWNING) {
|
||||||
@ -67,26 +70,34 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
|||||||
world.setMonsterSpawnLimit(-1);
|
world.setMonsterSpawnLimit(-1);
|
||||||
world.setWaterAnimalSpawnLimit(-1);
|
world.setWaterAnimalSpawnLimit(-1);
|
||||||
}
|
}
|
||||||
|
loaded = true;
|
||||||
return (List<BlockPopulator>)(List<?>) getPopulators(WorldEvents.getName(world));
|
return (List<BlockPopulator>)(List<?>) getPopulators(WorldEvents.getName(world));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new ArrayList<BlockPopulator>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid biomes) {
|
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;
|
final int prime = 13;
|
||||||
int h = 1;
|
int h = 1;
|
||||||
h = (prime * h) + cx;
|
h = (prime * h) + cx;
|
||||||
h = (prime * h) + cz;
|
h = (prime * h) + cz;
|
||||||
this.random.state = h;
|
this.random.state = h;
|
||||||
this.result = new short[16][];
|
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.X = cx << 4;
|
||||||
this.Z = cz << 4;
|
this.Z = cz << 4;
|
||||||
if (ChunkManager.FORCE_PASTE) {
|
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 x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
@ -117,6 +128,10 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user