Let generator be up to the implementation

This commit is contained in:
Jesse Boyd
2016-09-17 16:02:05 +10:00
parent 56227a6d7d
commit 264114332b
18 changed files with 79 additions and 34 deletions

View File

@ -236,6 +236,12 @@ public interface IPlotMain extends ILogger {
*/
void registerWorldEvents();
/**
* Usually HybridGen
* @return Default implementation generator
*/
IndependentPlotGenerator getDefaultGenerator();
/**
* Get the class that will manage player titles.
* @return

View File

@ -157,7 +157,7 @@ public class Area extends SubCommand {
id = null;
}
object.world = split[0];
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null);
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, PS.get().IMP.getDefaultGenerator(), null, null);
PlotArea other = PS.get().getPlotArea(pa.worldname, id);
if (other != null && Objects.equals(pa.id, other.id)) {
C.SETUP_WORLD_TAKEN.send(player, pa.toString());

View File

@ -79,9 +79,10 @@ public class ClassicPlotManager extends SquarePlotManager {
return false;
}
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), region.maxZ);
Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(maxY, 255), region.maxZ);
queue.setCuboid(pos1, pos2, blocks);
}
queue.enqueue();
@ -95,9 +96,10 @@ public class ClassicPlotManager extends SquarePlotManager {
}
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), region.maxZ);
Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(maxY, 255), region.maxZ);
queue.setCuboid(pos1, pos2, blocks);
}
queue.enqueue();
@ -144,10 +146,11 @@ public class ClassicPlotManager extends SquarePlotManager {
Location top = plot.getExtendedTopAbs();
PseudoRandom random = new PseudoRandom();
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
if (!plot.getMerged(0)) {
int z = bottom.getZ();
for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(plotArea.MAX_BUILD_HEIGHT, 255); y++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) {
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
}
}
@ -155,7 +158,7 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.getMerged(3)) {
int x = bottom.getX();
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(plotArea.MAX_BUILD_HEIGHT, 255); y++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) {
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
}
}
@ -164,7 +167,7 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.getMerged(2)) {
int z = top.getZ();
for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(plotArea.MAX_BUILD_HEIGHT, 255); y++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) {
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
}
}
@ -172,15 +175,15 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.getMerged(1)) {
int x = top.getX();
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(plotArea.MAX_BUILD_HEIGHT, 255); y++) {
for (int y = dpw.PLOT_HEIGHT; y <= Math.min(maxY, 255); y++) {
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
}
}
}
if (plot.isBasePlot()) {
for (RegionWrapper region : plot.getRegions()) {
Location pos1 = new Location(plotArea.worldname, region.minX, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), region.minZ);
Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), region.maxZ);
Location pos1 = new Location(plotArea.worldname, region.minX, Math.min(maxY, 255), region.minZ);
Location pos2 = new Location(plotArea.worldname, region.maxX, Math.min(maxY, 255), region.maxZ);
queue.setCuboid(pos1, pos2, blocks);
}
}
@ -286,9 +289,10 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = pos1.getZ() - 2;
int ez = pos2.getZ() + 2;
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
queue.setCuboid(
new Location(plotArea.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1),
new Location(plotArea.worldname, ex, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), ez - 1), PlotBlock.get((short) 0, (byte) 0));
new Location(plotArea.worldname, ex, Math.min(maxY, 255), ez - 1), PlotBlock.get((short) 0, (byte) 0));
queue.setCuboid(new Location(plotArea.worldname, sx, 0, sz + 1),
new Location(plotArea.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7,
(byte) 0));
@ -318,9 +322,10 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 2;
int ex = pos2.getX() + 2;
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
queue.setCuboid(
new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotArea.worldname, ex - 1, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), ez), PlotBlock.get((short) 0, (byte) 0));
new Location(plotArea.worldname, ex - 1, Math.min(maxY, 255), ez), PlotBlock.get((short) 0, (byte) 0));
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz),
new Location(plotArea.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0));
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz),
@ -369,8 +374,9 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = pos1.getZ() - 1;
int ez = pos2.getZ() + 1;
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
queue.setCuboid(new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotArea.worldname, ex, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), ez), PlotBlock.get((short) 0, (byte) 0));
new Location(plotArea.worldname, ex, Math.min(maxY, 255), ez), PlotBlock.get((short) 0, (byte) 0));
queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz + 1),
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
@ -389,8 +395,9 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 1;
int ex = pos2.getX() + 1;
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
queue.setCuboid(new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotArea.worldname, ex, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), ez), PlotBlock.get((short) 0, (byte) 0));
new Location(plotArea.worldname, ex, Math.min(maxY, 255), ez), PlotBlock.get((short) 0, (byte) 0));
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz),
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),

View File

@ -247,7 +247,7 @@ public class HybridGen extends IndependentPlotGenerator {
@Override
public PlotManager getNewPlotManager() {
return new HybridPlotManager();
return new HybridPlotManager();
}
@Override

View File

@ -61,7 +61,7 @@ public class HybridPlotManager extends ClassicPlotManager {
Location bot = getPlotBottomLocAbs(hpw, id2);
Location top = getPlotTopLocAbs(hpw, id);
Location pos1 = new Location(plotArea.worldname, top.getX() + 1, 0, bot.getZ() - 1);
Location pos2 = new Location(plotArea.worldname, bot.getX(), Math.min(plotArea.MAX_BUILD_HEIGHT, 255), top.getZ() + 1);
Location pos2 = new Location(plotArea.worldname, bot.getX(), Math.min(getWorldHeight(), 255), top.getZ() + 1);
MainUtil.resetBiome(plotArea, pos1, pos2);
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
return true;
@ -108,7 +108,7 @@ public class HybridPlotManager extends ClassicPlotManager {
Location bot = getPlotBottomLocAbs(hpw, id2);
Location top = getPlotTopLocAbs(hpw, id);
Location pos1 = new Location(plotArea.worldname, bot.getX() - 1, 0, top.getZ() + 1);
Location pos2 = new Location(plotArea.worldname, top.getX() + 1, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), bot.getZ());
Location pos2 = new Location(plotArea.worldname, top.getX() + 1, Math.min(getWorldHeight(), 255), bot.getZ());
MainUtil.resetBiome(plotArea, pos1, pos2);
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
return true;
@ -128,7 +128,7 @@ public class HybridPlotManager extends ClassicPlotManager {
Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
Location pos2 = getPlotBottomLocAbs(hpw, id2);
pos1.setY(0);
pos2.setY(Math.min(plotArea.MAX_BUILD_HEIGHT, 255));
pos2.setY(Math.min(getWorldHeight(), 255));
LocalBlockQueue queue = hpw.getQueue(false);
createSchemAbs(hpw, queue, pos1, pos2, true);
if (hpw.ROAD_SCHEMATIC_ENABLED) {
@ -189,7 +189,7 @@ public class HybridPlotManager extends ClassicPlotManager {
top.setY(dpw.PLOT_HEIGHT + 1);
queue.setCuboid(bot, top, plotfloor);
bot.setY(dpw.PLOT_HEIGHT + 1);
top.setY(plotArea.MAX_BUILD_HEIGHT);
top.setY(getWorldHeight());
queue.setCuboid(bot, top, air);
// And finally set the schematic, the y value is unimportant for this function
pastePlotSchematic(dpw, queue, bot, top);

View File

@ -47,7 +47,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
int pz = plotId.y;
int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
return new Location(plotArea.worldname, x, Math.min(plotArea.MAX_BUILD_HEIGHT, 255), z);
return new Location(plotArea.worldname, x, Math.min(getWorldHeight(), 255), z);
}
@Override

View File

@ -73,4 +73,8 @@ public abstract class PlotManager {
Template.zipAll(plotArea.worldname, files);
}
public int getWorldHeight() {
return 255;
}
}