mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-30 00:56:45 +01:00
Upgraded to new generator
This commit is contained in:
parent
7580b0ea82
commit
f8ca152300
@ -31,9 +31,9 @@ import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
|||||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||||
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.listeners.*;
|
import com.intellectualcrafters.plot.listeners.*;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
@ -970,8 +970,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
if (worlds.contains(world)) {
|
if (worlds.contains(world)) {
|
||||||
sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!");
|
sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!");
|
||||||
|
|
||||||
plotWorld = new DefaultPlotWorld(world);
|
plotWorld = new HybridPlotWorld(world);
|
||||||
plotManager = new DefaultPlotManager();
|
plotManager = new HybridPlotManager();
|
||||||
|
|
||||||
if (!config.contains(path)) {
|
if (!config.contains(path)) {
|
||||||
config.createSection(path);
|
config.createSection(path);
|
||||||
@ -1287,7 +1287,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||||
return new WorldGenerator(world);
|
return new HybridGen(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,14 +27,16 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -82,8 +84,8 @@ public class Claim extends SubCommand {
|
|||||||
plot2.settings.setFlags(flags);
|
plot2.settings.setFlags(flags);
|
||||||
DBFunc.setFlags(plot.world, plot2, flags);
|
DBFunc.setFlags(plot.world, plot2, flags);
|
||||||
}
|
}
|
||||||
if (world instanceof DefaultPlotWorld) {
|
if (world instanceof HybridPlotWorld) {
|
||||||
final DefaultPlotWorld pW = (DefaultPlotWorld) world;
|
final HybridPlotWorld pW = (HybridPlotWorld) world;
|
||||||
if (pW.CLAIMED_WALL_BLOCK != pW.WALL_BLOCK) {
|
if (pW.CLAIMED_WALL_BLOCK != pW.WALL_BLOCK) {
|
||||||
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
|
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
|
||||||
if (PlotHelper.canSetFast) {
|
if (PlotHelper.canSetFast) {
|
||||||
|
@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
@ -214,7 +214,7 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
if (generator instanceof PlotGenerator) {
|
if (generator instanceof PlotGenerator) {
|
||||||
plotworld = ((PlotGenerator) generator).getNewPlotWorld(world);
|
plotworld = ((PlotGenerator) generator).getNewPlotWorld(world);
|
||||||
} else {
|
} else {
|
||||||
plotworld = new DefaultPlotWorld(world);
|
plotworld = new HybridPlotWorld(world);
|
||||||
}
|
}
|
||||||
PlotMain.removePlotWorld(world);
|
PlotMain.removePlotWorld(world);
|
||||||
|
|
||||||
|
@ -24,12 +24,13 @@ package com.intellectualcrafters.plot.database;
|
|||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.object.PlotHomePosition;
|
import com.intellectualcrafters.plot.object.PlotHomePosition;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.worldcretornica.plotme.PlayerList;
|
import com.worldcretornica.plotme.PlayerList;
|
||||||
import com.worldcretornica.plotme.Plot;
|
import com.worldcretornica.plotme.Plot;
|
||||||
import com.worldcretornica.plotme.PlotManager;
|
import com.worldcretornica.plotme.PlotManager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
@ -265,7 +266,7 @@ public class PlotMeConverter {
|
|||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname + " plugin:PlotSquared");
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname + " plugin:PlotSquared");
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getServer().unloadWorld(world, true);
|
Bukkit.getServer().unloadWorld(world, true);
|
||||||
final World myworld = WorldCreator.name(worldname).generator(new WorldGenerator(worldname)).createWorld();
|
final World myworld = WorldCreator.name(worldname).generator(new HybridGen(worldname)).createWorld();
|
||||||
myworld.save();
|
myworld.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,897 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
||||||
// /
|
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
|
||||||
// it under the terms of the GNU General Public License as published by /
|
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
|
||||||
// (at your option) any later version. /
|
|
||||||
// /
|
|
||||||
// This program is distributed in the hope that it will be useful, /
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
||||||
// GNU General Public License for more details. /
|
|
||||||
// /
|
|
||||||
// You should have received a copy of the GNU General Public License /
|
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
||||||
// /
|
|
||||||
// You can contact us via: support@intellectualsites.com /
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.generator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
import com.intellectualcrafters.plot.object.*;
|
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public class DefaultPlotManager extends PlotManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 DefaultPlotWorld dpw = ((DefaultPlotWorld) 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 DefaultPlotWorld dpw = ((DefaultPlotWorld) 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a location is inside a specific plot(non-Javadoc) - For this implementation, we don't need to do
|
|
||||||
* anything fancier than referring to getPlotIdAbs(...)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isInPlotAbs(final PlotWorld plotworld, final Location loc, final PlotId plotid) {
|
|
||||||
final PlotId result = getPlotIdAbs(plotworld, loc);
|
|
||||||
return (result != null) && (result == plotid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the bottom plot loc (some basic math)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Location getPlotBottomLocAbs(final PlotWorld plotworld, final PlotId plotid) {
|
|
||||||
final DefaultPlotWorld dpw = ((DefaultPlotWorld) 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 DefaultPlotWorld dpw = ((DefaultPlotWorld) 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid
|
|
||||||
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster
|
|
||||||
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen
|
|
||||||
* to have 512x512 sized plots
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean clearPlot(final World world, final Plot plot, final boolean isDelete) {
|
|
||||||
PlotHelper.runners.put(plot, 1);
|
|
||||||
final Plugin plugin = PlotMain.getMain();
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.runners.remove(plot);
|
|
||||||
}
|
|
||||||
}, 90L);
|
|
||||||
|
|
||||||
final DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world));
|
|
||||||
|
|
||||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
|
||||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
|
||||||
|
|
||||||
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
|
||||||
final PlotBlock[] filling = dpw.MAIN_BLOCK;
|
|
||||||
|
|
||||||
// PlotBlock wall = dpw.WALL_BLOCK;
|
|
||||||
final PlotBlock wall;
|
|
||||||
|
|
||||||
if (isDelete) {
|
|
||||||
wall = dpw.WALL_BLOCK;
|
|
||||||
} else {
|
|
||||||
wall = dpw.CLAIMED_WALL_BLOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
final PlotBlock wall_filling = dpw.WALL_FILLING;
|
|
||||||
|
|
||||||
final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, 1, pos1.getBlockZ()));
|
|
||||||
if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) {
|
|
||||||
setWallFilling(world, dpw, plot.id, wall_filling);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, dpw.WALL_HEIGHT + 1, pos1.getBlockZ()));
|
|
||||||
if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) {
|
|
||||||
setWall(world, dpw, plot.id, wall);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if ((pos2.getBlockX() - pos1.getBlockX()) < 48) {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int startX = (pos1.getBlockX() / 16) * 16;
|
|
||||||
final int startZ = (pos1.getBlockZ() / 16) * 16;
|
|
||||||
final int chunkX = 16 + pos2.getBlockX();
|
|
||||||
final int chunkZ = 16 + pos2.getBlockZ();
|
|
||||||
final Location l1 = PlotHelper.getPlotBottomLoc(world, plot.id);
|
|
||||||
final Location l2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
|
||||||
final int plotMinX = l1.getBlockX() + 1;
|
|
||||||
final int plotMinZ = l1.getBlockZ() + 1;
|
|
||||||
final int plotMaxX = l2.getBlockX();
|
|
||||||
final int plotMaxZ = l2.getBlockZ();
|
|
||||||
Location mn = null;
|
|
||||||
Location mx = null;
|
|
||||||
for (int i = startX; i < chunkX; i += 16) {
|
|
||||||
for (int j = startZ; j < chunkZ; j += 16) {
|
|
||||||
final Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j));
|
|
||||||
if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
|
|
||||||
if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
|
||||||
if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
|
|
||||||
if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
|
||||||
if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mn == null) {
|
|
||||||
mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ));
|
|
||||||
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
|
||||||
} else if ((mx.getBlockZ() < (j + 15)) || (mx.getBlockX() < (i + 15))) {
|
|
||||||
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
|
||||||
}
|
|
||||||
world.regenerateChunk(i / 16, j / 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location max = mx;
|
|
||||||
final Location min = mn;
|
|
||||||
|
|
||||||
if (min == null) {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
}
|
|
||||||
}, 5L);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (min.getBlockX() < plotMinX) {
|
|
||||||
min.setX(plotMinX);
|
|
||||||
}
|
|
||||||
if (min.getBlockZ() < plotMinZ) {
|
|
||||||
min.setZ(plotMinZ);
|
|
||||||
}
|
|
||||||
if (max.getBlockX() > plotMaxX) {
|
|
||||||
max.setX(plotMaxX);
|
|
||||||
}
|
|
||||||
if (max.getBlockZ() > plotMaxZ) {
|
|
||||||
max.setZ(plotMaxZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 21L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 25L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 29L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 33L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 37L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 41L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 45L);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
}, 49L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove sign for a plot
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot) {
|
|
||||||
final DefaultPlotWorld dpw = (DefaultPlotWorld) 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 setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
|
||||||
final DefaultPlotWorld dpw = (DefaultPlotWorld) 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setWallFilling(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock plotblock) {
|
|
||||||
final DefaultPlotWorld dpw = (DefaultPlotWorld) 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;
|
|
||||||
|
|
||||||
Block block;
|
|
||||||
|
|
||||||
z = bottom.getBlockZ();
|
|
||||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
block = w.getBlockAt(x, y, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x = top.getBlockX() + 1;
|
|
||||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
block = w.getBlockAt(x, y, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
z = top.getBlockZ() + 1;
|
|
||||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
block = w.getBlockAt(x, y, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x = bottom.getBlockX();
|
|
||||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
|
||||||
block = w.getBlockAt(x, y, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setWall(final World w, final PlotWorld plotworld, final PlotId plotid, final PlotBlock plotblock) {
|
|
||||||
final DefaultPlotWorld dpw = (DefaultPlotWorld) 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;
|
|
||||||
|
|
||||||
Block block;
|
|
||||||
z = bottom.getBlockZ();
|
|
||||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
x = top.getBlockX() + 1;
|
|
||||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
z = top.getBlockZ() + 1;
|
|
||||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
x = bottom.getBlockX();
|
|
||||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
|
||||||
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 DefaultPlotWorld dpw = (DefaultPlotWorld) 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 DefaultPlotWorld dpw = (DefaultPlotWorld) 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 DefaultPlotWorld dpw = (DefaultPlotWorld) 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 DefaultPlotWorld dpw = (DefaultPlotWorld) 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 DefaultPlotWorld dpw = (DefaultPlotWorld) 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 DefaultPlotWorld dpw = (DefaultPlotWorld) 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) {
|
|
||||||
|
|
||||||
// TODO set plot wall
|
|
||||||
|
|
||||||
final DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
|
||||||
|
|
||||||
final PlotId pos1 = plotIds.get(0);
|
|
||||||
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
|
||||||
|
|
||||||
final PlotBlock block = dpw.WALL_BLOCK;
|
|
||||||
|
|
||||||
final Location megaPlotBot = PlotHelper.getPlotBottomLoc(world, pos1);
|
|
||||||
final Location megaPlotTop = PlotHelper.getPlotTopLoc(world, pos2).add(1, 0, 1);
|
|
||||||
for (int x = megaPlotBot.getBlockX(); x <= megaPlotTop.getBlockX(); x++) {
|
|
||||||
for (int z = megaPlotBot.getBlockZ(); z <= megaPlotTop.getBlockZ(); z++) {
|
|
||||||
if ((z == megaPlotBot.getBlockZ()) || (z == megaPlotTop.getBlockZ()) || (x == megaPlotBot.getBlockX()) || (x == megaPlotTop.getBlockX())) {
|
|
||||||
world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z).setTypeIdAndData(block.id, block.data, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean finishPlotUnlink(final World world, final PlotWorld plotworld, final ArrayList<PlotId> plotIds) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,363 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
||||||
|
* You will see a lot of slower implementations have a single for loop. - This is perfectly fine to do, it will just
|
||||||
|
* mean world generation may take somewhat longer
|
||||||
|
*
|
||||||
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
|
public class HybridGen extends PlotGenerator {
|
||||||
|
/**
|
||||||
|
* Set to static to re-use the same managet for all Default World Generators
|
||||||
|
*/
|
||||||
|
private static PlotManager manager = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some generator specific variables (implementation dependent)
|
||||||
|
*/
|
||||||
|
final int plotsize;
|
||||||
|
final int pathsize;
|
||||||
|
final short wall;
|
||||||
|
final short wallfilling;
|
||||||
|
final short roadblock;
|
||||||
|
final int size;
|
||||||
|
final Biome biome;
|
||||||
|
final int roadheight;
|
||||||
|
final int wallheight;
|
||||||
|
final int plotheight;
|
||||||
|
final short[] plotfloors;
|
||||||
|
final short[] filling;
|
||||||
|
final short pathWidthLower;
|
||||||
|
final short pathWidthUpper;
|
||||||
|
boolean doState = false;
|
||||||
|
int maxY;
|
||||||
|
/**
|
||||||
|
* result object is returned for each generated chunk, do stuff to it
|
||||||
|
*/
|
||||||
|
short[][] result;
|
||||||
|
/**
|
||||||
|
* plotworld object
|
||||||
|
*/
|
||||||
|
HybridPlotWorld plotworld = null;
|
||||||
|
/**
|
||||||
|
* Faster sudo-random number generator than java.util.random
|
||||||
|
*/
|
||||||
|
private long state = 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize variables, and create plotworld object used in calculations
|
||||||
|
*/
|
||||||
|
public HybridGen(final String world) {
|
||||||
|
super(world);
|
||||||
|
|
||||||
|
if (this.plotworld == null) {
|
||||||
|
this.plotworld = (HybridPlotWorld) PlotMain.getWorldSettings(world);
|
||||||
|
}
|
||||||
|
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||||
|
|
||||||
|
this.pathsize = this.plotworld.ROAD_WIDTH;
|
||||||
|
|
||||||
|
this.roadblock = this.plotworld.ROAD_BLOCK.id;
|
||||||
|
|
||||||
|
this.wallfilling = this.plotworld.WALL_FILLING.id;
|
||||||
|
this.size = this.pathsize + this.plotsize;
|
||||||
|
this.wall = this.plotworld.WALL_BLOCK.id;
|
||||||
|
|
||||||
|
this.plotfloors = new short[this.plotworld.TOP_BLOCK.length];
|
||||||
|
for (int i = 0; i < this.plotworld.TOP_BLOCK.length; i++) {
|
||||||
|
this.plotfloors[i] = this.plotworld.TOP_BLOCK[i].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.filling = new short[this.plotworld.MAIN_BLOCK.length];
|
||||||
|
for (int i = 0; i < this.plotworld.MAIN_BLOCK.length; i++) {
|
||||||
|
this.filling[i] = this.plotworld.MAIN_BLOCK[i].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.filling.length > 1 || this.plotfloors.length > 1) {
|
||||||
|
this.doState = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wallheight = this.plotworld.WALL_HEIGHT;
|
||||||
|
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
||||||
|
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
||||||
|
|
||||||
|
if ((this.pathsize % 2) == 0) {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
|
||||||
|
} else {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
|
||||||
|
|
||||||
|
this.biome = this.plotworld.PLOT_BIOME;
|
||||||
|
|
||||||
|
try {
|
||||||
|
maxY = Bukkit.getWorld(world).getMaxHeight();
|
||||||
|
}
|
||||||
|
catch (NullPointerException e) {
|
||||||
|
maxY = 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the plot manager for this type of generator, or create one For square plots you may as well use the
|
||||||
|
* default plot manager which comes with PlotSquared
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PlotManager getPlotManager() {
|
||||||
|
if (manager == null) {
|
||||||
|
manager = new HybridPlotManager();
|
||||||
|
}
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow spawning everywhere
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canSpawn(final World world, final int x, final int z) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PlotWorld getNewPlotWorld(final String world) {
|
||||||
|
this.plotworld = new HybridPlotWorld(world);
|
||||||
|
return this.plotworld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final long nextLong() {
|
||||||
|
final long a = this.state;
|
||||||
|
this.state = xorShift64(a);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final long xorShift64(long a) {
|
||||||
|
a ^= (a << 21);
|
||||||
|
a ^= (a >>> 35);
|
||||||
|
a ^= (a << 4);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int random(final int n) {
|
||||||
|
final long r = ((nextLong() >>> 32) * n) >> 32;
|
||||||
|
return (int) r;
|
||||||
|
}
|
||||||
|
private void setBlock(short[][] result, int x, int y, int z, short[] blkids) {
|
||||||
|
if (blkids.length == 1) {
|
||||||
|
setBlock(result, x, y, z, blkids[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final int i = random(blkids.length);
|
||||||
|
setBlock(result, x, y, z, blkids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Standard setblock method for world generation
|
||||||
|
*/
|
||||||
|
private void setBlock(short[][] result, int x, int y, int z, short blkid) {
|
||||||
|
if (result[y >> 4] == null) {
|
||||||
|
result[y >> 4] = new short[4096];
|
||||||
|
}
|
||||||
|
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the block populator
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
||||||
|
// disabling spawning for this world
|
||||||
|
if (!this.plotworld.MOB_SPAWNING) {
|
||||||
|
world.setSpawnFlags(false, false);
|
||||||
|
world.setAmbientSpawnLimit(0);
|
||||||
|
world.setAnimalSpawnLimit(0);
|
||||||
|
world.setMonsterSpawnLimit(0);
|
||||||
|
world.setWaterAnimalSpawnLimit(0);
|
||||||
|
}
|
||||||
|
// You can have as many populators as you would like, e.g. tree
|
||||||
|
// populator, ore populator
|
||||||
|
return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default spawn location for this world
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Location getFixedSpawnLocation(final World world, final Random random) {
|
||||||
|
return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world
|
||||||
|
* generator
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public short[][] generateExtBlockSections(final World world, final Random random, int cx, int cz, final BiomeGrid biomes) {
|
||||||
|
if (doState) {
|
||||||
|
final int prime = 13;
|
||||||
|
int h = 1;
|
||||||
|
h = (prime * h) + cx;
|
||||||
|
h = (prime * h) + cz;
|
||||||
|
this.state = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.result = new short[maxY / 16][];
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
setBlock(this.result, x, 0, z, (short) 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HybridPlotManager hpm = ((HybridPlotManager) this.manager);
|
||||||
|
RegionWrapper plot = hpm.CURRENT_PLOT_CLEAR;
|
||||||
|
if (plot != null) {
|
||||||
|
|
||||||
|
int X = cx << 4;
|
||||||
|
int Z = cz << 4;
|
||||||
|
|
||||||
|
short sx = (short) ((X) % this.size);
|
||||||
|
short sz = (short) ((Z) % this.size);
|
||||||
|
|
||||||
|
if (sx < 0) {
|
||||||
|
sx += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sz < 0) {
|
||||||
|
sz += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
if (isIn(plot, X + x, Z + z)) {
|
||||||
|
biomes.setBiome(x, z, this.biome);
|
||||||
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
|
setBlock(this.result, x, y, z, this.filling);
|
||||||
|
}
|
||||||
|
setBlock(this.result, x, this.plotheight, z, this.plotfloors);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ChunkLoc loc = new ChunkLoc(X + x, Z + z);
|
||||||
|
HashMap<Short, Short> blocks = hpm.GENERATE_BLOCKS.get(loc);
|
||||||
|
if (blocks != null) {
|
||||||
|
for (short y : blocks.keySet()) {
|
||||||
|
setBlock(this.result, x, y, z, blocks.get(y).shortValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
short sx = (short) ((cx << 4) % this.size);
|
||||||
|
short sz = (short) ((cz << 4) % this.size);
|
||||||
|
|
||||||
|
if (sx < 0) {
|
||||||
|
sx += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sz < 0) {
|
||||||
|
sz += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
|
||||||
|
biomes.setBiome(x, z, this.biome);
|
||||||
|
|
||||||
|
short absX = (short) ((sx + x) % this.size);
|
||||||
|
short absZ = (short) ((sz + z) % this.size);
|
||||||
|
|
||||||
|
boolean gx = absX > pathWidthLower;
|
||||||
|
boolean gz = absZ > pathWidthLower;
|
||||||
|
|
||||||
|
boolean lx = absX < pathWidthUpper;
|
||||||
|
boolean lz = absZ < pathWidthUpper;
|
||||||
|
|
||||||
|
// inside plot
|
||||||
|
if (gx && gz && lx && lz) {
|
||||||
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
|
setBlock(this.result, x, y, z, this.filling);
|
||||||
|
}
|
||||||
|
setBlock(this.result, x, this.plotheight, z, this.plotfloors);
|
||||||
|
} else {
|
||||||
|
// wall
|
||||||
|
if ((absX >= pathWidthLower && absX <= pathWidthUpper && absZ >= pathWidthLower && absZ <= pathWidthUpper))
|
||||||
|
{
|
||||||
|
for (short y = 1; y <= this.wallheight; y++) {
|
||||||
|
setBlock(this.result, x, y, z, this.wallfilling);
|
||||||
|
}
|
||||||
|
if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
setBlock(this.result, x, this.wallheight + 1, z, this.wall);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// road
|
||||||
|
else {
|
||||||
|
for (short y = 1; y <= this.roadheight; y++) {
|
||||||
|
setBlock(this.result, x, y, z, this.roadblock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
ChunkLoc loc = new ChunkLoc(absX, absZ);
|
||||||
|
HashMap<Short, Short> blocks = this.plotworld.G_SCH.get(loc);
|
||||||
|
if (blocks != null) {
|
||||||
|
for (short y : blocks.keySet()) {
|
||||||
|
setBlock(this.result, x, this.roadheight + y, z, blocks.get(y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIn(RegionWrapper plot, int x, int z) {
|
||||||
|
return (x >= plot.minX && x <= plot.maxX && z >= plot.minZ && z <= plot.maxZ);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -21,15 +21,24 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Configuration;
|
import com.intellectualcrafters.plot.config.Configuration;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
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;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
public class DefaultPlotWorld extends PlotWorld {
|
public class HybridPlotWorld extends PlotWorld {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These variables are set to ensure fast access to config settings Strings
|
* These variables are set to ensure fast access to config settings Strings
|
||||||
@ -74,11 +83,6 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
* Default wall filling: 1
|
* Default wall filling: 1
|
||||||
*/
|
*/
|
||||||
public final static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
public final static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
||||||
/**
|
|
||||||
* Default road stripes: 35
|
|
||||||
*/
|
|
||||||
public final static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0);
|
|
||||||
public final static boolean ROAD_STRIPES_ENABLED_DEFAULT = false;
|
|
||||||
/**
|
/**
|
||||||
* Default road block: 155
|
* Default road block: 155
|
||||||
*/
|
*/
|
||||||
@ -120,26 +124,29 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
* Wall filling
|
* Wall filling
|
||||||
*/
|
*/
|
||||||
public PlotBlock WALL_FILLING;
|
public PlotBlock WALL_FILLING;
|
||||||
/**
|
|
||||||
* Road stripes
|
|
||||||
*/
|
|
||||||
public PlotBlock ROAD_STRIPES;
|
|
||||||
/**
|
/**
|
||||||
* enable road stripes
|
* enable road stripes
|
||||||
*/
|
*/
|
||||||
public boolean ROAD_STRIPES_ENABLED;
|
public boolean ROAD_SCHEMATIC_ENABLED;
|
||||||
/**
|
/**
|
||||||
* Road block
|
* Road block
|
||||||
*/
|
*/
|
||||||
public PlotBlock ROAD_BLOCK;
|
public PlotBlock ROAD_BLOCK;
|
||||||
|
|
||||||
|
public short PATH_WIDTH_LOWER;
|
||||||
|
public short PATH_WIDTH_UPPER;
|
||||||
|
public short SIZE;
|
||||||
|
public short OFFSET;
|
||||||
|
public short SCHEMATIC_HEIGHT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we are just calling the super method, nothing special
|
* Here we are just calling the super method, nothing special
|
||||||
*/
|
*/
|
||||||
public DefaultPlotWorld(final String worldname) {
|
public HybridPlotWorld(final String worldname) {
|
||||||
super(worldname);
|
super(worldname);
|
||||||
}
|
}
|
||||||
|
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
|
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
||||||
* <p/>
|
* <p/>
|
||||||
@ -150,7 +157,7 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
@Override
|
@Override
|
||||||
public ConfigurationNode[] getSettingNodes() {
|
public ConfigurationNode[] getSettingNodes() {
|
||||||
// TODO return a set of configuration nodes (used for setup command)
|
// TODO return a set of configuration nodes (used for setup command)
|
||||||
return new ConfigurationNode[]{new ConfigurationNode("plot.height", DefaultPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.size", DefaultPlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block_claimed", DefaultPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true), new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true), new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), new ConfigurationNode("road.enable_stripes", DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", Configuration.BOOLEAN, true), new ConfigurationNode("road.block", DefaultPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true), new ConfigurationNode("road.stripes", DefaultPlotWorld.ROAD_STRIPES_DEFAULT, "Road stripe block", Configuration.BLOCK, true), new ConfigurationNode("wall.filling", DefaultPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true), new ConfigurationNode("wall.height", DefaultPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true),};
|
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),};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,11 +177,114 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
|
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
|
||||||
this.ROAD_WIDTH = config.getInt("road.width");
|
this.ROAD_WIDTH = config.getInt("road.width");
|
||||||
this.ROAD_HEIGHT = config.getInt("road.height");
|
this.ROAD_HEIGHT = config.getInt("road.height");
|
||||||
this.ROAD_STRIPES_ENABLED = config.getBoolean("road.enable_stripes");
|
|
||||||
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
|
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
|
||||||
this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes"));
|
|
||||||
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
||||||
this.WALL_HEIGHT = config.getInt("wall.height");
|
this.WALL_HEIGHT = config.getInt("wall.height");
|
||||||
this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block_claimed"));
|
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);
|
||||||
|
try {
|
||||||
|
if (true) {
|
||||||
|
setupSchematics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
PlotMain.sendConsoleSenderMessage("&c - road schematics are disabled for this world.");
|
||||||
|
this.ROAD_SCHEMATIC_ENABLED = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupSchematics() {
|
||||||
|
G_SCH_DATA = new HashMap<>();
|
||||||
|
G_SCH = new HashMap<>();
|
||||||
|
this.OFFSET = -1 + 1;
|
||||||
|
String schem1Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/sideroad";
|
||||||
|
String schem2Str = "GEN_ROAD_SCHEMATIC/" + worldname +"/intersection";
|
||||||
|
|
||||||
|
Schematic schem1 = SchematicHandler.getSchematic(schem1Str);
|
||||||
|
Schematic schem2 = SchematicHandler.getSchematic(schem2Str);
|
||||||
|
|
||||||
|
if (schem1 == null || schem2 == null || this.ROAD_WIDTH == 0) {
|
||||||
|
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&cInvalid generator schematic for world '" + worldname + "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataCollection[] blocks1 = schem1.getBlockCollection();
|
||||||
|
DataCollection[] blocks2 = schem2.getBlockCollection();
|
||||||
|
|
||||||
|
Dimension d1 = schem1.getSchematicDimension();
|
||||||
|
short w1 = (short) d1.getX();
|
||||||
|
short l1 = (short) d1.getZ();
|
||||||
|
short h1 = (short) d1.getY();
|
||||||
|
|
||||||
|
Dimension d2 = schem2.getSchematicDimension();
|
||||||
|
short w2 = (short) d2.getX();
|
||||||
|
short l2 = (short) d2.getZ();
|
||||||
|
short h2 = (short) d2.getY();
|
||||||
|
this.SCHEMATIC_HEIGHT = (short) Math.max(h2, h1);
|
||||||
|
|
||||||
|
for (short x = 0; x < w1; x++) {
|
||||||
|
for (short z = 0; z < l1; z++) {
|
||||||
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
|
for (short y = 0; y < h1; y++) {
|
||||||
|
int index = y * w1 * l1 + z * w1 + x;
|
||||||
|
|
||||||
|
short id = blocks1[index].getBlock();
|
||||||
|
byte data = blocks1[index].getData();
|
||||||
|
|
||||||
|
if (id != 0) {
|
||||||
|
addRoadBlock((short) (x - this.PATH_WIDTH_LOWER), (short) (y + this.OFFSET), (short) (z + this.PATH_WIDTH_LOWER + 1), id, data);
|
||||||
|
addRoadBlock((short) (z + this.PATH_WIDTH_LOWER + 1), (short) (y + this.OFFSET), (short) (x - this.PATH_WIDTH_LOWER), id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (short x = 0; x < w2; x++) {
|
||||||
|
for (short z = 0; z < l2; z++) {
|
||||||
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
|
for (short y = 0; y < h2; y++) {
|
||||||
|
int index = y * w2 * l2 + z * w2 + x;
|
||||||
|
|
||||||
|
short id = blocks2[index].getBlock();
|
||||||
|
byte data = blocks2[index].getData();
|
||||||
|
if (id != 0) {
|
||||||
|
addRoadBlock((short) (x - this.PATH_WIDTH_LOWER), (short) (y + this.OFFSET), (short) (z - this.PATH_WIDTH_LOWER), id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRoadBlock(short x, short y, short z, short id, byte data) {
|
||||||
|
if (z < 0) {
|
||||||
|
z += this.SIZE;
|
||||||
|
}
|
||||||
|
if (x < 0) {
|
||||||
|
x += this.SIZE;
|
||||||
|
}
|
||||||
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
|
if (!this.G_SCH.containsKey(loc)) {
|
||||||
|
this.G_SCH.put(loc, new HashMap<Short, Short>());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.G_SCH.get(loc).put(y, id);
|
||||||
|
|
||||||
|
if (data == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.G_SCH_DATA.containsKey(loc)) {
|
||||||
|
this.G_SCH_DATA.put(loc, new HashMap<Short, Byte>());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.G_SCH_DATA.get(loc).put(y, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,264 @@
|
|||||||
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Citymonstret
|
||||||
|
*/
|
||||||
|
public class HybridPop extends BlockPopulator {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sorry, this isn't well documented at the moment.
|
||||||
|
* We advise you to take a look at a world generation tutorial for
|
||||||
|
* information about how a BlockPopulator works.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final short plotsize;
|
||||||
|
final short pathsize;
|
||||||
|
final byte wall;
|
||||||
|
final byte wallfilling;
|
||||||
|
final byte roadblock;
|
||||||
|
final int size;
|
||||||
|
final int roadheight;
|
||||||
|
final int wallheight;
|
||||||
|
final int plotheight;
|
||||||
|
final byte[] plotfloors;
|
||||||
|
final byte[] filling;
|
||||||
|
private final HybridPlotWorld plotworld;
|
||||||
|
final short pathWidthLower;
|
||||||
|
final short pathWidthUpper;
|
||||||
|
Biome biome;
|
||||||
|
private int X;
|
||||||
|
private int Z;
|
||||||
|
private long state;
|
||||||
|
private boolean doFilling = false;
|
||||||
|
private boolean doFloor = false;
|
||||||
|
private boolean doState = false;
|
||||||
|
|
||||||
|
public HybridPop(final PlotWorld pw) {
|
||||||
|
this.plotworld = (HybridPlotWorld) pw;
|
||||||
|
|
||||||
|
// save configuration
|
||||||
|
|
||||||
|
this.plotsize = (short) this.plotworld.PLOT_WIDTH;
|
||||||
|
this.pathsize = (short) this.plotworld.ROAD_WIDTH;
|
||||||
|
|
||||||
|
this.roadblock = this.plotworld.ROAD_BLOCK.data;
|
||||||
|
|
||||||
|
this.wallfilling = this.plotworld.WALL_FILLING.data;
|
||||||
|
this.size = this.pathsize + this.plotsize;
|
||||||
|
this.wall = this.plotworld.WALL_BLOCK.data;
|
||||||
|
|
||||||
|
int count1 = 0;
|
||||||
|
int count2 = 0;
|
||||||
|
|
||||||
|
this.plotfloors = new byte[this.plotworld.TOP_BLOCK.length];
|
||||||
|
for (int i = 0; i < this.plotworld.TOP_BLOCK.length; i++) {
|
||||||
|
count1++;
|
||||||
|
this.plotfloors[i] = this.plotworld.TOP_BLOCK[i].data;
|
||||||
|
if (this.plotworld.TOP_BLOCK[i].data != 0) {
|
||||||
|
this.doFloor = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.filling = new byte[this.plotworld.MAIN_BLOCK.length];
|
||||||
|
for (int i = 0; i < this.plotworld.MAIN_BLOCK.length; i++) {
|
||||||
|
count2++;
|
||||||
|
this.filling[i] = this.plotworld.MAIN_BLOCK[i].data;
|
||||||
|
if (this.plotworld.MAIN_BLOCK[i].data != 0) {
|
||||||
|
this.doFilling = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((count1 > 0 && doFloor) || (count2 > 0 && doFilling)) {
|
||||||
|
doState = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wallheight = this.plotworld.WALL_HEIGHT;
|
||||||
|
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
||||||
|
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
||||||
|
|
||||||
|
if ((this.pathsize % 2) == 0) {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
|
||||||
|
} else {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final long nextLong() {
|
||||||
|
final long a = this.state;
|
||||||
|
this.state = xorShift64(a);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final long xorShift64(long a) {
|
||||||
|
a ^= (a << 21);
|
||||||
|
a ^= (a >>> 35);
|
||||||
|
a ^= (a << 4);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int random(final int n) {
|
||||||
|
final long result = ((nextLong() >>> 32) * n) >> 32;
|
||||||
|
return (int) result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(final World w, final Random r, final Chunk c) {
|
||||||
|
// initializing with bedrock pre-made
|
||||||
|
int cx = c.getX(), cz = c.getZ();
|
||||||
|
|
||||||
|
if (doState) {
|
||||||
|
final int prime = 13;
|
||||||
|
int h = 1;
|
||||||
|
h = (prime * h) + cx;
|
||||||
|
h = (prime * h) + cz;
|
||||||
|
this.state = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.X = cx << 4;
|
||||||
|
this.Z = cz << 4;
|
||||||
|
|
||||||
|
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(w);
|
||||||
|
RegionWrapper plot = manager.CURRENT_PLOT_CLEAR;
|
||||||
|
if (plot != null) {
|
||||||
|
|
||||||
|
short sx = (short) ((X) % this.size);
|
||||||
|
short sz = (short) ((Z) % this.size);
|
||||||
|
|
||||||
|
if (sx < 0) {
|
||||||
|
sx += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sz < 0) {
|
||||||
|
sz += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
if (isIn(plot, X + x, Z + z)) {
|
||||||
|
if (doFilling) {
|
||||||
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
|
setBlock(w, x, y, z, this.filling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (doFloor) {
|
||||||
|
setBlock(w, x,(short) this.plotheight, z, this.plotfloors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ChunkLoc loc = new ChunkLoc(X + x, Z + z);
|
||||||
|
HashMap<Short, Byte> data = manager.GENERATE_DATA.get(loc);
|
||||||
|
if (data != null) {
|
||||||
|
for (short y : data.keySet()) {
|
||||||
|
setBlock(w, x, y, z, data.get(y).byteValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
short sx = (short) ((X) % this.size);
|
||||||
|
short sz = (short) ((Z) % this.size);
|
||||||
|
|
||||||
|
if (sx < 0) {
|
||||||
|
sx += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sz < 0) {
|
||||||
|
sz += this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting biomes
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
|
||||||
|
short absX = (short) ((sx + x) % this.size);
|
||||||
|
short absZ = (short) ((sz + z) % this.size);
|
||||||
|
|
||||||
|
boolean gx = absX > pathWidthLower;
|
||||||
|
boolean gz = absZ > pathWidthLower;
|
||||||
|
|
||||||
|
boolean lx = absX < pathWidthUpper;
|
||||||
|
boolean lz = absZ < pathWidthUpper;
|
||||||
|
|
||||||
|
// inside plot
|
||||||
|
if (gx && gz && lx && lz) {
|
||||||
|
if (doFilling) {
|
||||||
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
|
setBlock(w, x, y, z, this.filling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (doFloor) {
|
||||||
|
setBlock(w, x, (short) this.plotheight, z, this.plotfloors);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// wall
|
||||||
|
if ((absX >= pathWidthLower && absX <= pathWidthUpper && absZ >= pathWidthLower && absZ <= pathWidthUpper))
|
||||||
|
{
|
||||||
|
if (this.wallfilling != 0) {
|
||||||
|
for (short y = 1; y <= this.wallheight; y++) {
|
||||||
|
setBlock(w, x, y, z, this.wallfilling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.wall != 0 && !this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
setBlock(w, x, (short) (this.wallheight + 1), z, this.wall);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// road
|
||||||
|
else {
|
||||||
|
if (this.roadblock != 0) {
|
||||||
|
for (short y = 1; y <= this.roadheight; y++) {
|
||||||
|
setBlock(w, x, y, z, this.roadblock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
ChunkLoc loc = new ChunkLoc(absX, absZ);
|
||||||
|
HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
||||||
|
if (blocks != null) {
|
||||||
|
for (short y : blocks.keySet()) {
|
||||||
|
setBlock(w, x, (short) (this.roadheight + y), z, blocks.get(y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBlock(final World w, short x, short y, short z, byte[] blkids) {
|
||||||
|
if (blkids.length == 1) {
|
||||||
|
setBlock(w, x, y, z, blkids[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final int i = random(blkids.length);
|
||||||
|
setBlock(w, x, y, z, blkids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private void setBlock(final World w, final short x, final short y, final short z, final byte val) {
|
||||||
|
w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIn(RegionWrapper plot, int x, int z) {
|
||||||
|
return (x >= plot.minX && x <= plot.maxX && z >= plot.minZ && z <= plot.maxZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,552 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
||||||
// /
|
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
|
||||||
// it under the terms of the GNU General Public License as published by /
|
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
|
||||||
// (at your option) any later version. /
|
|
||||||
// /
|
|
||||||
// This program is distributed in the hope that it will be useful, /
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
||||||
// GNU General Public License for more details. /
|
|
||||||
// /
|
|
||||||
// You should have received a copy of the GNU General Public License /
|
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
||||||
// /
|
|
||||||
// You can contact us via: support@intellectualsites.com /
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.generator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.generator.BlockPopulator;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
|
||||||
* You will see a lot of slower implementations have a single for loop. - This is perfectly fine to do, it will just
|
|
||||||
* mean world generation may take somewhat longer
|
|
||||||
*
|
|
||||||
* @author Citymonstret
|
|
||||||
* @author Empire92
|
|
||||||
*/
|
|
||||||
public class WorldGenerator extends PlotGenerator {
|
|
||||||
/**
|
|
||||||
* Set to static to re-use the same managet for all Default World Generators
|
|
||||||
*/
|
|
||||||
private static PlotManager manager = null;
|
|
||||||
/**
|
|
||||||
* Some generator specific variables (implementation dependent)
|
|
||||||
*/
|
|
||||||
final int plotsize;
|
|
||||||
final int pathsize;
|
|
||||||
final PlotBlock wall;
|
|
||||||
final PlotBlock wallfilling;
|
|
||||||
final PlotBlock floor1;
|
|
||||||
final PlotBlock floor2;
|
|
||||||
final int size;
|
|
||||||
final Biome biome;
|
|
||||||
final int roadheight;
|
|
||||||
final int wallheight;
|
|
||||||
final int plotheight;
|
|
||||||
final PlotBlock[] plotfloors;
|
|
||||||
final PlotBlock[] filling;
|
|
||||||
/**
|
|
||||||
* result object is returned for each generated chunk, do stuff to it
|
|
||||||
*/
|
|
||||||
short[][] result;
|
|
||||||
/**
|
|
||||||
* plotworld object
|
|
||||||
*/
|
|
||||||
DefaultPlotWorld plotworld = null;
|
|
||||||
/**
|
|
||||||
* Faster sudo-random number generator than java.util.random
|
|
||||||
*/
|
|
||||||
private long state;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize variables, and create plotworld object used in calculations
|
|
||||||
*/
|
|
||||||
public WorldGenerator(final String world) {
|
|
||||||
super(world);
|
|
||||||
|
|
||||||
if (this.plotworld == null) {
|
|
||||||
this.plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
|
|
||||||
}
|
|
||||||
this.plotsize = this.plotworld.PLOT_WIDTH;
|
|
||||||
|
|
||||||
this.pathsize = this.plotworld.ROAD_WIDTH;
|
|
||||||
|
|
||||||
this.floor1 = this.plotworld.ROAD_BLOCK;
|
|
||||||
this.floor2 = this.plotworld.ROAD_STRIPES;
|
|
||||||
|
|
||||||
this.wallfilling = this.plotworld.WALL_FILLING;
|
|
||||||
this.size = this.pathsize + this.plotsize;
|
|
||||||
this.wall = this.plotworld.WALL_BLOCK;
|
|
||||||
|
|
||||||
this.plotfloors = this.plotworld.TOP_BLOCK;
|
|
||||||
this.filling = this.plotworld.MAIN_BLOCK;
|
|
||||||
this.wallheight = this.plotworld.WALL_HEIGHT;
|
|
||||||
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
|
||||||
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
|
||||||
|
|
||||||
this.biome = this.plotworld.PLOT_BIOME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the plot manager for this type of generator, or create one For square plots you may as well use the
|
|
||||||
* default plot manager which comes with PlotSquared
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public PlotManager getPlotManager() {
|
|
||||||
if (manager == null) {
|
|
||||||
manager = new DefaultPlotManager();
|
|
||||||
}
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow spawning everywhere
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean canSpawn(final World world, final int x, final int z) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public PlotWorld getNewPlotWorld(final String world) {
|
|
||||||
this.plotworld = new DefaultPlotWorld(world);
|
|
||||||
return this.plotworld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long nextLong() {
|
|
||||||
final long a = this.state;
|
|
||||||
this.state = xorShift64(a);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long xorShift64(long a) {
|
|
||||||
a ^= (a << 21);
|
|
||||||
a ^= (a >>> 35);
|
|
||||||
a ^= (a << 4);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int random(final int n) {
|
|
||||||
final long r = ((nextLong() >>> 32) * n) >> 32;
|
|
||||||
return (int) r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cuboid based plot generation is quick, as it requires no calculations inside the loop - You don't have to use
|
|
||||||
* this this method, but you may find it useful.
|
|
||||||
*/
|
|
||||||
public void setCuboidRegion(final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock block) {
|
|
||||||
for (int x = x1; x < x2; x++) {
|
|
||||||
for (int z = z1; z < z2; z++) {
|
|
||||||
for (int y = y1; y < y2; y++) {
|
|
||||||
setBlock(this.result, x, y, z, block.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCuboidRegion(final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
|
||||||
if (blocks.length == 1) {
|
|
||||||
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]);
|
|
||||||
} else {
|
|
||||||
for (int x = x1; x < x2; x++) {
|
|
||||||
for (int z = z1; z < z2; z++) {
|
|
||||||
for (int y = y1; y < y2; y++) {
|
|
||||||
final int i = random(blocks.length);
|
|
||||||
setBlock(this.result, x, y, z, blocks[i].id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard setblock method for world generation
|
|
||||||
*/
|
|
||||||
private void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) {
|
|
||||||
if (result[y >> 4] == null) {
|
|
||||||
result[y >> 4] = new short[4096];
|
|
||||||
}
|
|
||||||
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the block populator
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
|
||||||
// disabling spawning for this world
|
|
||||||
if (!this.plotworld.MOB_SPAWNING) {
|
|
||||||
world.setSpawnFlags(false, false);
|
|
||||||
world.setAmbientSpawnLimit(0);
|
|
||||||
world.setAnimalSpawnLimit(0);
|
|
||||||
world.setMonsterSpawnLimit(0);
|
|
||||||
world.setWaterAnimalSpawnLimit(0);
|
|
||||||
}
|
|
||||||
// You can have as many populators as you would like, e.g. tree
|
|
||||||
// populator, ore populator
|
|
||||||
return Arrays.asList((BlockPopulator) new XPopulator(this.plotworld));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the default spawn location for this world
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Location getFixedSpawnLocation(final World world, final Random random) {
|
|
||||||
return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world
|
|
||||||
* generator
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public short[][] generateExtBlockSections(final World world, final Random random, int cx, int cz, final BiomeGrid biomes) {
|
|
||||||
|
|
||||||
final int maxY = world.getMaxHeight();
|
|
||||||
this.result = new short[maxY / 16][];
|
|
||||||
|
|
||||||
final int prime = 31;
|
|
||||||
int h = 1;
|
|
||||||
h = (prime * h) + cx;
|
|
||||||
h = (prime * h) + cz;
|
|
||||||
this.state = h;
|
|
||||||
|
|
||||||
double pathWidthLower;
|
|
||||||
if ((this.pathsize % 2) == 0) {
|
|
||||||
pathWidthLower = Math.floor(this.pathsize / 2) - 1;
|
|
||||||
} else {
|
|
||||||
pathWidthLower = Math.floor(this.pathsize / 2);
|
|
||||||
}
|
|
||||||
cx = (cx % this.size) + (8 * this.size);
|
|
||||||
cz = (cz % this.size) + (8 * this.size);
|
|
||||||
final int absX = (int) ((((cx * 16) + 16) - pathWidthLower - 1) + (8 * this.size));
|
|
||||||
final int absZ = (int) ((((cz * 16) + 16) - pathWidthLower - 1) + (8 * this.size));
|
|
||||||
final int plotMinX = (((absX) % this.size));
|
|
||||||
final int plotMinZ = (((absZ) % this.size));
|
|
||||||
int roadStartX = (plotMinX + this.pathsize);
|
|
||||||
int roadStartZ = (plotMinZ + this.pathsize);
|
|
||||||
if (roadStartX >= this.size) {
|
|
||||||
roadStartX -= this.size;
|
|
||||||
}
|
|
||||||
if (roadStartZ >= this.size) {
|
|
||||||
roadStartZ -= this.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// BOTTOM (1/1 cuboids)
|
|
||||||
for (int x = 0; x < 16; x++) {
|
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
setBlock(this.result, x, 0, z, (short) 7);
|
|
||||||
biomes.setBiome(x, z, this.biome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ROAD (0/24) The following is an inefficient placeholder as it is too
|
|
||||||
// much work to finish it
|
|
||||||
if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
|
|
||||||
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1);
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
|
|
||||||
final int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1);
|
|
||||||
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
|
|
||||||
if ((start >= 0) && (start <= 16) && (end < 0)) {
|
|
||||||
end = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1);
|
|
||||||
}
|
|
||||||
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
|
|
||||||
final int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
|
|
||||||
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
|
|
||||||
if ((start >= 0) && (start <= 16) && (end < 0)) {
|
|
||||||
end = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ROAD STRIPES
|
|
||||||
if ((this.pathsize > 4) && this.plotworld.ROAD_STRIPES_ENABLED) {
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
final int value = (plotMinZ + 2);
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
start = 16 - plotMinX - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX - 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); //
|
|
||||||
setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); //
|
|
||||||
}
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
final int value = (plotMinX + 2);
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
start = 16 - plotMinZ - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ - 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
|
|
||||||
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
|
||||||
}
|
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
start = 16 - plotMinX - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX - 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2);
|
|
||||||
setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2);
|
|
||||||
}
|
|
||||||
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
start = 16 - plotMinZ - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ - 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
|
|
||||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plot filling (28/28 cuboids) (10x2 + 4x2)
|
|
||||||
if (this.plotsize > 16) {
|
|
||||||
if (roadStartX <= 16) {
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
|
||||||
}
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
if (plotMinX > 16) {
|
|
||||||
setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
|
||||||
setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plotMinX <= 16) {
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
|
||||||
} else {
|
|
||||||
int z = 16 - roadStartZ;
|
|
||||||
if (z < 0) {
|
|
||||||
z = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
|
|
||||||
}
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
|
||||||
} else {
|
|
||||||
if (roadStartX <= 16) {
|
|
||||||
if (plotMinZ > 16) {
|
|
||||||
int x = 16 - roadStartX;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
if (roadStartX > 16) {
|
|
||||||
int x = 16 - roadStartX;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (roadStartZ > 16) {
|
|
||||||
int x = 16 - roadStartX;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 16;
|
|
||||||
}
|
|
||||||
int z = 16 - roadStartZ;
|
|
||||||
if (z < 0) {
|
|
||||||
z = 16;
|
|
||||||
}
|
|
||||||
if (roadStartX > 16) {
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
|
|
||||||
} else {
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (roadStartX <= 16) {
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
|
||||||
}
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plotMinX <= 16) {
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
|
||||||
}
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WALLS (16/16 cuboids)
|
|
||||||
if (this.pathsize > 0) {
|
|
||||||
if ((plotMinZ + 1) <= 16) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
start = 16 - plotMinX - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX - 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
|
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
|
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
|
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
|
|
||||||
}
|
|
||||||
if ((plotMinX + 1) <= 16) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
start = 16 - plotMinZ - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ - 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling);
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall);
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling);
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
|
|
||||||
}
|
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 1) <= 16) {
|
|
||||||
start = 16 - plotMinX;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX + 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
|
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
|
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
|
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
|
|
||||||
}
|
|
||||||
if ((roadStartX <= 16) && (roadStartX > 0)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 1) <= 16) {
|
|
||||||
start = 16 - plotMinZ;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ + 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling);
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall);
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling);
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Return the chunk
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,466 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
||||||
// /
|
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
|
||||||
// it under the terms of the GNU General Public License as published by /
|
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
|
||||||
// (at your option) any later version. /
|
|
||||||
// /
|
|
||||||
// This program is distributed in the hope that it will be useful, /
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
||||||
// GNU General Public License for more details. /
|
|
||||||
// /
|
|
||||||
// You should have received a copy of the GNU General Public License /
|
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
||||||
// /
|
|
||||||
// You can contact us via: support@intellectualsites.com /
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.generator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.generator.BlockPopulator;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Citymonstret
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused") public class XPopulator extends BlockPopulator {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sorry, this isn't well documented at the moment.
|
|
||||||
* We advise you to take a look at a world generation tutorial for
|
|
||||||
* information about how a BlockPopulator works.
|
|
||||||
*/
|
|
||||||
|
|
||||||
final int plotsize;
|
|
||||||
final int pathsize;
|
|
||||||
final PlotBlock wall;
|
|
||||||
final PlotBlock wallfilling;
|
|
||||||
final PlotBlock floor1;
|
|
||||||
final PlotBlock floor2;
|
|
||||||
final int size;
|
|
||||||
final int roadheight;
|
|
||||||
final int wallheight;
|
|
||||||
final int plotheight;
|
|
||||||
final PlotBlock[] plotfloors;
|
|
||||||
final PlotBlock[] filling;
|
|
||||||
private final DefaultPlotWorld plotworld;
|
|
||||||
final private double pathWidthLower;
|
|
||||||
Biome biome;
|
|
||||||
private int X;
|
|
||||||
private int Z;
|
|
||||||
private long state;
|
|
||||||
|
|
||||||
public XPopulator(final PlotWorld pw) {
|
|
||||||
this.plotworld = (DefaultPlotWorld) pw;
|
|
||||||
|
|
||||||
// save configuration
|
|
||||||
|
|
||||||
this.plotsize = this.plotworld.PLOT_WIDTH;
|
|
||||||
this.pathsize = this.plotworld.ROAD_WIDTH;
|
|
||||||
|
|
||||||
this.floor1 = this.plotworld.ROAD_BLOCK;
|
|
||||||
this.floor2 = this.plotworld.ROAD_STRIPES;
|
|
||||||
|
|
||||||
this.wallfilling = this.plotworld.WALL_FILLING;
|
|
||||||
this.size = this.pathsize + this.plotsize;
|
|
||||||
this.wall = this.plotworld.WALL_BLOCK;
|
|
||||||
|
|
||||||
this.plotfloors = this.plotworld.TOP_BLOCK;
|
|
||||||
this.filling = this.plotworld.MAIN_BLOCK;
|
|
||||||
|
|
||||||
this.wallheight = this.plotworld.WALL_HEIGHT;
|
|
||||||
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
|
||||||
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
|
||||||
|
|
||||||
if ((this.pathsize % 2) == 0) {
|
|
||||||
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
|
|
||||||
} else {
|
|
||||||
this.pathWidthLower = Math.floor(this.pathsize / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long nextLong() {
|
|
||||||
final long a = this.state;
|
|
||||||
this.state = xorShift64(a);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long xorShift64(long a) {
|
|
||||||
a ^= (a << 21);
|
|
||||||
a ^= (a >>> 35);
|
|
||||||
a ^= (a << 4);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int random(final int n) {
|
|
||||||
final long result = ((nextLong() >>> 32) * n) >> 32;
|
|
||||||
return (int) result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCuboidRegion(final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock block, final World w) {
|
|
||||||
if (block.data == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int x = x1; x < x2; x++) {
|
|
||||||
for (int z = z1; z < z2; z++) {
|
|
||||||
for (int y = y1; y < y2; y++) {
|
|
||||||
setBlock(w, x, y, z, block.id, block.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCuboidRegion(final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks, final World w) {
|
|
||||||
if (blocks.length == 1) {
|
|
||||||
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0], w);
|
|
||||||
} else {
|
|
||||||
for (int x = x1; x < x2; x++) {
|
|
||||||
for (int z = z1; z < z2; z++) {
|
|
||||||
for (int y = y1; y < y2; y++) {
|
|
||||||
final int i = random(blocks.length);
|
|
||||||
if (blocks[i].data != 0) {
|
|
||||||
setBlock(w, x, y, z, blocks[i].id, blocks[i].data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public short[] getBlock(final String block) {
|
|
||||||
if (block.contains(":")) {
|
|
||||||
final String[] split = block.split(":");
|
|
||||||
return new short[]{Short.parseShort(split[0]), Short.parseShort(split[1])};
|
|
||||||
}
|
|
||||||
return new short[]{Short.parseShort(block), 0};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void populate(final World w, final Random r, final Chunk c) {
|
|
||||||
int cx = c.getX(), cz = c.getZ();
|
|
||||||
|
|
||||||
final int prime = 31;
|
|
||||||
int h = 1;
|
|
||||||
h = (prime * h) + cx;
|
|
||||||
h = (prime * h) + cz;
|
|
||||||
this.state = h;
|
|
||||||
|
|
||||||
this.X = cx << 4;
|
|
||||||
this.Z = cz << 4;
|
|
||||||
cx = (cx % this.size) + (8 * this.size);
|
|
||||||
cz = (cz % this.size) + (8 * this.size);
|
|
||||||
final double absX = ((((cx * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)), absZ = ((((cz * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size));
|
|
||||||
final int plotMinX = (int) (((absX) % this.size));
|
|
||||||
final int plotMinZ = (int) (((absZ) % this.size));
|
|
||||||
int roadStartX = (plotMinX + this.pathsize);
|
|
||||||
int roadStartZ = (plotMinZ + this.pathsize);
|
|
||||||
if (roadStartX >= this.size) {
|
|
||||||
roadStartX -= this.size;
|
|
||||||
}
|
|
||||||
if (roadStartZ >= this.size) {
|
|
||||||
roadStartZ -= this.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ROADS
|
|
||||||
|
|
||||||
if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
|
|
||||||
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1, w);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
|
|
||||||
final int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1);
|
|
||||||
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
|
|
||||||
if ((start >= 0) && (start <= 16) && (end < 0)) {
|
|
||||||
end = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1, w);
|
|
||||||
}
|
|
||||||
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
|
|
||||||
final int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
|
|
||||||
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
|
|
||||||
if ((start >= 0) && (start <= 16) && (end < 0)) {
|
|
||||||
end = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1, w);
|
|
||||||
}
|
|
||||||
|
|
||||||
// STRIPES
|
|
||||||
if ((this.pathsize > 4) && this.plotworld.ROAD_STRIPES_ENABLED) {
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
final int value = (plotMinZ + 2);
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
start = 16 - plotMinX - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX - 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.floor2, w); //
|
|
||||||
setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.floor2, w); //
|
|
||||||
}
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
final int value = (plotMinX + 2);
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
start = 16 - plotMinZ - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ - 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
|
|
||||||
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
|
|
||||||
}
|
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
start = 16 - plotMinX - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX - 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2, w);
|
|
||||||
setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2, w);
|
|
||||||
}
|
|
||||||
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
start = 16 - plotMinZ - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ - 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
|
|
||||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// WALLS
|
|
||||||
if (this.pathsize > 0) {
|
|
||||||
if ((plotMinZ + 1) <= 16) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 2) <= 16) {
|
|
||||||
start = 16 - plotMinX - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX - 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
|
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w);
|
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
|
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w);
|
|
||||||
}
|
|
||||||
if ((plotMinX + 1) <= 16) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 2) <= 16) {
|
|
||||||
start = 16 - plotMinZ - 1;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ - 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall, w);
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w);
|
|
||||||
}
|
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinX + 1) <= 16) {
|
|
||||||
start = 16 - plotMinX;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartX + 1) <= 16) {
|
|
||||||
end = (16 - roadStartX) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w);
|
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w);
|
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w);
|
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w);
|
|
||||||
}
|
|
||||||
if ((roadStartX <= 16) && (roadStartX > 0)) {
|
|
||||||
int start, end;
|
|
||||||
if ((plotMinZ + 1) <= 16) {
|
|
||||||
start = 16 - plotMinZ;
|
|
||||||
} else {
|
|
||||||
start = 16;
|
|
||||||
}
|
|
||||||
if ((roadStartZ + 1) <= 16) {
|
|
||||||
end = (16 - roadStartZ) + 1;
|
|
||||||
} else {
|
|
||||||
end = 0;
|
|
||||||
}
|
|
||||||
if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling, w);
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall, w);
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling, w);
|
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PLOT
|
|
||||||
|
|
||||||
if (this.plotsize > 16) {
|
|
||||||
if (roadStartX <= 16) {
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
if (plotMinX > 16) {
|
|
||||||
setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
|
||||||
setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plotMinX <= 16) {
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
|
||||||
} else {
|
|
||||||
int z = 16 - roadStartZ;
|
|
||||||
if (z < 0) {
|
|
||||||
z = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
|
||||||
} else {
|
|
||||||
if (roadStartX <= 16) {
|
|
||||||
if (plotMinZ > 16) {
|
|
||||||
int x = 16 - roadStartX;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling, w);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
if (roadStartX > 16) {
|
|
||||||
int x = 16 - roadStartX;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 16;
|
|
||||||
}
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (roadStartZ > 16) {
|
|
||||||
int x = 16 - roadStartX;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 16;
|
|
||||||
}
|
|
||||||
int z = 16 - roadStartZ;
|
|
||||||
if (z < 0) {
|
|
||||||
z = 16;
|
|
||||||
}
|
|
||||||
if (roadStartX > 16) {
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
|
|
||||||
} else {
|
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w);
|
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (roadStartX <= 16) {
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plotMinX <= 16) {
|
|
||||||
if (plotMinZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
if (roadStartZ <= 16) {
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void setBlock(final World w, final int x, final int y, final int z, final short id, final byte val) {
|
|
||||||
w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
|
||||||
|
public class BlockLoc {
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int z;
|
||||||
|
|
||||||
|
public BlockLoc(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = (prime * result) + this.x;
|
||||||
|
result = (prime * result) + this.y;
|
||||||
|
result = (prime * result) + this.z;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BlockLoc other = (BlockLoc) obj;
|
||||||
|
return ((this.x == other.x) && (this.y == other.y) && (this.z == other.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
|
||||||
|
public class ChunkLoc {
|
||||||
|
public int x;
|
||||||
|
public int z;
|
||||||
|
|
||||||
|
public ChunkLoc(int x, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = (prime * result) + this.x;
|
||||||
|
result = (prime * result) + this.z;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ChunkLoc other = (ChunkLoc) obj;
|
||||||
|
return ((this.x == other.x) && (this.z == other.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
public class PlotLoc {
|
||||||
|
public short x;
|
||||||
|
public short z;
|
||||||
|
|
||||||
|
public PlotLoc(short x, short z) {
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = (prime * result) + this.x;
|
||||||
|
result = (prime * result) + this.z;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlotLoc other = (PlotLoc) obj;
|
||||||
|
return ((this.x == other.x) && (this.z == other.z));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class RegionWrapper {
|
||||||
|
public final int minX;
|
||||||
|
public final int maxX;
|
||||||
|
public final int minZ;
|
||||||
|
public final int maxZ;
|
||||||
|
|
||||||
|
public RegionWrapper(int minX, int maxX, int minZ, int maxZ) {
|
||||||
|
this.maxX = maxX;
|
||||||
|
this.minX = minX;
|
||||||
|
this.maxZ = maxZ;
|
||||||
|
this.minZ = minZ;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user