mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Merge branch 'v6' into v7
This commit is contained in:
@ -112,30 +112,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
@Override
|
||||
public @NonNull List<BlockPopulator> getDefaultPopulators(@NonNull World world) {
|
||||
try {
|
||||
if (!this.loaded) {
|
||||
String name = world.getName();
|
||||
PlotSquared.get().loadWorld(name, this);
|
||||
final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(name);
|
||||
if (!areas.isEmpty()) {
|
||||
PlotArea area = areas.iterator().next();
|
||||
if (!area.isMobSpawning()) {
|
||||
if (!area.isSpawnEggs()) {
|
||||
world.setSpawnFlags(false, false);
|
||||
}
|
||||
world.setAmbientSpawnLimit(0);
|
||||
world.setAnimalSpawnLimit(0);
|
||||
world.setMonsterSpawnLimit(0);
|
||||
world.setWaterAnimalSpawnLimit(0);
|
||||
} else {
|
||||
world.setSpawnFlags(true, true);
|
||||
world.setAmbientSpawnLimit(-1);
|
||||
world.setAnimalSpawnLimit(-1);
|
||||
world.setMonsterSpawnLimit(-1);
|
||||
world.setWaterAnimalSpawnLimit(-1);
|
||||
}
|
||||
}
|
||||
this.loaded = true;
|
||||
}
|
||||
checkLoaded(world);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -154,6 +131,39 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
private synchronized void checkLoaded(@NonNull World world) {
|
||||
// Do not attempt to load configurations until WorldEdit has a platform ready.
|
||||
if (!PlotSquared.get().isWeInitialised()) {
|
||||
return;
|
||||
}
|
||||
if (!this.loaded) {
|
||||
String name = world.getName();
|
||||
PlotSquared.get().loadWorld(name, this);
|
||||
final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(name);
|
||||
if (!areas.isEmpty()) {
|
||||
PlotArea area = areas.iterator().next();
|
||||
if (!area.isMobSpawning()) {
|
||||
if (!area.isSpawnEggs()) {
|
||||
world.setSpawnFlags(false, false);
|
||||
}
|
||||
setSpawnLimits(world, 0);
|
||||
} else {
|
||||
world.setSpawnFlags(true, true);
|
||||
setSpawnLimits(world, -1);
|
||||
}
|
||||
}
|
||||
this.loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setSpawnLimits(@NonNull World world, int limit) {
|
||||
world.setAmbientSpawnLimit(limit);
|
||||
world.setAnimalSpawnLimit(limit);
|
||||
world.setMonsterSpawnLimit(limit);
|
||||
world.setWaterAnimalSpawnLimit(limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChunkData generateChunkData(
|
||||
@NonNull World world, @NonNull Random random, int x, int z,
|
||||
@ -201,9 +211,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
private void generate(BlockVector2 loc, World world, ScopedQueueCoordinator result) {
|
||||
// Load if improperly loaded
|
||||
if (!this.loaded) {
|
||||
String name = world.getName();
|
||||
PlotSquared.get().loadWorld(name, this);
|
||||
this.loaded = true;
|
||||
checkLoaded(world);
|
||||
}
|
||||
// Process the chunk
|
||||
if (ChunkManager.preProcessChunk(loc, result)) {
|
||||
|
@ -208,7 +208,7 @@ public class EntityEventListener implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (BukkitEntityUtil.checkEntity(entity, plot)) {
|
||||
if (BukkitEntityUtil.checkEntity(entity, plot.getBasePlot(false))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user