Finished coding default world generation classes

Now I just need to do is fix all the errors I created as well as point
the static methods to the newly abstracted ones.
This commit is contained in:
boy0001 2014-10-08 22:23:18 +11:00
parent 101b726319
commit 2aff00c088
4 changed files with 119 additions and 20 deletions

View File

@ -41,7 +41,7 @@ public abstract class PlotManager {
* method)
*/
public abstract boolean setWall(Player player, Plot plot, Block block);
public abstract boolean setWall(Player player, Plot plot, Block block, PlotBlock newBlock);
public abstract boolean setBiome(Player player, Plot plot, Biome biome);

View File

@ -21,6 +21,7 @@ import static com.intellectualcrafters.plot.PlotWorld.WALL_HEIGHT_DEFAULT;
import static com.intellectualcrafters.plot.PlotWorld.MOB_SPAWNING_DEFAULT;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -91,7 +92,6 @@ public class PlotSquaredGen extends ChunkGenerator {
}
public PlotSquaredGen(String world) {
YamlConfiguration config = PlotMain.config;
this.plotworld = new PlotWorld();
Map<String, Object> options = new HashMap<String, Object>();

View File

@ -190,7 +190,7 @@ public class Unlink extends SubCommand {
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, this.wallheight + 1, sz + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, sz), new Location(w, ex, this.wallheight + 2, sz + 1), new short[] { this.w_id }, new short[] { this.w_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, this.wallheight + 1, sz + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, this.wallheight + 1, ez + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, ez), new Location(w, ex, this.wallheight + 2, ez + 1), new short[] { this.w_id }, new short[] { this.w_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });

View File

@ -259,47 +259,146 @@ public class DefaultPlotManager extends PlotManager {
}
@Override
public boolean setWall(Player player, Plot plot, Block block) {
// TODO Auto-generated method stub
public boolean setWall(Player player, Plot plot, Block block, PlotBlock newblock) {
// CURRENTLY NOT IMPLEMENTED
return false;
}
@Override
public boolean setBiome(Player player, Plot plot, Biome biome) {
// TODO Auto-generated method stub
return false;
World world = player.getWorld();
int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1;
int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1;
int bottomZ = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1;
int topZ = PlotHelper.getPlotTopLoc(world, plot.id).getBlockZ() + 1;
for (int x = bottomX; x <= topX; x++) {
for (int z = bottomZ; z <= topZ; z++) {
world.getBlockAt(x, 0, z).setBiome(biome);
}
}
plot.settings.setBiome(biome);
PlotMain.updatePlot(plot);
PlotHelper.refreshPlotChunks(world, plot);
return true;
}
// PLOT MERGING
@Override
public boolean createRoadEast(PlotWorld plotworld, Plot plot) {
// TODO Auto-generated method stub
return false;
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World w = Bukkit.getWorld(plot.world);
Location pos1 = getPlotBottomLocAbs(plotworld, plot);
Location pos2 = getPlotTopLocAbs(plotworld, plot);
int sx = pos2.getBlockX();
int ex = (sx + dpw.ROAD_WIDTH);
int sz = pos1.getBlockZ() - 1;
int ez = pos2.getBlockZ() + 2;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setSimpleCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK);
PlotHelper.setSimpleCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
PlotHelper.setSimpleCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK);
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
return true;
}
@Override
public boolean createRoadSouth(PlotWorld plotworld, Plot plot) {
// TODO Auto-generated method stub
return false;
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World w = Bukkit.getWorld(plot.world);
Location pos1 = getPlotBottomLocAbs(plotworld, plot);
Location pos2 = getPlotTopLocAbs(plotworld, plot);
int sz = pos2.getBlockZ();
int ez = (sz + dpw.ROAD_WIDTH);
int sx = pos1.getBlockX() - 1;
int ex = pos2.getBlockX() + 2;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK);
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK);
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
return true;
}
@Override
public boolean createRoadSouthEast(PlotWorld plotworld, Plot plot) {
// TODO Auto-generated method stub
return false;
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World w = Bukkit.getWorld(plot.world);
Location pos2 = getPlotTopLocAbs(plotworld, plot);
int sx = pos2.getBlockX() + 1;
int ex = (sx + dpw.ROAD_WIDTH) - 1;
int sz = pos2.getBlockZ() + 1;
int ez = (sz + dpw.ROAD_WIDTH) - 1;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
return true;
}
@Override
public boolean removeRoadEast(PlotWorld plotworld, Plot plot) {
// TODO Auto-generated method stub
return false;
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World w = Bukkit.getWorld(plot.world);
Location pos1 = getPlotBottomLocAbs(plotworld, plot);
Location pos2 = getPlotTopLocAbs(plotworld, plot);
int sx = pos2.getBlockX();
int ex = (sx + dpw.ROAD_WIDTH);
int sz = pos1.getBlockZ() - 1;
int ez = pos2.getBlockZ() + 2;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT+1, ez + 1), dpw.TOP_BLOCK);
return true;
}
@Override
public boolean removeRoadSouth(PlotWorld plotworld, Plot plot) {
// TODO Auto-generated method stub
return false;
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World w = Bukkit.getWorld(plot.world);
Location pos1 = getPlotBottomLocAbs(plotworld, plot);
Location pos2 = getPlotTopLocAbs(plotworld, plot);
int sz = pos2.getBlockZ();
int ez = (sz + dpw.ROAD_WIDTH);
int sx = pos1.getBlockX() - 1;
int ex = pos2.getBlockX() + 2;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT+1, ez + 1), dpw.TOP_BLOCK);
return true;
}
@Override
@ -314,11 +413,11 @@ public class DefaultPlotManager extends PlotManager {
int sz = loc.getBlockZ() + 1;
int ez = (sz + dpw.ROAD_WIDTH) - 1;
PlotHelper.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257 + 1, ez + 1), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
PlotHelper.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK);
return false;
return true;
}
/*
@ -343,7 +442,7 @@ public class DefaultPlotManager extends PlotManager {
}
}
}
return false;
return true;
}