mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Pass the PlotArea into the PlotManager
This commit is contained in:
parent
908a5784a1
commit
6b3960fc3f
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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<FileBytes> files = Sets.newHashSet(
|
||||
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea)));
|
||||
|
@ -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.
|
||||
|
@ -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<RegionWrapper> regions = plot.getRegions();
|
||||
|
@ -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) {
|
||||
|
@ -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).
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user