From 3c75b170f029dcec926486de0cef9c98feb52ac1 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 10 Jun 2022 01:27:39 +0200 Subject: [PATCH 1/3] fix: mob cap counting for each connected plot individually (#3643) cap meta is now handled in the base plot --- .../com/plotsquared/bukkit/listener/EntityEventListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java index bd4c485f4..b8a052bc5 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java @@ -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); } } From cc7e17960b6d8fa29598ea796de5c8b20b5d5cad Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Fri, 10 Jun 2022 13:42:09 +0200 Subject: [PATCH 2/3] docs: Add 1.19 to issue template --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5b294ea27..ce357a5ab 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -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 From bf646be482445a015d79e35d95606b40d1cbac41 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 10 Jun 2022 15:52:17 +0100 Subject: [PATCH 3/3] Only load world cofigurations if WorldEdit has fully enabled (safe to do) (#3666) * Only load world cofigurations if WorldEdit has fully enabled (safe to do) - Fixes #3664 (cherry picked from commit f2e1e99be3b4f1fd5ce00e32ea7773dd4d1855aa) * Fix imports * QueryCapability is effectively a "dumb" method * Update Core/src/main/java/com/plotsquared/core/PlotSquared.java Co-authored-by: Alexander Brandes --- .../bukkit/generator/BukkitPlotGenerator.java | 62 +++++++++++-------- .../com/plotsquared/core/PlotSquared.java | 24 +++++++ 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index baaf95dfc..7b7cbd2c3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -112,30 +112,7 @@ public class BukkitPlotGenerator extends ChunkGenerator @Override public @NonNull List getDefaultPopulators(@NonNull World world) { try { - if (!this.loaded) { - String name = world.getName(); - PlotSquared.get().loadWorld(name, this); - final Set 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 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)) { diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 9c9bb09f3..03b526e72 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -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); @@ -1574,6 +1580,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} */ @@ -1596,4 +1609,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); + } + + } + }