diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/DelegatePlotGenerator.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/DelegatePlotGenerator.java index 762e809af..f07c65cbf 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/DelegatePlotGenerator.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/DelegatePlotGenerator.java @@ -30,8 +30,8 @@ import java.util.Random; @Override public void initialize(PlotArea area) { } - @Override public PlotManager getNewPlotManager() { - return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotManager(); + @Override public PlotManager getNewPlotManager(PlotArea plotArea) { + return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotManager(plotArea); } @Override public String getName() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java index a5d63d49b..e3164427c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java @@ -1086,7 +1086,7 @@ import java.util.zip.ZipInputStream; } // Conventional plot generator PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null); - PlotManager plotManager = plotGenerator.getNewPlotManager(); + PlotManager plotManager = plotGenerator.getNewPlotManager(plotArea); PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'"); PlotSquared .log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java index 2ae0ca358..86836447b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java @@ -13,8 +13,19 @@ import java.util.List; */ public class ClassicPlotManager extends SquarePlotManager { + private final ClassicPlotWorld classicPlotWorld; + + public ClassicPlotManager(PlotArea plotArea) { + super(plotArea); + if (plotArea instanceof ClassicPlotWorld){ + classicPlotWorld = (ClassicPlotWorld)plotArea; + } else { + throw new RuntimeException("ClassicPlotManager requires plotArea to be an instance of ClassicPlotWorld"); + } + } + @Override public boolean setComponent(PlotArea plotArea, PlotId plotId, String component, - BlockBucket blocks) { + BlockBucket blocks) { switch (component) { case "floor": setFloor(plotArea, plotId, blocks); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/GridPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/GridPlotManager.java index 4ea841c3c..a0ed41226 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/GridPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/GridPlotManager.java @@ -1,10 +1,13 @@ package com.github.intellectualsites.plotsquared.plot.generator; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotManager; /** * A plot manager where plots tessellate in a grid formation symmetrical about x=z. */ public abstract class GridPlotManager extends PlotManager { - + public GridPlotManager(PlotArea plotArea) { + super(plotArea); + } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java index 66a32db4c..8d34f5d25 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridGen.java @@ -253,8 +253,8 @@ public class HybridGen extends IndependentPlotGenerator { return new HybridPlotWorld(world, id, this, min, max); } - @Override public PlotManager getNewPlotManager() { - return new HybridPlotManager(); + @Override public PlotManager getNewPlotManager(PlotArea plotArea) { + return new HybridPlotManager(plotArea); } @Override public void initialize(PlotArea area) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java index 9f77e56f7..f3b6f6fe3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java @@ -21,6 +21,17 @@ public class HybridPlotManager extends ClassicPlotManager { public static boolean REGENERATIVE_CLEAR = true; + private final HybridPlotWorld hybridPlotWorld; + + public HybridPlotManager(PlotArea plotArea) { + super(plotArea); + if (plotArea instanceof HybridPlotWorld){ + hybridPlotWorld = (HybridPlotWorld)plotArea; + } else { + throw new RuntimeException("HybridPlotManager requires plotArea to be an instance of HybridPlotWorld"); + } + } + @Override public void exportTemplate(PlotArea plotArea) throws IOException { HashSet files = Sets.newHashSet( new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea))); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/IndependentPlotGenerator.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/IndependentPlotGenerator.java index e06d7208e..44703be52 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/IndependentPlotGenerator.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/IndependentPlotGenerator.java @@ -53,8 +53,9 @@ public abstract class IndependentPlotGenerator { * Return a new PlotManager object. * * @return + * @param plotArea */ - public abstract PlotManager getNewPlotManager(); + public abstract PlotManager getNewPlotManager(PlotArea plotArea); /** * If any additional setup options need to be changed before world creation. diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java index 5be65a394..f9b2f5437 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/SquarePlotManager.java @@ -14,6 +14,17 @@ import java.util.Iterator; */ public abstract class SquarePlotManager extends GridPlotManager { + private final SquarePlotWorld squarePlotWorld; + + public SquarePlotManager(PlotArea plotArea) { + super(plotArea); + if (plotArea instanceof SquarePlotWorld){ + squarePlotWorld = (SquarePlotWorld)plotArea; + } else { + throw new RuntimeException("SquarePlotManager requires plotArea to be an instance of SquarePlotWorld"); + } + } + @Override public boolean clearPlot(PlotArea plotArea, final Plot plot, final Runnable whenDone) { final HashSet regions = plot.getRegions(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java index 785b20e1e..25b22c1bf 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java @@ -81,7 +81,7 @@ public abstract class PlotArea { @Nullable final PlotId max) { this.worldname = worldName; this.id = id; - this.manager = generator.getNewPlotManager(); + this.manager = generator.getNewPlotManager(this); this.generator = generator; if (min == null || max == null) { if (min != max) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java index 7dc4185c8..32a1e0423 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java @@ -10,6 +10,13 @@ import java.util.List; public abstract class PlotManager { + private final PlotArea plotArea; + + public PlotManager(PlotArea plotArea) { + + this.plotArea = plotArea; + } + /* * Plot locations (methods with Abs in them will not need to consider mega * plots). diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java index 7146a898b..ab8a01078 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotManager.java @@ -10,6 +10,10 @@ import java.io.File; import java.util.List; public class SinglePlotManager extends PlotManager { + public SinglePlotManager(PlotArea plotArea) { + super(plotArea); + } + @Override public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) { return new PlotId(0, 0); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SingleWorldGenerator.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SingleWorldGenerator.java index ba498f971..a821c03a4 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SingleWorldGenerator.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SingleWorldGenerator.java @@ -81,8 +81,8 @@ public class SingleWorldGenerator extends IndependentPlotGenerator { return ((SinglePlotAreaManager) PlotSquared.get().getPlotAreaManager()).getArea(); } - @Override public PlotManager getNewPlotManager() { - return new SinglePlotManager(); + @Override public PlotManager getNewPlotManager(PlotArea plotArea) { + return new SinglePlotManager(plotArea); } @Override public void initialize(PlotArea area) {