mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
[UNSTABLE] Major restructuring
This commit is contained in:
parent
cd1c0bcee8
commit
b95acd5d62
@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
@ -63,7 +64,7 @@ public class RegenAllRoads extends SubCommand {
|
||||
HybridPlotManager hpm = (HybridPlotManager) manager;
|
||||
|
||||
World world = Bukkit.getWorld(name);
|
||||
ArrayList<ChunkLoc> chunks = hpm.getChunkChunks(world);
|
||||
ArrayList<ChunkLoc> chunks = ChunkManager.getChunkChunks(world);
|
||||
|
||||
PlotMain.sendConsoleSenderMessage("&cIf no schematic is set, the following will not do anything");
|
||||
PlotMain.sendConsoleSenderMessage("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
||||
|
@ -1,8 +1,540 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
|
||||
/**
|
||||
* A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
|
||||
*/
|
||||
public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override
|
||||
public boolean setComponent(World world, PlotWorld plotworld, PlotId plotid, String component, PlotBlock[] blocks) {
|
||||
switch(component) {
|
||||
case "floor": {
|
||||
setFloor(world, plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "wall": {
|
||||
setWallFilling(world, plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "border": {
|
||||
setWall(world, plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid);
|
||||
PlotHelper.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);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWallFilling(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 = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
|
||||
int x, z;
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
PlotHelper.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++) {
|
||||
PlotHelper.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++) {
|
||||
PlotHelper.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++) {
|
||||
PlotHelper.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 = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
|
||||
int x, z;
|
||||
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
x = top.getBlockX() + 1;
|
||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
z = top.getBlockZ() + 1;
|
||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
x = bottom.getBlockX();
|
||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a plot biome
|
||||
*/
|
||||
@Override
|
||||
public boolean setBiome(final World world, final Plot plot, final Biome biome) {
|
||||
|
||||
final int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||
final int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
final int bottomZ = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1;
|
||||
final int topZ = PlotHelper.getPlotTopLoc(world, plot.id).getBlockZ() + 1;
|
||||
|
||||
final Block block = world.getBlockAt(PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||
final Biome current = block.getBiome();
|
||||
if (biome.equals(current)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int x = bottomX; x <= topX; x++) {
|
||||
for (int z = bottomZ; z <= topZ; z++) {
|
||||
final Block blk = world.getBlockAt(x, 0, z);
|
||||
final Biome c = blk.getBiome();
|
||||
if (c.equals(biome)) {
|
||||
x += 15;
|
||||
continue;
|
||||
}
|
||||
blk.setBiome(biome);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* PLOT MERGING
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sx = pos2.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getBlockZ() - 1;
|
||||
final 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.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(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(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getBlockX() - 1;
|
||||
final 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.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(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(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sx = pos2.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final 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.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
PlotHelper.setCuboid(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(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sx = pos2.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getBlockZ();
|
||||
final int ez = pos2.getBlockZ() + 1;
|
||||
|
||||
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(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getBlockX();
|
||||
final int ex = pos2.getBlockX() + 1;
|
||||
|
||||
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 removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final World world = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location loc = getPlotTopLocAbs(dpw, plot.id);
|
||||
|
||||
final int sx = loc.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = loc.getBlockZ() + 1;
|
||||
final 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, 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 true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, Runnable whendone) {
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
ChunkManager.regenerateRegion(pos1, pos2, whendone);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED)
|
||||
*/
|
||||
@Override
|
||||
public boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final PlotId pos1 = plotIds.get(0);
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
if (block.id != 0) {
|
||||
setWall(world, plotworld, pos1, new PlotBlock[] {(( ClassicPlotWorld) plotworld).WALL_BLOCK });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
if (block.id != 0) {
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(world, plotworld, id, new PlotBlock[] {(( ClassicPlotWorld) plotworld).WALL_BLOCK });
|
||||
Plot plot = PlotHelper.getPlot(world, id);
|
||||
if (plot.hasOwner()) {
|
||||
String name = UUIDHandler.getName(plot.owner);
|
||||
if (name != null) {
|
||||
PlotHelper.setSign(world, name, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean claimPlot(World world, final PlotWorld plotworld, Plot plot) {
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if (claim != unclaim) {
|
||||
setWall(world, plotworld, plot.id, new PlotBlock[] {claim});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(World world, final PlotWorld plotworld, Plot plot) {
|
||||
PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if (claim != unclaim) {
|
||||
setWall(world, plotworld, plot.id, new PlotBlock[] {unclaim});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlotComponents(World world, PlotWorld plotworld, PlotId plotid) {
|
||||
return new String[] {
|
||||
"floor",
|
||||
"wall",
|
||||
"border"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(final PlotWorld plotworld, final PlotId plotid) {
|
||||
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
|
||||
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
|
||||
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
|
||||
return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sign for a plot
|
||||
*/
|
||||
@Override
|
||||
public Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc) {
|
||||
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
|
||||
|
||||
// get x,z loc
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
// get plot size
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
|
||||
// get size of path on bottom part, and top part of plot
|
||||
// (As 0,0 is in the middle of a road, not the very start)
|
||||
int pathWidthLower;
|
||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
}
|
||||
|
||||
// calulating how many shifts need to be done
|
||||
int dx = x / size;
|
||||
int dz = z / size;
|
||||
if (x < 0) {
|
||||
dx--;
|
||||
x += ((-dx) * size);
|
||||
}
|
||||
if (z < 0) {
|
||||
dz--;
|
||||
z += ((-dz) * size);
|
||||
}
|
||||
|
||||
// reducing to first plot
|
||||
final int rx = (x) % size;
|
||||
final int rz = (z) % size;
|
||||
|
||||
// checking if road (return null if so)
|
||||
final int end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
|
||||
final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||
if (northSouth || eastWest) {
|
||||
return null;
|
||||
}
|
||||
// returning the plot id (based on the number of shifts required)
|
||||
return new PlotId(dx + 1, dz + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(final PlotWorld plotworld, final Location loc) {
|
||||
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
|
||||
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
}
|
||||
|
||||
int dx = x / size;
|
||||
int dz = z / size;
|
||||
|
||||
if (x < 0) {
|
||||
dx--;
|
||||
x += ((-dx) * size);
|
||||
}
|
||||
if (z < 0) {
|
||||
dz--;
|
||||
z += ((-dz) * size);
|
||||
}
|
||||
|
||||
final int rx = (x) % size;
|
||||
final int rz = (z) % size;
|
||||
|
||||
final int end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
|
||||
final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
|
||||
final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||
if (northSouth && eastWest) {
|
||||
// This means you are in the intersection
|
||||
final PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH));
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) {
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (northSouth) {
|
||||
// You are on a road running West to East (yeah, I named the var
|
||||
// poorly)
|
||||
final PlotId id = PlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH));
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings.getMerged(0)) {
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (eastWest) {
|
||||
// This is the road separating an Eastern and Western plot
|
||||
final PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0));
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings.getMerged(3)) {
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final PlotId id = new PlotId(dx + 1, dz + 1);
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return id;
|
||||
}
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom plot loc (some basic math)
|
||||
*/
|
||||
@Override
|
||||
public Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid) {
|
||||
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
|
||||
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
|
||||
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
|
||||
return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
||||
public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
public static int ROAD_HEIGHT_DEFAULT = 64;
|
||||
public static int PLOT_HEIGHT_DEFAULT = 64;
|
||||
public static int WALL_HEIGHT_DEFAULT = 64;
|
||||
public static int PLOT_WIDTH_DEFAULT = 32;
|
||||
public static int ROAD_WIDTH_DEFAULT = 7;
|
||||
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) };
|
||||
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) };
|
||||
public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
|
||||
public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1);
|
||||
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
||||
public final static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
|
||||
|
||||
public int ROAD_HEIGHT;
|
||||
public int PLOT_HEIGHT;
|
||||
public int WALL_HEIGHT;
|
||||
public int PLOT_WIDTH;
|
||||
public int ROAD_WIDTH;
|
||||
public PlotBlock[] MAIN_BLOCK;
|
||||
public PlotBlock[] TOP_BLOCK;
|
||||
public PlotBlock WALL_BLOCK;
|
||||
public PlotBlock CLAIMED_WALL_BLOCK;
|
||||
public PlotBlock WALL_FILLING;
|
||||
public PlotBlock ROAD_BLOCK;
|
||||
public boolean PLOT_BEDROCK;
|
||||
|
||||
public short PATH_WIDTH_LOWER;
|
||||
public short PATH_WIDTH_UPPER;
|
||||
public short SIZE;
|
||||
public short OFFSET;
|
||||
|
||||
/**
|
||||
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
||||
* <p/>
|
||||
* Set the last boolean to false if you do not require a specific config node to be set while using the setup
|
||||
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
|
||||
* world generation
|
||||
*/
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
return new ConfigurationNode[] { new ConfigurationNode("plot.height", ClassicPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.size", ClassicPlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.filling", ClassicPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", ClassicPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("wall.block", ClassicPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block_claimed", ClassicPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true), new ConfigurationNode("road.width", ClassicPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.height", ClassicPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), new ConfigurationNode("road.block", ClassicPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true), new ConfigurationNode("wall.filling", ClassicPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true), new ConfigurationNode("wall.height", ClassicPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true), new ConfigurationNode("plot.bedrock", true, "Plot bedrock generation", Configuration.BOOLEAN, true) };
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a world loads. Make sure you set all your constants here. You are provided with the
|
||||
* configuration section for that specific world.
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
if (!config.contains("plot.height")) {
|
||||
PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
||||
}
|
||||
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
|
||||
this.PLOT_HEIGHT = Math.min(255, config.getInt("plot.height"));
|
||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ','));
|
||||
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"), ','));
|
||||
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
|
||||
this.ROAD_WIDTH = config.getInt("road.width");
|
||||
this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height"));
|
||||
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
|
||||
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
||||
this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height"));
|
||||
this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed"));
|
||||
|
||||
this.SIZE = (short) (this.PLOT_WIDTH + this.ROAD_WIDTH);
|
||||
|
||||
if ((this.ROAD_WIDTH % 2) == 0) {
|
||||
PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
PATH_WIDTH_LOWER = (short) (Math.floor(this.ROAD_WIDTH / 2));
|
||||
}
|
||||
|
||||
this.PATH_WIDTH_UPPER = (short) (this.PATH_WIDTH_LOWER + this.PLOT_WIDTH + 1);
|
||||
}
|
||||
|
||||
public ClassicPlotWorld(String worldname) {
|
||||
super(worldname);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
|
||||
public abstract class GridPlotWorld extends PlotWorld {
|
||||
public GridPlotWorld(String worldname) {
|
||||
super(worldname);
|
||||
}
|
||||
}
|
@ -42,9 +42,11 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
@SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager {
|
||||
@ -201,7 +203,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
if (HybridPlotManager.UPDATE) {
|
||||
return false;
|
||||
}
|
||||
final ArrayList<ChunkLoc> chunks = getChunkChunks(world);
|
||||
final ArrayList<ChunkLoc> chunks = ChunkManager.getChunkChunks(world);
|
||||
|
||||
final Plugin plugin = (Plugin) PlotMain.getMain();
|
||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@ -233,38 +235,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
return true;
|
||||
}
|
||||
|
||||
public ArrayList<ChunkLoc> getChunkChunks(World world) {
|
||||
String directory = new File(".").getAbsolutePath() + File.separator + world.getName() + File.separator + "region";
|
||||
|
||||
File folder = new File(directory);
|
||||
File[] regionFiles = folder.listFiles();
|
||||
|
||||
ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
|
||||
for (File file : regionFiles) {
|
||||
String name = file.getName();
|
||||
if (name.endsWith("mca")) {
|
||||
String[] split = name.split("\\.");
|
||||
|
||||
try {
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
chunks.add(loc);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
}
|
||||
}
|
||||
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
|
||||
if (!chunks.contains(loc)) {
|
||||
chunks.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public boolean regenerateRoad(Chunk chunk) {
|
||||
World world = chunk.getWorld();
|
||||
@ -366,176 +336,52 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of getting a plot at a given location For a simplified explanation of the math involved: -
|
||||
* Get the current coords - shift these numbers down to something relatable for a single plot (similar to reducing
|
||||
* trigonometric functions down to the first quadrant) - e.g. If the plot size is 20 blocks, and we are at x=25,
|
||||
* it's equivalent to x=5 for that specific plot From this, and knowing how thick the road is, we can say whether
|
||||
* x=5 is road, or plot. The number of shifts done, is also counted, and this number gives us the PlotId
|
||||
*/
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(final PlotWorld plotworld, final Location loc) {
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
|
||||
// get x,z loc
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
// get plot size
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
|
||||
// get size of path on bottom part, and top part of plot
|
||||
// (As 0,0 is in the middle of a road, not the very start)
|
||||
int pathWidthLower;
|
||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
for (PlotId id : plotIds) {
|
||||
Location bottom = getPlotBottomLocAbs(plotworld, id);
|
||||
int sx = bottom.getBlockX() - hpw.PATH_WIDTH_LOWER;
|
||||
int sz = bottom.getBlockZ() - hpw.PATH_WIDTH_LOWER;
|
||||
int sy = hpw.ROAD_HEIGHT + hpw.OFFSET;
|
||||
for (ChunkLoc loc : hpw.G_SCH.keySet()) {
|
||||
HashMap<Short, Short> blocks = hpw.G_SCH.get(loc);
|
||||
HashMap<Short, Byte> datas = hpw.G_SCH_DATA.get(loc);
|
||||
if (datas == null) {
|
||||
for (Short y : blocks.keySet()) {
|
||||
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Short y : blocks.keySet()) {
|
||||
Byte data = datas.get(y);
|
||||
if (data == null) {
|
||||
data = 0;
|
||||
}
|
||||
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// calulating how many shifts need to be done
|
||||
int dx = x / size;
|
||||
int dz = z / size;
|
||||
if (x < 0) {
|
||||
dx--;
|
||||
x += ((-dx) * size);
|
||||
PlotBlock block = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
if (block.id != 0) {
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(world, plotworld, id, new PlotBlock[] {(( ClassicPlotWorld) plotworld).WALL_BLOCK });
|
||||
Plot plot = PlotHelper.getPlot(world, id);
|
||||
if (plot.hasOwner()) {
|
||||
String name = UUIDHandler.getName(plot.owner);
|
||||
if (name != null) {
|
||||
PlotHelper.setSign(world, name, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z < 0) {
|
||||
dz--;
|
||||
z += ((-dz) * size);
|
||||
}
|
||||
|
||||
// reducing to first plot
|
||||
final int rx = (x) % size;
|
||||
final int rz = (z) % size;
|
||||
|
||||
// checking if road (return null if so)
|
||||
final int end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
|
||||
final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||
if (northSouth || eastWest) {
|
||||
return null;
|
||||
}
|
||||
// returning the plot id (based on the number of shifts required)
|
||||
return new PlotId(dx + 1, dz + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some complex stuff for traversing mega plots (return getPlotIdAbs if you do not support mega plots)
|
||||
*/
|
||||
@Override
|
||||
public PlotId getPlotId(final PlotWorld plotworld, final Location loc) {
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
}
|
||||
|
||||
int dx = x / size;
|
||||
int dz = z / size;
|
||||
|
||||
if (x < 0) {
|
||||
dx--;
|
||||
x += ((-dx) * size);
|
||||
}
|
||||
if (z < 0) {
|
||||
dz--;
|
||||
z += ((-dz) * size);
|
||||
}
|
||||
|
||||
final int rx = (x) % size;
|
||||
final int rz = (z) % size;
|
||||
|
||||
final int end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||
|
||||
final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
|
||||
final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||
if (northSouth && eastWest) {
|
||||
// This means you are in the intersection
|
||||
final PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH));
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) {
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (northSouth) {
|
||||
// You are on a road running West to East (yeah, I named the var
|
||||
// poorly)
|
||||
final PlotId id = PlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH));
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings.getMerged(0)) {
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (eastWest) {
|
||||
// This is the road separating an Eastern and Western plot
|
||||
final PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0));
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings.getMerged(3)) {
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final PlotId id = new PlotId(dx + 1, dz + 1);
|
||||
final Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot == null) {
|
||||
return id;
|
||||
}
|
||||
return PlayerFunctions.getBottomPlot(loc.getWorld(), plot).id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom plot loc (some basic math)
|
||||
*/
|
||||
@Override
|
||||
public Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid) {
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
|
||||
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
|
||||
return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top plot loc (some basic math)
|
||||
*/
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(final PlotWorld plotworld, final PlotId plotid) {
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
|
||||
final int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
|
||||
return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid
|
||||
@ -544,7 +390,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
* to have 512x512 sized plots
|
||||
*/
|
||||
@Override
|
||||
public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete) {
|
||||
public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
PlotHelper.runners.put(plot, 1);
|
||||
final Plugin plugin = PlotMain.getMain();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@ -887,6 +733,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -902,378 +749,4 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
}, 20L);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sign for a plot
|
||||
*/
|
||||
@Override
|
||||
public Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setComponent(World world, PlotWorld plotworld, PlotId plotid, String component, PlotBlock[] blocks) {
|
||||
switch(component) {
|
||||
case "floor": {
|
||||
setFloor(world, plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "wall": {
|
||||
setWallFilling(world, plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "border": {
|
||||
setWall(world, plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid);
|
||||
PlotHelper.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);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWallFilling(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
final Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
|
||||
int x, z;
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
PlotHelper.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++) {
|
||||
PlotHelper.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++) {
|
||||
PlotHelper.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++) {
|
||||
PlotHelper.setBlock(w, x, y, z, blocks);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWall(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
final Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
|
||||
int x, z;
|
||||
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
x = top.getBlockX() + 1;
|
||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
z = top.getBlockZ() + 1;
|
||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
x = bottom.getBlockX();
|
||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a plot biome
|
||||
*/
|
||||
@Override
|
||||
public boolean setBiome(final World world, final Plot plot, final Biome biome) {
|
||||
|
||||
final int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||
final int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
final int bottomZ = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1;
|
||||
final int topZ = PlotHelper.getPlotTopLoc(world, plot.id).getBlockZ() + 1;
|
||||
|
||||
final Block block = world.getBlockAt(PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||
final Biome current = block.getBiome();
|
||||
if (biome.equals(current)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int x = bottomX; x <= topX; x++) {
|
||||
for (int z = bottomZ; z <= topZ; z++) {
|
||||
final Block blk = world.getBlockAt(x, 0, z);
|
||||
final Biome c = blk.getBiome();
|
||||
if (c.equals(biome)) {
|
||||
x += 15;
|
||||
continue;
|
||||
}
|
||||
blk.setBiome(biome);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* PLOT MERGING
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean createRoadEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sx = pos2.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getBlockZ() - 1;
|
||||
final 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.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(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(final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getBlockX() - 1;
|
||||
final 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.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(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.setCuboid(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(final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sx = pos2.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final 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.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
PlotHelper.setCuboid(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(final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sx = pos2.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getBlockZ();
|
||||
final int ez = pos2.getBlockZ() + 1;
|
||||
|
||||
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(final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.id);
|
||||
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getBlockX();
|
||||
final int ex = pos2.getBlockX() + 1;
|
||||
|
||||
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 removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final World world = Bukkit.getWorld(plot.world);
|
||||
|
||||
final Location loc = getPlotTopLocAbs(dpw, plot.id);
|
||||
|
||||
final int sx = loc.getBlockX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = loc.getBlockZ() + 1;
|
||||
final 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, 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 true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED)
|
||||
*/
|
||||
@Override
|
||||
public boolean finishPlotMerge(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotworld;
|
||||
final PlotId pos1 = plotIds.get(0);
|
||||
PlotBlock block = ((HybridPlotWorld) plotworld).WALL_BLOCK;
|
||||
if (block.id != 0) {
|
||||
setWall(world, plotworld, pos1, new PlotBlock[] {(( HybridPlotWorld) plotworld).WALL_BLOCK });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
for (PlotId id : plotIds) {
|
||||
Location bottom = getPlotBottomLocAbs(plotworld, id);
|
||||
int sx = bottom.getBlockX() - hpw.PATH_WIDTH_LOWER;
|
||||
int sz = bottom.getBlockZ() - hpw.PATH_WIDTH_LOWER;
|
||||
int sy = hpw.ROAD_HEIGHT + hpw.OFFSET;
|
||||
for (ChunkLoc loc : hpw.G_SCH.keySet()) {
|
||||
HashMap<Short, Short> blocks = hpw.G_SCH.get(loc);
|
||||
HashMap<Short, Byte> datas = hpw.G_SCH_DATA.get(loc);
|
||||
if (datas == null) {
|
||||
for (Short y : blocks.keySet()) {
|
||||
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Short y : blocks.keySet()) {
|
||||
Byte data = datas.get(y);
|
||||
if (data == null) {
|
||||
data = 0;
|
||||
}
|
||||
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
PlotBlock block = ((HybridPlotWorld) plotworld).WALL_BLOCK;
|
||||
if (block.id != 0) {
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(world, plotworld, id, new PlotBlock[] {(( HybridPlotWorld) plotworld).WALL_BLOCK });
|
||||
Plot plot = PlotHelper.getPlot(world, id);
|
||||
if (plot.hasOwner()) {
|
||||
String name = UUIDHandler.getName(plot.owner);
|
||||
if (name != null) {
|
||||
PlotHelper.setSign(world, name, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotMerge(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean claimPlot(World world, final PlotWorld plotworld, Plot plot) {
|
||||
PlotBlock unclaim = ((HybridPlotWorld) plotworld).WALL_BLOCK;
|
||||
PlotBlock claim = ((HybridPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if (claim != unclaim) {
|
||||
setWall(world, plotworld, plot.id, new PlotBlock[] {claim});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(World world, final PlotWorld plotworld, Plot plot) {
|
||||
PlotBlock unclaim = ((HybridPlotWorld) plotworld).WALL_BLOCK;
|
||||
PlotBlock claim = ((HybridPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if (claim != unclaim) {
|
||||
setWall(world, plotworld, plot.id, new PlotBlock[] {unclaim});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlotComponents(World world, PlotWorld plotworld, PlotId plotid) {
|
||||
return new String[] {
|
||||
"floor",
|
||||
"wall",
|
||||
"border"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,121 +29,17 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
|
||||
public class HybridPlotWorld extends PlotWorld {
|
||||
|
||||
/*
|
||||
* These variables are set to ensure fast access to config settings Strings
|
||||
* are used as little as possible to optimize math performance in many of
|
||||
* the functions/algorithms
|
||||
*/
|
||||
/**
|
||||
* Default Road Height: 64
|
||||
*/
|
||||
public static int ROAD_HEIGHT_DEFAULT = 64;
|
||||
/**
|
||||
* Default plot height: 64
|
||||
*/
|
||||
public static int PLOT_HEIGHT_DEFAULT = 64;
|
||||
/**
|
||||
* Default Wall Height: 64
|
||||
*/
|
||||
public static int WALL_HEIGHT_DEFAULT = 64;
|
||||
/**
|
||||
* Default plot width: 32
|
||||
*/
|
||||
public static int PLOT_WIDTH_DEFAULT = 32;
|
||||
/**
|
||||
* Default road width: 7
|
||||
*/
|
||||
public static int ROAD_WIDTH_DEFAULT = 7;
|
||||
/**
|
||||
* Default main block: 1
|
||||
*/
|
||||
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) };
|
||||
/**
|
||||
* Default top blocks: {"2"}
|
||||
*/
|
||||
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) };
|
||||
/**
|
||||
* Default wall block: 44
|
||||
*/
|
||||
public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
|
||||
public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1);
|
||||
/**
|
||||
* Default wall filling: 1
|
||||
*/
|
||||
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
||||
/**
|
||||
* Default road block: 155
|
||||
*/
|
||||
public final static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
|
||||
/**
|
||||
* Road Height
|
||||
*/
|
||||
public int ROAD_HEIGHT;
|
||||
/**
|
||||
* plot height
|
||||
*/
|
||||
public int PLOT_HEIGHT;
|
||||
/**
|
||||
* Wall height
|
||||
*/
|
||||
public int WALL_HEIGHT;
|
||||
/**
|
||||
* plot width
|
||||
*/
|
||||
public int PLOT_WIDTH;
|
||||
/**
|
||||
* Road width
|
||||
*/
|
||||
public int ROAD_WIDTH;
|
||||
/**
|
||||
* Plot main block
|
||||
*/
|
||||
public PlotBlock[] MAIN_BLOCK;
|
||||
/**
|
||||
* Top blocks
|
||||
*/
|
||||
public PlotBlock[] TOP_BLOCK;
|
||||
/**
|
||||
* Wall block
|
||||
*/
|
||||
public PlotBlock WALL_BLOCK;
|
||||
public PlotBlock CLAIMED_WALL_BLOCK;
|
||||
/**
|
||||
* Wall filling
|
||||
*/
|
||||
public PlotBlock WALL_FILLING;
|
||||
/**
|
||||
* enable road stripes
|
||||
*/
|
||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
public boolean ROAD_SCHEMATIC_ENABLED;
|
||||
/**
|
||||
* Road block
|
||||
*/
|
||||
public PlotBlock ROAD_BLOCK;
|
||||
/**
|
||||
* If bedrock is enabled
|
||||
*/
|
||||
public boolean PLOT_BEDROCK;
|
||||
|
||||
public short PATH_WIDTH_LOWER;
|
||||
public short PATH_WIDTH_UPPER;
|
||||
public short SIZE;
|
||||
public short OFFSET;
|
||||
public short SCHEMATIC_HEIGHT;
|
||||
|
||||
public boolean PLOT_SCHEMATIC = false;
|
||||
|
||||
public short REQUIRED_CHANGES = 0;
|
||||
|
||||
/*
|
||||
@ -156,20 +52,6 @@ public class HybridPlotWorld extends PlotWorld {
|
||||
public HashMap<ChunkLoc, HashMap<Short, Short>> G_SCH;
|
||||
public HashMap<ChunkLoc, HashMap<Short, Byte>> G_SCH_DATA;
|
||||
|
||||
/**
|
||||
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
||||
* <p/>
|
||||
* Set the last boolean to false if you do not require a specific config node to be set while using the setup
|
||||
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
|
||||
* world generation
|
||||
*/
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
// TODO return a set of configuration nodes (used for setup command)
|
||||
return new ConfigurationNode[] { new ConfigurationNode("plot.height", HybridPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.size", HybridPlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.filling", HybridPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", HybridPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("wall.block", HybridPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block_claimed", HybridPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true), new ConfigurationNode("road.width", HybridPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true),
|
||||
new ConfigurationNode("road.height", HybridPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), new ConfigurationNode("road.block", HybridPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true), new ConfigurationNode("wall.filling", HybridPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true), new ConfigurationNode("wall.height", HybridPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true), new ConfigurationNode("plot.bedrock", true, "Plot bedrock generation", Configuration.BOOLEAN, true) };
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a world loads. Make sure you set all your constants here. You are provided with the
|
||||
* configuration section for that specific world.
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||
public SquarePlotWorld(String worldname) {
|
||||
super(worldname);
|
||||
}
|
||||
}
|
@ -711,7 +711,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
for (final Plot plot : plots) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plot.world);
|
||||
final PlotManager manager = PlotMain.getPlotManager(plot.getWorld());
|
||||
manager.clearPlot(null, plotworld, plot, true);
|
||||
manager.clearPlot(null, plotworld, plot, true, null);
|
||||
DBFunc.delete(plot.getWorld().getName(), plot);
|
||||
PlotMain.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public abstract class PlotManager {
|
||||
/*
|
||||
* Plot clearing (return false if you do not support some method)
|
||||
*/
|
||||
public abstract boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, boolean isDelete);
|
||||
public abstract boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone);
|
||||
|
||||
public abstract boolean claimPlot(final World world, final PlotWorld plotworld, final Plot plot);
|
||||
|
||||
|
@ -62,17 +62,34 @@ public class ChunkManager {
|
||||
}
|
||||
|
||||
public static ArrayList<ChunkLoc> getChunkChunks(World world) {
|
||||
File[] regionFiles = new File(world.getName() + File.separator + "region").listFiles();
|
||||
String directory = new File(".").getAbsolutePath() + File.separator + world.getName() + File.separator + "region";
|
||||
|
||||
File folder = new File(directory);
|
||||
File[] regionFiles = folder.listFiles();
|
||||
|
||||
ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
|
||||
for (File file : regionFiles) {
|
||||
String name = file.getName();
|
||||
if (name.endsWith("mca")) {
|
||||
String[] split = name.split("\\.");
|
||||
try {
|
||||
chunks.add(new ChunkLoc(Integer.parseInt(split[1]), Integer.parseInt(split[2])));
|
||||
} catch (Exception e) { }
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
ChunkLoc loc = new ChunkLoc(x, z);
|
||||
chunks.add(loc);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
}
|
||||
}
|
||||
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
|
||||
if (!chunks.contains(loc)) {
|
||||
chunks.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class ExpireManager {
|
||||
Unlink.unlinkPlot(Bukkit.getWorld(world), plot);
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
manager.clearPlot(worldobj, plotworld, plot, false);
|
||||
manager.clearPlot(worldobj, plotworld, plot, false, null);
|
||||
PlotHelper.removeSign(worldobj, plot);
|
||||
DBFunc.delete(world, plot);
|
||||
PlotMain.removePlot(world, plot.id, true);
|
||||
|
@ -587,8 +587,8 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
final long start = System.currentTimeMillis();
|
||||
final Location location = PlotHelper.getPlotHomeDefault(plot);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
runners.put(plot, 1);
|
||||
if (plotworld.TERRAIN != 0) {
|
||||
runners.put(plot, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
ChunkManager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||
@Override
|
||||
@ -601,20 +601,18 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
manager.clearPlot(world, plotworld, plot, isDelete);
|
||||
|
||||
final Plugin plugin = PlotMain.getMain();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setBiome(world, plot, Biome.FOREST);
|
||||
runners.remove(plot);
|
||||
if (player != null && player.isOnline()) {
|
||||
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
||||
}
|
||||
update(location);
|
||||
}
|
||||
}, 90L);
|
||||
};
|
||||
manager.clearPlot(world, plotworld, plot, isDelete, run);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user