From a5731d94be2606ea9cce79e7c542000179d5dec2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Feb 2015 00:20:41 +1100 Subject: [PATCH] mostly done --- .../intellectualcrafters/plot/BukkitMain.java | 18 +++++++++++++++++- .../intellectualcrafters/plot/IPlotMain.java | 9 ++++++++- .../intellectualcrafters/plot/PlotSquared.java | 9 ++++++++- .../plot/generator/HybridUtils.java | 2 +- .../plot/listeners/PlayerEvents.java | 5 +++-- .../plot/util/BlockManager.java | 2 +- .../plot/util/ExpireManager.java | 2 +- .../plot/util/SetupUtils.java | 2 +- 8 files changed, 40 insertions(+), 9 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 9ca66e3e7..1d5b63dea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -29,7 +29,9 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.PlotMeConverter; import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.listeners.ForceFieldListener; import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.PlayerEvents; @@ -37,9 +39,12 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.Metrics; @@ -265,7 +270,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } @Override - public void initSetBlockManager() { + public BlockManager initBlockManager() { if (checkVersion(1, 8, 0)) { try { SetBlockManager.setBlockManager = new SetBlockFast_1_8(); @@ -286,6 +291,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } catch (final Throwable e) { MainUtil.canSendChunk = false; } + return BlockManager.manager = new BukkitUtil(); } @Override @@ -321,4 +327,14 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } return true; } + + @Override + public HybridUtils initHybridUtils() { + return new BukkitHybridUtils(); + } + + @Override + public SetupUtils initSetupUtils() { + return new BukkitSetupUtils(); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index dba352914..76c59e5ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -4,7 +4,10 @@ import java.io.File; import net.milkbowl.vault.economy.Economy; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; public interface IPlotMain { @@ -34,7 +37,11 @@ public interface IPlotMain { public Economy getEconomy(); - public void initSetBlockManager(); + public BlockManager initBlockManager(); + + public SetupUtils initSetupUtils(); + + public HybridUtils initHybridUtils(); public boolean initPlotMeConverter(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index bb84e0258..ed5d96fd1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.ClassicPlotWorld; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridPlotWorld; +import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; @@ -48,9 +49,11 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.Logger; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; @@ -434,8 +437,12 @@ public class PlotSquared { IMP.registerPlotPlusEvents(); IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); + // create Hybrid utility class + HybridUtils.manager = IMP.initHybridUtils(); + // create setup util class + SetupUtils.manager = IMP.initSetupUtils(); // Set block - IMP.initSetBlockManager(); + BlockManager.manager = IMP.initBlockManager(); // PlotMe TaskManager.runTaskLater(new Runnable() { @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index e206b7439..2ba65f1c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -19,7 +19,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class HybridUtils { - public static HybridUtils manager = new BukkitHybridUtils(); + public static HybridUtils manager; public boolean checkModified(final Plot plot, int requiredChanges) { final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 717c66c97..4e9fa59ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -101,6 +101,7 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -752,8 +753,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onLeave(final PlayerQuitEvent event) { String name = event.getPlayer().getName(); - if (Setup.setupMap.containsKey(name)) { - Setup.setupMap.remove(name); + if (SetupUtils.setupMap.containsKey(name)) { + SetupUtils.setupMap.remove(name); } BukkitUtil.removePlayer(name); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index db169b370..500cc2a88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class BlockManager { - public static BlockManager manager = new BukkitUtil(); + public static BlockManager manager; private static long state = 1; public static long nextLong() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index a7026c09f..0efd9348f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -109,7 +109,7 @@ public class ExpireManager { } final PlotManager manager = PlotSquared.getPlotManager(world); if (plot.settings.isMerged()) { - Unlink.unlinkPlot(Bukkit.getWorld(world), plot); + Unlink.unlinkPlot(plot); } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.clearPlot(plotworld, plot, false, null); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index 54d491ec6..06456b903 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -9,7 +9,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; public abstract class SetupUtils { - public static SetupUtils manager = new BukkitSetupUtils(); + public static SetupUtils manager; public final static Map setupMap = new HashMap<>(); public static HashMap generators = new HashMap<>();