mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
pm
This commit is contained in:
parent
4aeb5f459f
commit
c5260471c5
@ -2,14 +2,12 @@ package com.intellectualcrafters.plot.generator;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,33 +15,97 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
*/
|
*/
|
||||||
public abstract class ClassicPlotManager extends SquarePlotManager {
|
public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||||
@Override
|
@Override
|
||||||
public boolean setComponent(final World world, final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) {
|
public boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) {
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case "floor": {
|
case "floor": {
|
||||||
setFloor(world, plotworld, plotid, blocks);
|
setFloor(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "wall": {
|
case "wall": {
|
||||||
setWallFilling(world, plotworld, plotid, blocks);
|
setWallFilling(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "border": {
|
case "border": {
|
||||||
setWall(world, plotworld, plotid, blocks);
|
setWall(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1);
|
final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1);
|
||||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plotid);
|
final Location pos2 = MainUtil.getPlotTopLoc(plotworld.worldname, plotid);
|
||||||
MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks);
|
int size = (pos2.getX() - pos1.getX() + 1) * (pos2.getZ() - pos1.getZ() + 1);
|
||||||
|
|
||||||
|
pos1.setY(dpw.PLOT_HEIGHT);
|
||||||
|
pos2.setY(dpw.PLOT_HEIGHT + 1);
|
||||||
|
|
||||||
|
MainUtil.setCuboid(plotworld.worldname, pos1, pos2, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setWallFilling(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
public boolean setWallFilling(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||||
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
|
if (dpw.ROAD_WIDTH == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
|
||||||
|
final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid);
|
||||||
|
int x, z;
|
||||||
|
z = bottom.getZ();
|
||||||
|
int length = top.getX() - bottom.getX();
|
||||||
|
int size = (length) * 4 * (dpw.WALL_HEIGHT - 1);
|
||||||
|
final int[] xl = new int[size];
|
||||||
|
final int[] yl = new int[size];
|
||||||
|
final int[] zl = new int[size];
|
||||||
|
final PlotBlock[] bl = new PlotBlock[size];
|
||||||
|
int i = 0;
|
||||||
|
for (x = bottom.getX(); x < (top.getX() + 1); x++) {
|
||||||
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
|
xl[i] = x;
|
||||||
|
zl[i] = z;
|
||||||
|
yl[i] = y;
|
||||||
|
bl[i] = blocks[BlockManager.random(blocks.length)];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x = top.getX() + 1;
|
||||||
|
for (z = bottom.getZ(); z < (top.getZ() + 1); z++) {
|
||||||
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
|
xl[i] = x;
|
||||||
|
zl[i] = z;
|
||||||
|
yl[i] = y;
|
||||||
|
bl[i] = blocks[BlockManager.random(blocks.length)];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
z = top.getZ() + 1;
|
||||||
|
for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) {
|
||||||
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
|
xl[i] = x;
|
||||||
|
zl[i] = z;
|
||||||
|
yl[i] = y;
|
||||||
|
bl[i] = blocks[BlockManager.random(blocks.length)];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x = bottom.getX();
|
||||||
|
for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) {
|
||||||
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
|
xl[i] = x;
|
||||||
|
zl[i] = z;
|
||||||
|
yl[i] = y;
|
||||||
|
bl[i] = blocks[BlockManager.random(blocks.length)];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlockManager.setBlocks(plotworld.worldname, x, y, z, blocks);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setWall(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
if (dpw.ROAD_WIDTH == 0) {
|
if (dpw.ROAD_WIDTH == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -51,55 +113,20 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
|
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
|
||||||
final Location top = MainUtil.getPlotTopLoc(w, plotid);
|
final Location top = MainUtil.getPlotTopLoc(w, plotid);
|
||||||
int x, z;
|
int x, z;
|
||||||
z = bottom.getBlockZ();
|
z = bottom.getZ();
|
||||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
for (x = bottom.getX(); x < (top.getX() + 1); x++) {
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
MainUtil.setBlock(w, x, y, z, blocks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x = top.getBlockX() + 1;
|
|
||||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
MainUtil.setBlock(w, x, y, z, blocks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
z = top.getBlockZ() + 1;
|
|
||||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
MainUtil.setBlock(w, x, y, z, blocks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x = bottom.getBlockX();
|
|
||||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
MainUtil.setBlock(w, x, y, z, blocks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setWall(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
|
||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
|
||||||
if (dpw.ROAD_WIDTH == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
|
|
||||||
final Location top = MainUtil.getPlotTopLoc(w, plotid);
|
|
||||||
int x, z;
|
|
||||||
z = bottom.getBlockZ();
|
|
||||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
|
||||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||||
}
|
}
|
||||||
x = top.getBlockX() + 1;
|
x = top.getX() + 1;
|
||||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
for (z = bottom.getZ(); z < (top.getZ() + 1); z++) {
|
||||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||||
}
|
}
|
||||||
z = top.getBlockZ() + 1;
|
z = top.getZ() + 1;
|
||||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) {
|
||||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||||
}
|
}
|
||||||
x = bottom.getBlockX();
|
x = bottom.getX();
|
||||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) {
|
||||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -114,10 +141,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final World w = Bukkit.getWorld(plot.world);
|
final World w = Bukkit.getWorld(plot.world);
|
||||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||||
final int sx = pos2.getBlockX() + 1;
|
final int sx = pos2.getX() + 1;
|
||||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sz = pos1.getBlockZ() - 1;
|
final int sz = pos1.getZ() - 1;
|
||||||
final int ez = pos2.getBlockZ() + 2;
|
final int ez = pos2.getZ() + 2;
|
||||||
MainUtil.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));
|
MainUtil.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));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0));
|
MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||||
@ -134,10 +161,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final World w = Bukkit.getWorld(plot.world);
|
final World w = Bukkit.getWorld(plot.world);
|
||||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||||
final int sz = pos2.getBlockZ() + 1;
|
final int sz = pos2.getZ() + 1;
|
||||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sx = pos1.getBlockX() - 1;
|
final int sx = pos1.getX() - 1;
|
||||||
final int ex = pos2.getBlockX() + 2;
|
final int ex = pos2.getX() + 2;
|
||||||
MainUtil.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));
|
MainUtil.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));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
||||||
@ -153,9 +180,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final World w = Bukkit.getWorld(plot.world);
|
final World w = Bukkit.getWorld(plot.world);
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||||
final int sx = pos2.getBlockX() + 1;
|
final int sx = pos2.getX() + 1;
|
||||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sz = pos2.getBlockZ() + 1;
|
final int sz = pos2.getZ() + 1;
|
||||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||||
MainUtil.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));
|
MainUtil.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));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
|
MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
|
||||||
@ -169,10 +196,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final World w = Bukkit.getWorld(plot.world);
|
final World w = Bukkit.getWorld(plot.world);
|
||||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||||
final int sx = pos2.getBlockX() + 1;
|
final int sx = pos2.getX() + 1;
|
||||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sz = pos1.getBlockZ();
|
final int sz = pos1.getZ();
|
||||||
final int ez = pos2.getBlockZ() + 1;
|
final int ez = pos2.getZ() + 1;
|
||||||
MainUtil.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));
|
MainUtil.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));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||||
MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
||||||
@ -185,10 +212,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final World w = Bukkit.getWorld(plot.world);
|
final World w = Bukkit.getWorld(plot.world);
|
||||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||||
final int sz = pos2.getBlockZ() + 1;
|
final int sz = pos2.getZ() + 1;
|
||||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sx = pos1.getBlockX();
|
final int sx = pos1.getX();
|
||||||
final int ex = pos2.getBlockX() + 1;
|
final int ex = pos2.getX() + 1;
|
||||||
MainUtil.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));
|
MainUtil.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));
|
||||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||||
MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
||||||
@ -200,9 +227,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final World world = Bukkit.getWorld(plot.world);
|
final World world = Bukkit.getWorld(plot.world);
|
||||||
final Location loc = getPlotTopLocAbs(dpw, plot.id);
|
final Location loc = getPlotTopLocAbs(dpw, plot.id);
|
||||||
final int sx = loc.getBlockX() + 1;
|
final int sx = loc.getX() + 1;
|
||||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sz = loc.getBlockZ() + 1;
|
final int sz = loc.getZ() + 1;
|
||||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||||
MainUtil.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));
|
MainUtil.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));
|
||||||
MainUtil.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
|
MainUtil.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
|
||||||
@ -214,7 +241,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED)
|
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
public boolean finishPlotMerge(final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final PlotId pos1 = plotIds.get(0);
|
final PlotId pos1 = plotIds.get(0);
|
||||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
@ -225,7 +252,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
public boolean finishPlotUnlink(final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
for (final PlotId id : plotIds) {
|
for (final PlotId id : plotIds) {
|
||||||
@ -237,17 +264,17 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
public boolean startPlotMerge(final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
public boolean startPlotUnlink(final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean claimPlot(final World world, final PlotWorld plotworld, final Plot plot) {
|
public boolean claimPlot(final PlotWorld plotworld, final Plot plot) {
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
if (claim.equals(unclaim)) {
|
if (claim.equals(unclaim)) {
|
||||||
@ -257,7 +284,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unclaimPlot(final World world, final PlotWorld plotworld, final Plot plot) {
|
public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) {
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
if (claim != unclaim) {
|
if (claim != unclaim) {
|
||||||
@ -278,6 +305,6 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) {
|
public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) {
|
||||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final Location bot = MainUtil.getPlotBottomLoc(plotworld.worldname, plot.id);
|
final Location bot = MainUtil.getPlotBottomLoc(plotworld.worldname, plot.id);
|
||||||
return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1);
|
return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX(), dpw.ROAD_HEIGHT + 1, bot.getZ() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.AChunkManager;
|
import com.intellectualcrafters.plot.util.AChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.MainUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A plot manager with a square grid layout, with square shaped plots
|
* A plot manager with a square grid layout, with square shaped plots
|
||||||
@ -167,30 +162,25 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
* Set a plot biome
|
* Set a plot biome
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final String world, final Plot plot, final Biome biome) {
|
public boolean setBiome(final Plot plot, final int biome) {
|
||||||
final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getX() - 1;
|
final int bottomX = MainUtil.getPlotBottomLoc(plot.world, plot.id).getX() - 1;
|
||||||
final int topX = MainUtil.getPlotTopLoc(world, plot.id).getX() + 1;
|
final int topX = MainUtil.getPlotTopLoc(plot.world, plot.id).getX() + 1;
|
||||||
final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getZ() - 1;
|
final int bottomZ = MainUtil.getPlotBottomLoc(plot.world, plot.id).getZ() - 1;
|
||||||
final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getZ() + 1;
|
final int topZ = MainUtil.getPlotTopLoc(plot.world, plot.id).getZ() + 1;
|
||||||
final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
int size = (topX - bottomX + 1) * (topZ - bottomZ + 1);
|
||||||
final Biome current = block.getBiome();
|
int[] xb = new int[size];
|
||||||
|
int[] zb = new int[size];
|
||||||
|
int[] biomes = new int[size];
|
||||||
|
int index = 0;
|
||||||
if (biome.equals(current)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int x = bottomX; x <= topX; x++) {
|
for (int x = bottomX; x <= topX; x++) {
|
||||||
for (int z = bottomZ; z <= topZ; z++) {
|
for (int z = bottomZ; z <= topZ; z++) {
|
||||||
final Block blk = world.getBlockAt(x, 0, z);
|
xb[index] = x;
|
||||||
final Biome c = blk.getBiome();
|
zb[index] = z;
|
||||||
if (c.equals(biome)) {
|
biomes[index] = biome;
|
||||||
x += 15;
|
index++;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
blk.setBiome(biome);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BlockManager.setBiomes(plot.world, xb, zb, biomes);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public abstract class PlotManager {
|
|||||||
|
|
||||||
public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks);
|
public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks);
|
||||||
|
|
||||||
public abstract boolean setBiome(final Plot plot, final Biome biome);
|
public abstract boolean setBiome(final Plot plot, final int biome);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PLOT MERGING (return false if your generator does not support plot
|
* PLOT MERGING (return false if your generator does not support plot
|
||||||
|
@ -32,6 +32,12 @@ public abstract class BlockManager {
|
|||||||
|
|
||||||
public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines);
|
public abstract void functionSetSign(String worldname, int x, int y, int z, String[] lines);
|
||||||
|
|
||||||
|
public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final int[] biome);
|
||||||
|
|
||||||
|
public static void setBiomes(final String worldname, final int[] x, final int z[], final int[] biome) {
|
||||||
|
manager.functionSetBiomes(worldname, x, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[][] blocks) {
|
public static void setBlocks(final String worldname, final int[] x, final int y[], final int z[], final PlotBlock[][] blocks) {
|
||||||
final int[] id = new int[blocks.length];
|
final int[] id = new int[blocks.length];
|
||||||
final byte[] data = new byte[blocks.length];
|
final byte[] data = new byte[blocks.length];
|
||||||
|
@ -152,4 +152,13 @@ public class BukkitUtil extends BlockManager {
|
|||||||
public static int getViewDistance() {
|
public static int getViewDistance() {
|
||||||
return Bukkit.getViewDistance();
|
return Bukkit.getViewDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void functionSetBiomes(String worldname, int[] x, int[] z, int[] biome) {
|
||||||
|
World world = getWorld(worldname);
|
||||||
|
Biome[] biomes = Biome.values();
|
||||||
|
for (int i = 0; i < x.length; i++) {
|
||||||
|
world.setBiome(x[i], z[i], biomes[biome[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user