mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Various
sponge changes / documentation / cleanup / event tweak
This commit is contained in:
@ -58,7 +58,7 @@ public class Auto extends SubCommand {
|
||||
return new PlotId(id.x + 1, id.y);
|
||||
}
|
||||
} else {
|
||||
if (id.x.equals(id.y) && (id.x > 0)) {
|
||||
if (id.x == id.y && (id.x > 0)) {
|
||||
return new PlotId(id.x, id.y + step);
|
||||
}
|
||||
if (id.x == absX) {
|
||||
@ -159,6 +159,7 @@ public class Auto extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// TODO handle type 2 the same as normal worlds!
|
||||
if (plotarea.TYPE == 2) {
|
||||
final PlotId bot = plotarea.getMin();
|
||||
final PlotId top = plotarea.getMax();
|
||||
@ -180,34 +181,26 @@ public class Auto extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_FREE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
boolean br = false;
|
||||
if ((size_x == 1) && (size_z == 1)) {
|
||||
while (!br) {
|
||||
Plot plot = plotarea.getPlotAbs(getLastPlotId(plotarea));
|
||||
if (plot.canClaim(plr)) {
|
||||
plot.claim(plr, true, null);
|
||||
br = true;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", getNextPlotId(plot.getId(), 1));
|
||||
}
|
||||
} else {
|
||||
while (!br) {
|
||||
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
plotarea.setMeta("lastPlot", start);
|
||||
if (plotarea.canClaim(plr, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
plot.claim(plr, teleport, null);
|
||||
}
|
||||
while (true) {
|
||||
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
plotarea.setMeta("lastPlot", start);
|
||||
if (plotarea.canClaim(plr, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
plot.claim(plr, teleport, null);
|
||||
}
|
||||
}
|
||||
if ((size_x != 1) || (size_z != 1)) {
|
||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
|
||||
return false;
|
||||
}
|
||||
br = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
|
@ -68,7 +68,7 @@ public class Buy extends SubCommand {
|
||||
}
|
||||
} else {
|
||||
plot = loc.getPlotAbs();
|
||||
plots = plot.getConnectedPlots();
|
||||
plots = plot != null ? plot.getConnectedPlots() : null;
|
||||
}
|
||||
if (plots == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
|
@ -8,6 +8,11 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
|
||||
/**
|
||||
* This class allows for implementation independent world generation<br>
|
||||
* - Sponge/Bukkit API<br><br>
|
||||
* Use the specify method to get the generator for that platform.
|
||||
*/
|
||||
public abstract class IndependentPlotGenerator {
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* The plot class
|
||||
* The plot class<br>
|
||||
* [IMPORTANT]
|
||||
* - Unclaimed plots will not have persistent information.
|
||||
* - Any information set/modified in an unclaimed object may not be reflected in other instances
|
||||
* - Using the `new` operator will create an unclaimed plot instance
|
||||
* - Use the methods from the PlotArea/PS/Location etc to get existing plots
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Plot {
|
||||
@ -211,7 +216,13 @@ public class Plot {
|
||||
this.timestamp = timestamp;
|
||||
this.temp = temp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a plot from a string e.g. [area];[id]
|
||||
* @param defaultArea If no area is specified
|
||||
* @param string plot id/area + id
|
||||
* @return New or existing plot object
|
||||
*/
|
||||
public static Plot fromString(final PlotArea defaultArea, final String string) {
|
||||
final String[] split = string.split(";|,");
|
||||
if (split.length == 2) {
|
||||
@ -430,7 +441,13 @@ public class Plot {
|
||||
public PlotArea getArea() {
|
||||
return this.area;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign this plot to a plot area.<br>
|
||||
* (Mostly used during startup when worlds are being created)<br>
|
||||
* Note: Using this when it doesn't make sense will result in strange behavior
|
||||
* @param area
|
||||
*/
|
||||
public void setArea(final PlotArea area) {
|
||||
if (this.getArea() == area) {
|
||||
return;
|
||||
@ -497,7 +514,7 @@ public class Plot {
|
||||
this.origin = this;
|
||||
PlotId min = this.id;
|
||||
for (final Plot plot : this.getConnectedPlots()) {
|
||||
if ((plot.id.y < min.y) || (plot.id.y.equals(min.y) && (plot.id.x < min.x))) {
|
||||
if ((plot.id.y < min.y) || (plot.id.y == min.y && plot.id.x < min.x)) {
|
||||
this.origin = plot;
|
||||
min = plot.id;
|
||||
}
|
||||
@ -1022,7 +1039,12 @@ public class Plot {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrement the number of tracked tasks this plot is running<br>
|
||||
* - Used to track/limit the number of things a player can do on the plot at once
|
||||
* @return previous number of tasks (int)
|
||||
*/
|
||||
public int removeRunning() {
|
||||
final int value = this.getRunning();
|
||||
if (value < 2) {
|
||||
@ -1036,12 +1058,22 @@ public class Plot {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of tracked running tasks for this plot<br>
|
||||
* - Used to track/limit the number of things a player can do on the plot at once
|
||||
* @return number of tasks (int)
|
||||
*/
|
||||
public int getRunning() {
|
||||
final Integer value = (Integer) this.getMeta("running");
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unclaim the plot (does not modify terrain)<br>
|
||||
* - Changes made to this plot will not be reflected in unclaimed plot objects<br>
|
||||
* @return
|
||||
*/
|
||||
public boolean unclaim() {
|
||||
if (owner == null) {
|
||||
return false;
|
||||
@ -1759,7 +1791,7 @@ public class Plot {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
@ -1776,8 +1808,10 @@ public class Plot {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot hashcode
|
||||
*
|
||||
* Get the plot hashcode<br>
|
||||
* Note: The hashcode is unique if:<br>
|
||||
* - Plots are in the same world<br>
|
||||
* - The x,z coordinates are between Short.MIN_VALUE and Short.MAX_VALUE<br>
|
||||
* @return integer.
|
||||
*/
|
||||
@Override
|
||||
@ -1853,7 +1887,7 @@ public class Plot {
|
||||
if (value) {
|
||||
final Plot other = this.getRelative(direction).getBasePlot(false);
|
||||
if (!other.equals(this.getBasePlot(false))) {
|
||||
final Plot base = (other.id.y < this.id.y) || (other.id.y.equals(this.id.y) && (other.id.x < this.id.x)) ? other : this.origin;
|
||||
final Plot base = (other.id.y < this.id.y) || (other.id.y == this.id.y && (other.id.x < this.id.x)) ? other : this.origin;
|
||||
this.origin.origin = base;
|
||||
other.origin = base;
|
||||
this.origin = base;
|
||||
@ -1919,7 +1953,12 @@ public class Plot {
|
||||
}
|
||||
return this.settings.getPosition();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a plot can be claimed
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean canClaim(final PlotPlayer player) {
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
final PlotCluster cluster = this.getCluster();
|
||||
@ -1929,9 +1968,14 @@ public class Plot {
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.guessOwner() == null;
|
||||
return this.guessOwner() == null && !isMerged();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Guess the owner of a plot either by the value in memory, or the sign data<br>
|
||||
* Note: Recovering from sign information is useful if e.g. PlotMe conversion wasn't successful
|
||||
* @return UUID
|
||||
*/
|
||||
public UUID guessOwner() {
|
||||
if (this.hasOwner()) {
|
||||
return this.owner;
|
||||
@ -2137,7 +2181,10 @@ public class Plot {
|
||||
this.addDenied(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the SE road (only effects terrain)
|
||||
*/
|
||||
public void removeRoadSouthEast() {
|
||||
if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) {
|
||||
if (this.area.TERRAIN == 3) {
|
||||
@ -2153,11 +2200,28 @@ public class Plot {
|
||||
this.area.getPlotManager().removeRoadSouthEast(this.area, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot in a relative location<br>
|
||||
* Note: May be null if the partial plot area does not include the relative location
|
||||
* @param x
|
||||
* @param y
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getRelative(final int x, final int y) {
|
||||
return this.area.getPlotAbs(this.id.getRelative(x, y));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot in a relative direction<br>
|
||||
* 0 = north<br>
|
||||
* 1 = east<br>
|
||||
* 2 = south<br>
|
||||
* 3 = west<br>
|
||||
* Note: May be null if the partial plot area does not include the relative location
|
||||
* @param direction
|
||||
* @return
|
||||
*/
|
||||
public Plot getRelative(final int direction) {
|
||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||
}
|
||||
@ -2427,7 +2491,11 @@ public class Plot {
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do the plot entry tasks for each player in the plot<br>
|
||||
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
|
||||
*/
|
||||
public void reEnter() {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
@ -2564,7 +2632,7 @@ public class Plot {
|
||||
*/
|
||||
public void mergePlot(Plot lesserPlot, final boolean removeRoads) {
|
||||
Plot greaterPlot = this;
|
||||
if (lesserPlot.getId().x.equals(greaterPlot.getId().x)) {
|
||||
if (lesserPlot.getId().x == greaterPlot.getId().x) {
|
||||
if (lesserPlot.getId().y > greaterPlot.getId().y) {
|
||||
final Plot tmp = lesserPlot;
|
||||
lesserPlot = greaterPlot;
|
||||
|
@ -97,7 +97,13 @@ public abstract class PlotArea {
|
||||
}
|
||||
this.worldhash = worldname.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PlotArea object with no functionality/information<br>
|
||||
* - Mainly used during startup before worlds are created as a temporary object
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
public static PlotArea createGeneric(String world) {
|
||||
return new PlotArea(world, null, null, null, null) {
|
||||
@Override
|
||||
@ -108,8 +114,9 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the region for this PlotArea
|
||||
* @return
|
||||
* Returns the region for this PlotArea or a RegionWrapper encompassing the whole world if none exists
|
||||
* @NotNull
|
||||
* @return RegionWrapper
|
||||
*/
|
||||
public RegionWrapper getRegion() {
|
||||
region = getRegionAbs();
|
||||
@ -118,7 +125,12 @@ public abstract class PlotArea {
|
||||
}
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the region for this PlotArea
|
||||
* @Nullable
|
||||
* @return RegionWrapper or null if no applicable region
|
||||
*/
|
||||
public RegionWrapper getRegionAbs() {
|
||||
if (region == null) {
|
||||
if (min != null) {
|
||||
@ -146,6 +158,11 @@ public abstract class PlotArea {
|
||||
return max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the implementation independent generator for this area
|
||||
* @Nullable
|
||||
* @return
|
||||
*/
|
||||
public IndependentPlotGenerator getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
@ -169,6 +186,11 @@ public abstract class PlotArea {
|
||||
return clusters == null ? new HashSet<PlotCluster>() : clusters.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a PlotArea is compatible (move/copy etc)
|
||||
* @param plotarea
|
||||
* @return
|
||||
*/
|
||||
public boolean isCompatible(PlotArea plotarea) {
|
||||
final ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
||||
for (final ConfigurationNode setting : plotarea.getSettingNodes()) {
|
||||
@ -358,7 +380,12 @@ public abstract class PlotArea {
|
||||
* @return ConfigurationNode[]
|
||||
*/
|
||||
public abstract ConfigurationNode[] getSettingNodes();
|
||||
|
||||
|
||||
/**
|
||||
* Get the Plot at a location
|
||||
* @param loc
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlotAbs(Location loc) {
|
||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||
if (pid == null) {
|
||||
@ -366,7 +393,12 @@ public abstract class PlotArea {
|
||||
}
|
||||
return getPlotAbs(pid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the base plot at a location
|
||||
* @param loc
|
||||
* @return base Plot
|
||||
*/
|
||||
public Plot getPlot(Location loc) {
|
||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||
if (pid == null) {
|
||||
@ -374,7 +406,12 @@ public abstract class PlotArea {
|
||||
}
|
||||
return getPlot(pid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the base owned plot at a location
|
||||
* @param loc
|
||||
* @return base Plot or null
|
||||
*/
|
||||
public Plot getOwnedPlot(Location loc) {
|
||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||
if (pid == null) {
|
||||
@ -383,7 +420,12 @@ public abstract class PlotArea {
|
||||
Plot plot = plots.get(pid);
|
||||
return plot == null ? null : plot.getBasePlot(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the owned plot at a location
|
||||
* @param loc
|
||||
* @return Plot or null
|
||||
*/
|
||||
public Plot getOwnedPlotAbs(Location loc) {
|
||||
PlotId pid = manager.getPlotId(this, loc.getX(), loc.getY(), loc.getZ());
|
||||
if (pid == null) {
|
||||
@ -391,7 +433,12 @@ public abstract class PlotArea {
|
||||
}
|
||||
return plots.get(pid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the owned Plot at a PlotId
|
||||
* @param id
|
||||
* @return Plot or null
|
||||
*/
|
||||
public Plot getOwnedPlotAbs(PlotId id) {
|
||||
return plots.get(id);
|
||||
}
|
||||
@ -688,7 +735,7 @@ public abstract class PlotArea {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = getPlot(id);
|
||||
final Plot plot = getPlotAbs(id);
|
||||
if (!plot.canClaim(player)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ public class PlotId {
|
||||
/**
|
||||
* x value
|
||||
*/
|
||||
public Integer x;
|
||||
public int x;
|
||||
/**
|
||||
* y value
|
||||
*/
|
||||
public Integer y;
|
||||
public int y;
|
||||
private int hash;
|
||||
|
||||
/**
|
||||
@ -68,10 +68,25 @@ public class PlotId {
|
||||
return new PlotId(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotId from the HashCode<br>
|
||||
* Note: Only accurate for small x,z values (short)
|
||||
* @param hash
|
||||
* @return
|
||||
*/
|
||||
public static PlotId unpair(int hash) {
|
||||
return new PlotId(hash >> 16, hash & 0xFFFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotId in a relative direction
|
||||
* 0 = north<br>
|
||||
* 1 = east<br>
|
||||
* 2 = south<br>
|
||||
* 3 = west<br>
|
||||
* @param direction
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getRelative(final int direction) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
@ -85,7 +100,13 @@ public class PlotId {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the PlotId in a relative location
|
||||
* @param x
|
||||
* @param y
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getRelative(int x, int y) {
|
||||
return new PlotId(this.x + x, this.y + y);
|
||||
}
|
||||
@ -98,18 +119,31 @@ public class PlotId {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.hashCode() != obj.hashCode()) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final PlotId other = (PlotId) obj;
|
||||
return ((x.equals(other.x)) && (y.equals(other.y)));
|
||||
return x == other.x && y == other.y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* e.g.
|
||||
* 5;-6
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + ";" + y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The PlotId object caches the hashcode for faster mapping/fetching/sorting<br>
|
||||
* - Recalculation is required if the x/y values change
|
||||
* TODO maybe make x/y values private and add this to the mutators
|
||||
*/
|
||||
public void recalculateHash() {
|
||||
hash = 0;
|
||||
hashCode();
|
||||
|
@ -1,8 +1,15 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
|
||||
/**
|
||||
* The PlotChunk class is primarily used for world generation and mass block placement.<br>
|
||||
* - With mass block placement, it is associated with a queue<br>
|
||||
* - World Generation has no queue, so don't use those methods in that case
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class PlotChunk<T> implements Cloneable {
|
||||
private ChunkWrapper chunk;
|
||||
private T objChunk;
|
||||
@ -31,43 +38,153 @@ public abstract class PlotChunk<T> implements Cloneable {
|
||||
return chunk.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this PlotChunk to the SetQueue for later block placement<br>
|
||||
* - Will cause issues if not the right type for the implementation
|
||||
*/
|
||||
public void addToQueue() {
|
||||
if (chunk == null) {
|
||||
throw new IllegalArgumentException("Chunk location cannot be null!");
|
||||
}
|
||||
((PlotQueue<T>) SetQueue.IMP.queue).setChunk(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force the queue to finish processing this chunk
|
||||
* @param fixLighting
|
||||
*/
|
||||
public void flush(boolean fixLighting) {
|
||||
((PlotQueue<T>) SetQueue.IMP.queue).next(getChunkWrapper(), fixLighting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the queue to fix lighting for this chunk
|
||||
*/
|
||||
public void fixLighting() {
|
||||
((PlotQueue<T>) SetQueue.IMP.queue).fixLighting(this, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill this chunk with a block
|
||||
* @param id
|
||||
* @param data
|
||||
*/
|
||||
public void fill(int id, byte data) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
fillCuboid(0, 15, 0, 255, 0, 15, id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill this chunk with blocks (random)
|
||||
* @param blocks
|
||||
*/
|
||||
public void fill(PlotBlock[] blocks) {
|
||||
fillCuboid(0, 15, 0, 255, 0, 15, blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a cuboid in this chunk with a block
|
||||
* @param x1
|
||||
* @param x2
|
||||
* @param y1
|
||||
* @param y2
|
||||
* @param z1
|
||||
* @param z2
|
||||
* @param id
|
||||
* @param data
|
||||
*/
|
||||
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, int id, byte data) {
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
setBlock(x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill a cuboid in this chunk with blocks
|
||||
* @param x1
|
||||
* @param x2
|
||||
* @param y1
|
||||
* @param y2
|
||||
* @param z1
|
||||
* @param z2
|
||||
* @param blocks
|
||||
*/
|
||||
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
|
||||
if (blocks.length == 1) {
|
||||
fillCuboid(x1, x2, y1, y2, z1, z2, blocks[0]);
|
||||
return;
|
||||
}
|
||||
if (chunk != null) {
|
||||
PseudoRandom.random.state = (chunk.x << 16) | (chunk.z & 0xFFFF);
|
||||
}
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
setBlock(x, y, z, blocks[PseudoRandom.random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a cuboid in this chunk with a block
|
||||
* @param x1
|
||||
* @param x2
|
||||
* @param y1
|
||||
* @param y2
|
||||
* @param z1
|
||||
* @param z2
|
||||
* @param block
|
||||
*/
|
||||
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block) {
|
||||
fillCuboid(x1, x2, y1, y2, z1, z2, block.id, block.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the implementation specific chunk
|
||||
* @Nullable If no location is tied to this container
|
||||
* @return Chunk
|
||||
*/
|
||||
public T getChunk() {
|
||||
return objChunk != null ? objChunk : getChunkAbs();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the implementation specific chunk (no caching)
|
||||
* @return
|
||||
*/
|
||||
public abstract T getChunkAbs();
|
||||
|
||||
/**
|
||||
* Set a block in this container
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param id
|
||||
* @param data
|
||||
*/
|
||||
public abstract void setBlock(final int x, final int y, final int z, final int id, final byte data);
|
||||
|
||||
|
||||
/**
|
||||
* Set a block in this container
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
*/
|
||||
public void setBlock(int x, int y, int z, PlotBlock block) {
|
||||
setBlock(x, y, z, block.id, block.data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a biome in this container
|
||||
* @param x
|
||||
* @param z
|
||||
* @param biome
|
||||
*/
|
||||
public abstract void setBiome(int x, int z, int biome);
|
||||
|
||||
@Override
|
||||
@ -87,9 +204,19 @@ public abstract class PlotChunk<T> implements Cloneable {
|
||||
public String toString() {
|
||||
return getChunkWrapper().toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to clone this PlotChunk object<br>
|
||||
* - Depending on the implementation, this may not work
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public abstract PlotChunk clone();
|
||||
|
||||
|
||||
/**
|
||||
* Attempt a shallow clone i.e. block mappings share the same reference<br>
|
||||
* - Depending on the implementation, this may not work
|
||||
* @return
|
||||
*/
|
||||
public abstract PlotChunk shallowClone();
|
||||
}
|
||||
|
Reference in New Issue
Block a user