From 732f79bbfccd738c110e26ba14e076c1860c3cf1 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 7 Sep 2021 14:47:37 +0100 Subject: [PATCH] Fix #3231 --- .../main/java/com/plotsquared/bukkit/BukkitPlatform.java | 3 +++ .../com/plotsquared/bukkit/util/BukkitSetupUtils.java | 8 ++++---- .../main/java/com/plotsquared/bukkit/util/SetGenCB.java | 2 +- .../src/main/java/com/plotsquared/core/command/Setup.java | 2 +- .../main/java/com/plotsquared/core/util/SetupUtils.java | 6 +++++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 03b13ea02..44f2b8893 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -419,6 +419,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl }, TaskTime.ticks(1L)); } + // Once the server has loaded force updating all generators known to P2 + TaskManager.runTaskLater(() -> PlotSquared.platform().setupUtils().updateGenerators(true), TaskTime.ticks(1L)); + // Services are accessed in order final CacheUUIDService cacheUUIDService = new CacheUUIDService(Settings.UUID.UUID_CACHE_SIZE); this.impromptuPipeline.registerService(cacheUUIDService); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java index 03c8da626..84822c6c9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java @@ -75,8 +75,8 @@ public class BukkitSetupUtils extends SetupUtils { } @Override - public void updateGenerators() { - if (!SetupUtils.generators.isEmpty()) { + public void updateGenerators(final boolean force) { + if (!SetupUtils.generators.isEmpty() && !force) { return; } String testWorld = "CheckingPlotSquaredGenerator"; @@ -128,7 +128,7 @@ public class BukkitSetupUtils extends SetupUtils { @Override public String setupWorld(PlotAreaBuilder builder) { - this.updateGenerators(); + this.updateGenerators(false); ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ? new ConfigurationNode[0] : builder.settingsNodesWrapper().getSettingsNodes(); String world = builder.worldName(); @@ -240,7 +240,7 @@ public class BukkitSetupUtils extends SetupUtils { @Override public String getGenerator(PlotArea plotArea) { if (SetupUtils.generators.isEmpty()) { - updateGenerators(); + updateGenerators(false); } World world = Bukkit.getWorld(plotArea.getWorldName()); if (world == null) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java index adee15e8c..1a2a56045 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java @@ -38,7 +38,7 @@ import java.util.ArrayList; public class SetGenCB { public static void setGenerator(World world) throws Exception { - PlotSquared.platform().setupUtils().updateGenerators(); + PlotSquared.platform().setupUtils().updateGenerators(false); PlotSquared.get().removePlotAreas(world.getName()); ChunkGenerator gen = world.getGenerator(); if (gen == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Setup.java b/Core/src/main/java/com/plotsquared/core/command/Setup.java index a0e6f9116..41267bf2f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Setup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Setup.java @@ -91,7 +91,7 @@ public class Setup extends SubCommand { } process = new SetupProcess(); metaDataAccess.set(process); - this.setupUtils.updateGenerators(); + this.setupUtils.updateGenerators(false); SetupStep step = process.getCurrentStep(); step.announce(player); displayGenerators(player); diff --git a/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java b/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java index e543f1673..7696aed8b 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java +++ b/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java @@ -34,8 +34,12 @@ import java.util.HashMap; public abstract class SetupUtils { public static HashMap> generators = new HashMap<>(); +// static { +// generators.put(PlotSquared.platform().pluginName(), +// (HybridGen) PlotSquared.platform().injector().getInstance(IndependentPlotGenerator.class)); +// } - public abstract void updateGenerators(); + public abstract void updateGenerators(final boolean force); public abstract String getGenerator(final PlotArea plotArea);