Merge branch 'v7' into feature/v7/new-generation-api

# Conflicts:
#	Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java
This commit is contained in:
dordsor21 2022-06-11 14:12:32 +01:00
commit 666a60a1c7
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
5 changed files with 42 additions and 11 deletions

View File

@ -27,14 +27,12 @@ body:
description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
multiple: false
options:
- '1.19'
- '1.18.2'
- '1.18.1'
- '1.18'
- '1.17.1'
- '1.16.5'
- '1.15.2'
- '1.14.4'
- '1.13.2'
validations:
required: true

View File

@ -150,7 +150,11 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
}
// Extracted to synchronized method for thread-safety, preventing multiple internal world load calls
private synchronized void checkLoaded(World world) {
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);
@ -172,11 +176,11 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
}
@SuppressWarnings("deprecation") // Kept for compatibility with <=1.17.1
private void setSpawnLimits(World world, int spawnLimit) {
world.setAmbientSpawnLimit(spawnLimit);
world.setAnimalSpawnLimit(spawnLimit);
world.setMonsterSpawnLimit(spawnLimit);
world.setWaterAnimalSpawnLimit(spawnLimit);
private void setSpawnLimits(@NonNull World world, int limit) {
world.setAmbientSpawnLimit(limit);
world.setAnimalSpawnLimit(limit);
world.setMonsterSpawnLimit(limit);
world.setWaterAnimalSpawnLimit(limit);
}
@Override
@ -323,6 +327,11 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
}
private void generate(BlockVector2 loc, String world, ZeroedDelegateScopedQueueCoordinator result, boolean biomes) {
if (!this.loaded) {
synchronized (this) {
PlotSquared.get().loadWorld(world, this);
}
}
// Process the chunk
if (ChunkManager.preProcessChunk(loc, result)) {
return;

View File

@ -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);
}
}

View File

@ -72,7 +72,10 @@ import com.plotsquared.core.util.ReflectionUtils;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.uuid.UUIDPipeline;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.util.eventbus.EventHandler;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@ -153,6 +156,8 @@ public class PlotSquared {
private EventDispatcher eventDispatcher;
private PlotListener plotListener;
private boolean weInitialised;
/**
* Initialize PlotSquared with the desired Implementation class.
*
@ -223,6 +228,7 @@ public class PlotSquared {
}
this.worldedit = WorldEdit.getInstance();
WorldEdit.getInstance().getEventBus().register(new WEPlatformReadyListener());
// Create Event utility class
this.eventDispatcher = new EventDispatcher(this.worldedit);
@ -1576,6 +1582,13 @@ public class PlotSquared {
return this.plotListener;
}
/**
* Get if the {@link PlatformReadyEvent} has been sent by WE. There is no way to query this within WE itself.
*/
public boolean isWeInitialised() {
return weInitialised;
}
/**
* Different ways of sorting {@link Plot plots}
*/
@ -1598,4 +1611,15 @@ public class PlotSquared {
DISTANCE_FROM_ORIGIN
}
private final class WEPlatformReadyListener {
@SuppressWarnings("unused")
@Subscribe(priority = EventHandler.Priority.VERY_EARLY)
public void onPlatformReady(PlatformReadyEvent event) {
weInitialised = true;
WorldEdit.getInstance().getEventBus().unregister(WEPlatformReadyListener.this);
}
}
}

View File

@ -66,7 +66,7 @@ subprojects {
}
dependencies {
implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.2"))
implementation(platform("com.intellectualsites.bom:bom-newest:1.5"))
}
}