mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
This commit is contained in:
parent
252fdefef3
commit
07fcd53bf8
@ -51,7 +51,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING);
|
||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
||||
if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) {
|
||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
||||
}
|
||||
return GlobalBlockQueue.IMP.addEmptyTask(whenDone);
|
||||
}
|
||||
|
||||
@ -409,44 +411,29 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
* @return false if part of the merge failed, otherwise true if successful.
|
||||
*/
|
||||
@Override public boolean finishPlotMerge(List<PlotId> plotIds) {
|
||||
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
boolean success = true;
|
||||
for (PlotId plotId : plotIds) {
|
||||
success &= setWall(plotId, block);
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||
for (PlotId plotId : plotIds) {
|
||||
setWall(plotId, claim);
|
||||
}
|
||||
}
|
||||
if (Settings.General.MERGE_REPLACE_WALL) {
|
||||
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
|
||||
for (PlotId id : plotIds) {
|
||||
success &= setWallFilling(id, wallBlock);
|
||||
setWallFilling(id, wallBlock);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
||||
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
boolean success = true;
|
||||
for (PlotId id : plotIds) {
|
||||
success &= setWall(id, block);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed).
|
||||
*
|
||||
* @return true if the wall blocks were successfully set
|
||||
*/
|
||||
@Override public boolean regenerateAllPlotWalls() {
|
||||
boolean success = true;
|
||||
for (Plot plot : classicPlotWorld.getPlots()) {
|
||||
if (plot.hasOwner()) {
|
||||
success &= setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
|
||||
} else {
|
||||
success &= setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(id, claim);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
return true; // return false if unlink has been denied
|
||||
}
|
||||
|
||||
@Override public boolean startPlotMerge(List<PlotId> plotIds) {
|
||||
@ -459,7 +446,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override public boolean claimPlot(Plot plot) {
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
return setWall(plot.getId(), claim);
|
||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||
return setWall(plot.getId(), claim);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public String[] getPlotComponents(PlotId plotId) {
|
||||
|
@ -25,7 +25,7 @@ import java.util.Random;
|
||||
* A block bucket is a container of block types, where each block
|
||||
* has a specified chance of being randomly picked
|
||||
*/
|
||||
@EqualsAndHashCode @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket
|
||||
@EqualsAndHashCode(of={"blocks"}) @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket
|
||||
implements Iterable<BlockState>, ConfigurationSerializable {
|
||||
|
||||
private final Random random = new Random();
|
||||
@ -194,6 +194,11 @@ import java.util.Random;
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public boolean isAir() {
|
||||
compile();
|
||||
return blocks.isEmpty() || (single != null && single.getBlockType().getMaterial().isAir());
|
||||
}
|
||||
|
||||
@Override public Map<String, Object> serialize() {
|
||||
if (!isCompiled()) {
|
||||
compile();
|
||||
@ -201,7 +206,6 @@ import java.util.Random;
|
||||
return ImmutableMap.of("blocks", this.toString());
|
||||
}
|
||||
|
||||
|
||||
@Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range {
|
||||
|
||||
private final int min;
|
||||
|
@ -90,6 +90,21 @@ public abstract class PlotManager {
|
||||
return 255;
|
||||
}
|
||||
|
||||
public abstract boolean regenerateAllPlotWalls();
|
||||
/**
|
||||
* Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed).
|
||||
*
|
||||
* @return true if the wall blocks were successfully set
|
||||
*/
|
||||
public boolean regenerateAllPlotWalls() {
|
||||
boolean success = true;
|
||||
for (Plot plot : plotArea.getPlots()) {
|
||||
if (plot.hasOwner()) {
|
||||
success &= claimPlot(plot);
|
||||
} else {
|
||||
success &= unClaimPlot(plot, null);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user