mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Basic plot clearing (external generators need to comply)
This commit is contained in:
parent
239fcc9b2d
commit
6a8b227b08
@ -26,10 +26,10 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
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.generator.HybridPlotManager;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
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.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
@ -59,8 +59,7 @@ public class DebugClear extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world);
|
PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world);
|
||||||
} else {
|
} else {
|
||||||
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(world);
|
ChunkManager.clearPlotExperimental(Bukkit.getWorld(world), plot, false);
|
||||||
manager.clearPlotExperimental(Bukkit.getWorld(world), plot, false);
|
|
||||||
PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared.");
|
PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared.");
|
||||||
PlotMain.sendConsoleSenderMessage("&aDone!");
|
PlotMain.sendConsoleSenderMessage("&aDone!");
|
||||||
}
|
}
|
||||||
@ -81,8 +80,7 @@ public class DebugClear extends SubCommand {
|
|||||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(plr.getWorld());
|
ChunkManager.clearPlotExperimental(plr.getWorld(), plot, false);
|
||||||
manager.clearPlotExperimental(plr.getWorld(), plot, false);
|
|
||||||
PlayerFunctions.sendMessage(plr, "&aDone!");
|
PlayerFunctions.sendMessage(plr, "&aDone!");
|
||||||
|
|
||||||
// sign
|
// sign
|
||||||
|
@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.object.PlotGenerator;
|
|||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
||||||
@ -252,8 +253,7 @@ public class HybridGen extends PlotGenerator {
|
|||||||
setBlock(this.result, x, 0, z, (short) 7);
|
setBlock(this.result, x, 0, z, (short) 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HybridPlotManager hpm = ((HybridPlotManager) HybridGen.manager);
|
RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR;
|
||||||
RegionWrapper plot = hpm.CURRENT_PLOT_CLEAR;
|
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
|
|
||||||
int X = cx << 4;
|
int X = cx << 4;
|
||||||
@ -281,7 +281,7 @@ public class HybridGen extends PlotGenerator {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ChunkLoc loc = new ChunkLoc(X + x, Z + z);
|
ChunkLoc loc = new ChunkLoc(X + x, Z + z);
|
||||||
HashMap<Short, Short> blocks = hpm.GENERATE_BLOCKS.get(loc);
|
HashMap<Short, Short> blocks = ChunkManager.GENERATE_BLOCKS.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (short y : blocks.keySet()) {
|
for (short y : blocks.keySet()) {
|
||||||
setBlock(this.result, x, y, z, blocks.get(y).shortValue());
|
setBlock(this.result, x, y, z, blocks.get(y).shortValue());
|
||||||
|
@ -29,33 +29,20 @@ import java.util.HashSet;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Note;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Beacon;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.BrewingStand;
|
|
||||||
import org.bukkit.block.Chest;
|
|
||||||
import org.bukkit.block.Dispenser;
|
|
||||||
import org.bukkit.block.Furnace;
|
|
||||||
import org.bukkit.block.Hopper;
|
|
||||||
import org.bukkit.block.NoteBlock;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
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.object.BlockLoc;
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
|
||||||
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;
|
||||||
@ -63,9 +50,6 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation") public class HybridPlotManager extends PlotManager {
|
@SuppressWarnings("deprecation") public class HybridPlotManager extends PlotManager {
|
||||||
|
|
||||||
public RegionWrapper CURRENT_PLOT_CLEAR = null;
|
|
||||||
public HashMap<ChunkLoc, HashMap<Short, Short>> GENERATE_BLOCKS = new HashMap<>();
|
|
||||||
public HashMap<ChunkLoc, HashMap<Short, Byte>> GENERATE_DATA = new HashMap<>();
|
|
||||||
private int task;
|
private int task;
|
||||||
private static boolean UPDATE = false;
|
private static boolean UPDATE = false;
|
||||||
|
|
||||||
@ -151,8 +135,6 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
Location pos1 = new Location(world, sx, sy, sz);
|
Location pos1 = new Location(world, sx, sy, sz);
|
||||||
Location pos2 = new Location(world, ex, ey, ez);
|
Location pos2 = new Location(world, ex, ey, ez);
|
||||||
|
|
||||||
PlotBlock newblock = new PlotBlock((short) 5, (byte) 0);
|
|
||||||
|
|
||||||
int bx = sx;
|
int bx = sx;
|
||||||
int bz = sz - plotworld.ROAD_WIDTH;
|
int bz = sz - plotworld.ROAD_WIDTH;
|
||||||
int by = sy;
|
int by = sy;
|
||||||
@ -164,8 +146,6 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
Location pos3 = new Location(world, bx, by, bz);
|
Location pos3 = new Location(world, bx, by, bz);
|
||||||
Location pos4 = new Location(world, tx, ty, tz);
|
Location pos4 = new Location(world, tx, ty, tz);
|
||||||
|
|
||||||
newblock = new PlotBlock((short) 7, (byte) 0);
|
|
||||||
|
|
||||||
CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2);
|
CompoundTag sideroad = SchematicHandler.getCompoundTag(world, pos1, pos2);
|
||||||
CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4);
|
CompoundTag intersection = SchematicHandler.getCompoundTag(world, pos3, pos4);
|
||||||
|
|
||||||
@ -956,316 +936,6 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearPlotExperimental(final World world, final Plot plot, final boolean isDelete) {
|
|
||||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
|
||||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
|
||||||
|
|
||||||
Chunk c1 = world.getChunkAt(pos1);
|
|
||||||
Chunk c2 = world.getChunkAt(pos2);
|
|
||||||
|
|
||||||
this.CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
|
||||||
|
|
||||||
int sx = pos1.getBlockX();
|
|
||||||
int sz = pos1.getBlockZ();
|
|
||||||
int ex = pos2.getBlockX();
|
|
||||||
int ez = pos2.getBlockZ();
|
|
||||||
|
|
||||||
int c1x = c1.getX();
|
|
||||||
int c1z = c1.getZ();
|
|
||||||
int c2x = c2.getX();
|
|
||||||
int c2z = c2.getZ();
|
|
||||||
|
|
||||||
int maxY = world.getMaxHeight();
|
|
||||||
|
|
||||||
for (int x = c1x; x <= c2x; x ++) {
|
|
||||||
for (int z = c1z; z <= c2z; z ++) {
|
|
||||||
|
|
||||||
Chunk chunk = world.getChunkAt(x, z);
|
|
||||||
|
|
||||||
boolean loaded = true;
|
|
||||||
|
|
||||||
if (!chunk.isLoaded()) {
|
|
||||||
boolean result = chunk.load(false);
|
|
||||||
if (!result) {
|
|
||||||
loaded = false;;
|
|
||||||
}
|
|
||||||
if (!chunk.isLoaded()) {
|
|
||||||
loaded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loaded) {
|
|
||||||
int absX = x << 4;
|
|
||||||
int absZ = z << 4;
|
|
||||||
|
|
||||||
this.GENERATE_BLOCKS = new HashMap<>();
|
|
||||||
this.GENERATE_DATA = new HashMap<>();
|
|
||||||
|
|
||||||
HashMap<BlockLoc, ItemStack[]> chestContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, ItemStack[]> furnaceContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, ItemStack[]> dispenserContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, ItemStack[]> brewingStandContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, ItemStack[]> beaconContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, ItemStack[]> hopperContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, Note> noteBlockContents = new HashMap<>();
|
|
||||||
HashMap<BlockLoc, String[]> signContents = new HashMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
if (x == c1x || z == c1z) {
|
|
||||||
for (int X = 0; X < 16; X++) {
|
|
||||||
for (int Z = 0; Z < 16; Z++) {
|
|
||||||
if ((X + absX < sx || Z + absZ < sz) || (X + absX > ex || Z + absZ > ez)) {
|
|
||||||
HashMap<Short, Short> ids = new HashMap<>();
|
|
||||||
HashMap<Short, Byte> datas = new HashMap<>();
|
|
||||||
for (short y = 1; y < maxY; y++) {
|
|
||||||
Block block = world.getBlockAt(X + absX, y, Z + absZ);
|
|
||||||
short id = (short) block.getTypeId();
|
|
||||||
if (id != 0) {
|
|
||||||
ids.put(y, id);
|
|
||||||
byte data = block.getData();
|
|
||||||
if (data != 0) {
|
|
||||||
datas.put(y, data);
|
|
||||||
}
|
|
||||||
BlockLoc bl;
|
|
||||||
switch (id) {
|
|
||||||
case 54:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Chest chest = (Chest) block.getState();
|
|
||||||
ItemStack[] inventory = chest.getBlockInventory().getContents().clone();
|
|
||||||
chestContents.put(bl, inventory);
|
|
||||||
break;
|
|
||||||
case 63: case 68: case 323:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.getLines();
|
|
||||||
signContents.put(bl, sign.getLines().clone());
|
|
||||||
break;
|
|
||||||
case 61: case 62:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Furnace furnace = (Furnace) block.getState();
|
|
||||||
ItemStack[] invFur = furnace.getInventory().getContents().clone();
|
|
||||||
furnaceContents.put(bl, invFur);
|
|
||||||
break;
|
|
||||||
case 23:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Dispenser dispenser = (Dispenser) block.getState();
|
|
||||||
ItemStack[] invDis = dispenser.getInventory().getContents().clone();
|
|
||||||
dispenserContents.put(bl, invDis);
|
|
||||||
break;
|
|
||||||
case 117:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
BrewingStand brewingStand = (BrewingStand) block.getState();
|
|
||||||
ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
|
|
||||||
brewingStandContents.put(bl, invBre);
|
|
||||||
break;
|
|
||||||
case 25:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
NoteBlock noteBlock = (NoteBlock) block.getState();
|
|
||||||
Note note = noteBlock.getNote();
|
|
||||||
noteBlockContents.put(bl, note);
|
|
||||||
break;
|
|
||||||
case 138:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Beacon beacon = (Beacon) block.getState();
|
|
||||||
ItemStack[] invBea = beacon.getInventory().getContents().clone();
|
|
||||||
beaconContents.put(bl, invBea);
|
|
||||||
break;
|
|
||||||
case 154:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Hopper hopper = (Hopper) block.getState();
|
|
||||||
ItemStack[] invHop = hopper.getInventory().getContents().clone();
|
|
||||||
hopperContents.put(bl, invHop);
|
|
||||||
break;
|
|
||||||
/*
|
|
||||||
* TODO
|
|
||||||
* - NoteBlock
|
|
||||||
* - entities
|
|
||||||
* - beacon
|
|
||||||
* - hopper
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ChunkLoc loc = new ChunkLoc(X + absX, Z + absZ);
|
|
||||||
this.GENERATE_BLOCKS.put(loc, ids);
|
|
||||||
this.GENERATE_DATA.put(loc, datas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (x == c2x || z == c2z) {
|
|
||||||
for (int X = 0; X < 16; X++) {
|
|
||||||
for (int Z = 0; Z < 16; Z++) {
|
|
||||||
if ((X + absX > ex || Z + absZ > ez) || (X + absX < sx || Z + absZ < sz)) {
|
|
||||||
HashMap<Short, Short> ids = new HashMap<>();
|
|
||||||
HashMap<Short, Byte> datas = new HashMap<>();
|
|
||||||
for (short y = 1; y < maxY; y++) {
|
|
||||||
Block block = world.getBlockAt(X + absX, y, Z + absZ);
|
|
||||||
short id = (short) block.getTypeId();
|
|
||||||
if (id != 0) {
|
|
||||||
ids.put(y, id);
|
|
||||||
byte data = block.getData();
|
|
||||||
if (data != 0) {
|
|
||||||
datas.put(y, data);
|
|
||||||
}
|
|
||||||
BlockLoc bl;
|
|
||||||
switch (id) {
|
|
||||||
case 54:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Chest chest = (Chest) block.getState();
|
|
||||||
ItemStack[] inventory = chest.getBlockInventory().getContents().clone();
|
|
||||||
chestContents.put(bl, inventory);
|
|
||||||
break;
|
|
||||||
case 63: case 68: case 323:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.getLines();
|
|
||||||
signContents.put(bl, sign.getLines().clone());
|
|
||||||
break;
|
|
||||||
case 61: case 62:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Furnace furnace = (Furnace) block.getState();
|
|
||||||
ItemStack[] invFur = furnace.getInventory().getContents().clone();
|
|
||||||
furnaceContents.put(bl, invFur);
|
|
||||||
break;
|
|
||||||
case 23:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Dispenser dispenser = (Dispenser) block.getState();
|
|
||||||
ItemStack[] invDis = dispenser.getInventory().getContents().clone();
|
|
||||||
dispenserContents.put(bl, invDis);
|
|
||||||
break;
|
|
||||||
case 117:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
BrewingStand brewingStand = (BrewingStand) block.getState();
|
|
||||||
ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
|
|
||||||
brewingStandContents.put(bl, invBre);
|
|
||||||
break;
|
|
||||||
case 25:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
NoteBlock noteBlock = (NoteBlock) block.getState();
|
|
||||||
Note note = noteBlock.getNote();
|
|
||||||
noteBlockContents.put(bl, note);
|
|
||||||
break;
|
|
||||||
case 138:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Beacon beacon = (Beacon) block.getState();
|
|
||||||
ItemStack[] invBea = beacon.getInventory().getContents().clone();
|
|
||||||
beaconContents.put(bl, invBea);
|
|
||||||
break;
|
|
||||||
case 154:
|
|
||||||
bl = new BlockLoc(X + absX, y, Z + absZ);
|
|
||||||
Hopper hopper = (Hopper) block.getState();
|
|
||||||
ItemStack[] invHop = hopper.getInventory().getContents().clone();
|
|
||||||
hopperContents.put(bl, invHop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ChunkLoc loc = new ChunkLoc(X + absX, Z + absZ);
|
|
||||||
this.GENERATE_BLOCKS.put(loc, ids);
|
|
||||||
this.GENERATE_DATA.put(loc, datas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
world.regenerateChunk(x, z);
|
|
||||||
|
|
||||||
for (BlockLoc loc: chestContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Chest) {
|
|
||||||
Chest chest = (Chest) state;
|
|
||||||
chest.getInventory().setContents(chestContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate chest: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: signContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Sign) {
|
|
||||||
Sign sign = (Sign) state;
|
|
||||||
int i = 0;
|
|
||||||
for (String line : signContents.get(loc)) {
|
|
||||||
sign.setLine(i, line);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate sign: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: dispenserContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Dispenser) {
|
|
||||||
((Dispenser) (state)).getInventory().setContents(dispenserContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: beaconContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Beacon) {
|
|
||||||
((Beacon) (state)).getInventory().setContents(beaconContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate beacon: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: hopperContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Hopper) {
|
|
||||||
((Hopper) (state)).getInventory().setContents(hopperContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate hopper: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: noteBlockContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof NoteBlock) {
|
|
||||||
((NoteBlock) (state)).setNote(noteBlockContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate note block: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: brewingStandContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof BrewingStand) {
|
|
||||||
((BrewingStand) (state)).getInventory().setContents(brewingStandContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate brewing stand: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BlockLoc loc: furnaceContents.keySet()) {
|
|
||||||
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
|
||||||
BlockState state = block.getState();
|
|
||||||
if (state instanceof Furnace) {
|
|
||||||
((Furnace) (state)).getInventory().setContents(furnaceContents.get(loc));
|
|
||||||
state.update(true);
|
|
||||||
}
|
|
||||||
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x+","+loc.y+","+loc.z); }
|
|
||||||
}
|
|
||||||
chunk.unload();
|
|
||||||
chunk.load();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.CURRENT_PLOT_CLEAR = null;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove sign for a plot
|
* Remove sign for a plot
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
@ -132,7 +133,7 @@ public class HybridPop extends BlockPopulator {
|
|||||||
this.Z = cz << 4;
|
this.Z = cz << 4;
|
||||||
|
|
||||||
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(w);
|
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(w);
|
||||||
RegionWrapper plot = manager.CURRENT_PLOT_CLEAR;
|
RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR;
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
short sx = (short) ((X) % this.size);
|
short sx = (short) ((X) % this.size);
|
||||||
short sz = (short) ((Z) % this.size);
|
short sz = (short) ((Z) % this.size);
|
||||||
@ -159,7 +160,7 @@ public class HybridPop extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ChunkLoc loc = new ChunkLoc(X + x, Z + z);
|
ChunkLoc loc = new ChunkLoc(X + x, Z + z);
|
||||||
HashMap<Short, Byte> data = manager.GENERATE_DATA.get(loc);
|
HashMap<Short, Byte> data = ChunkManager.GENERATE_DATA.get(loc);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
for (short y : data.keySet()) {
|
for (short y : data.keySet()) {
|
||||||
setBlock(w, x, y, z, data.get(y).byteValue());
|
setBlock(w, x, y, z, data.get(y).byteValue());
|
||||||
|
@ -28,7 +28,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
public abstract class PlotManager {
|
public abstract class PlotManager {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plot locations (methods with Abs in them will not need to consider mega
|
* Plot locations (methods with Abs in them will not need to consider mega
|
||||||
* plots)
|
* plots)
|
||||||
|
@ -2,16 +2,36 @@ package com.intellectualcrafters.plot.util;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Note;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Beacon;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.BrewingStand;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.block.Dispenser;
|
||||||
|
import org.bukkit.block.Furnace;
|
||||||
|
import org.bukkit.block.Hopper;
|
||||||
|
import org.bukkit.block.NoteBlock;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
|
|
||||||
public class ChunkManager {
|
public class ChunkManager {
|
||||||
|
|
||||||
|
public static RegionWrapper CURRENT_PLOT_CLEAR = null;
|
||||||
|
public static HashMap<ChunkLoc, HashMap<Short, Short>> GENERATE_BLOCKS = new HashMap<>();
|
||||||
|
public static HashMap<ChunkLoc, HashMap<Short, Byte>> GENERATE_DATA = new HashMap<>();
|
||||||
|
|
||||||
public static ArrayList<ChunkLoc> getChunkChunks(World world) {
|
public static ArrayList<ChunkLoc> getChunkChunks(World world) {
|
||||||
File[] regionFiles = new File(new File(".").getAbsolutePath() + File.separator + world.getName() + File.separator + "region").listFiles();
|
File[] regionFiles = new File(new File(".").getAbsolutePath() + File.separator + world.getName() + File.separator + "region").listFiles();
|
||||||
ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||||
@ -39,7 +59,6 @@ public class ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPlot(World world, Chunk chunk) {
|
public static boolean hasPlot(World world, Chunk chunk) {
|
||||||
@ -61,4 +80,303 @@ public class ChunkManager {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean clearPlotExperimental(final World world, final Plot plot, final boolean isDelete) {
|
||||||
|
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
|
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||||
|
|
||||||
|
Chunk c1 = world.getChunkAt(pos1);
|
||||||
|
Chunk c2 = world.getChunkAt(pos2);
|
||||||
|
|
||||||
|
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
||||||
|
|
||||||
|
int sx = pos1.getBlockX();
|
||||||
|
int sz = pos1.getBlockZ();
|
||||||
|
int ex = pos2.getBlockX();
|
||||||
|
int ez = pos2.getBlockZ();
|
||||||
|
|
||||||
|
int c1x = c1.getX();
|
||||||
|
int c1z = c1.getZ();
|
||||||
|
int c2x = c2.getX();
|
||||||
|
int c2z = c2.getZ();
|
||||||
|
|
||||||
|
int maxY = world.getMaxHeight();
|
||||||
|
|
||||||
|
for (int x = c1x; x <= c2x; x ++) {
|
||||||
|
for (int z = c1z; z <= c2z; z ++) {
|
||||||
|
Chunk chunk = world.getChunkAt(x, z);
|
||||||
|
boolean loaded = true;
|
||||||
|
|
||||||
|
if (!chunk.isLoaded()) {
|
||||||
|
boolean result = chunk.load(false);
|
||||||
|
if (!result) {
|
||||||
|
loaded = false;;
|
||||||
|
}
|
||||||
|
if (!chunk.isLoaded()) {
|
||||||
|
loaded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loaded) {
|
||||||
|
int absX = x << 4;
|
||||||
|
int absZ = z << 4;
|
||||||
|
|
||||||
|
GENERATE_BLOCKS = new HashMap<>();
|
||||||
|
GENERATE_DATA = new HashMap<>();
|
||||||
|
|
||||||
|
HashMap<BlockLoc, ItemStack[]> chestContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, ItemStack[]> furnaceContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, ItemStack[]> dispenserContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, ItemStack[]> brewingStandContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, ItemStack[]> beaconContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, ItemStack[]> hopperContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, Note> noteBlockContents = new HashMap<>();
|
||||||
|
HashMap<BlockLoc, String[]> signContents = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
if (x == c1x || z == c1z) {
|
||||||
|
for (int X = 0; X < 16; X++) {
|
||||||
|
for (int Z = 0; Z < 16; Z++) {
|
||||||
|
if ((X + absX < sx || Z + absZ < sz) || (X + absX > ex || Z + absZ > ez)) {
|
||||||
|
HashMap<Short, Short> ids = new HashMap<>();
|
||||||
|
HashMap<Short, Byte> datas = new HashMap<>();
|
||||||
|
for (short y = 1; y < maxY; y++) {
|
||||||
|
Block block = world.getBlockAt(X + absX, y, Z + absZ);
|
||||||
|
short id = (short) block.getTypeId();
|
||||||
|
if (id != 0) {
|
||||||
|
ids.put(y, id);
|
||||||
|
byte data = block.getData();
|
||||||
|
if (data != 0) {
|
||||||
|
datas.put(y, data);
|
||||||
|
}
|
||||||
|
BlockLoc bl;
|
||||||
|
switch (id) {
|
||||||
|
case 54:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Chest chest = (Chest) block.getState();
|
||||||
|
ItemStack[] inventory = chest.getBlockInventory().getContents().clone();
|
||||||
|
chestContents.put(bl, inventory);
|
||||||
|
break;
|
||||||
|
case 63: case 68: case 323:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.getLines();
|
||||||
|
signContents.put(bl, sign.getLines().clone());
|
||||||
|
break;
|
||||||
|
case 61: case 62:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Furnace furnace = (Furnace) block.getState();
|
||||||
|
ItemStack[] invFur = furnace.getInventory().getContents().clone();
|
||||||
|
furnaceContents.put(bl, invFur);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Dispenser dispenser = (Dispenser) block.getState();
|
||||||
|
ItemStack[] invDis = dispenser.getInventory().getContents().clone();
|
||||||
|
dispenserContents.put(bl, invDis);
|
||||||
|
break;
|
||||||
|
case 117:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
BrewingStand brewingStand = (BrewingStand) block.getState();
|
||||||
|
ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
|
||||||
|
brewingStandContents.put(bl, invBre);
|
||||||
|
break;
|
||||||
|
case 25:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
NoteBlock noteBlock = (NoteBlock) block.getState();
|
||||||
|
Note note = noteBlock.getNote();
|
||||||
|
noteBlockContents.put(bl, note);
|
||||||
|
break;
|
||||||
|
case 138:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Beacon beacon = (Beacon) block.getState();
|
||||||
|
ItemStack[] invBea = beacon.getInventory().getContents().clone();
|
||||||
|
beaconContents.put(bl, invBea);
|
||||||
|
break;
|
||||||
|
case 154:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Hopper hopper = (Hopper) block.getState();
|
||||||
|
ItemStack[] invHop = hopper.getInventory().getContents().clone();
|
||||||
|
hopperContents.put(bl, invHop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChunkLoc loc = new ChunkLoc(X + absX, Z + absZ);
|
||||||
|
GENERATE_BLOCKS.put(loc, ids);
|
||||||
|
GENERATE_DATA.put(loc, datas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (x == c2x || z == c2z) {
|
||||||
|
for (int X = 0; X < 16; X++) {
|
||||||
|
for (int Z = 0; Z < 16; Z++) {
|
||||||
|
if ((X + absX > ex || Z + absZ > ez) || (X + absX < sx || Z + absZ < sz)) {
|
||||||
|
HashMap<Short, Short> ids = new HashMap<>();
|
||||||
|
HashMap<Short, Byte> datas = new HashMap<>();
|
||||||
|
for (short y = 1; y < maxY; y++) {
|
||||||
|
Block block = world.getBlockAt(X + absX, y, Z + absZ);
|
||||||
|
short id = (short) block.getTypeId();
|
||||||
|
if (id != 0) {
|
||||||
|
ids.put(y, id);
|
||||||
|
byte data = block.getData();
|
||||||
|
if (data != 0) {
|
||||||
|
datas.put(y, data);
|
||||||
|
}
|
||||||
|
BlockLoc bl;
|
||||||
|
switch (id) {
|
||||||
|
case 54:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Chest chest = (Chest) block.getState();
|
||||||
|
ItemStack[] inventory = chest.getBlockInventory().getContents().clone();
|
||||||
|
chestContents.put(bl, inventory);
|
||||||
|
break;
|
||||||
|
case 63: case 68: case 323:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.getLines();
|
||||||
|
signContents.put(bl, sign.getLines().clone());
|
||||||
|
break;
|
||||||
|
case 61: case 62:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Furnace furnace = (Furnace) block.getState();
|
||||||
|
ItemStack[] invFur = furnace.getInventory().getContents().clone();
|
||||||
|
furnaceContents.put(bl, invFur);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Dispenser dispenser = (Dispenser) block.getState();
|
||||||
|
ItemStack[] invDis = dispenser.getInventory().getContents().clone();
|
||||||
|
dispenserContents.put(bl, invDis);
|
||||||
|
break;
|
||||||
|
case 117:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
BrewingStand brewingStand = (BrewingStand) block.getState();
|
||||||
|
ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
|
||||||
|
brewingStandContents.put(bl, invBre);
|
||||||
|
break;
|
||||||
|
case 25:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
NoteBlock noteBlock = (NoteBlock) block.getState();
|
||||||
|
Note note = noteBlock.getNote();
|
||||||
|
noteBlockContents.put(bl, note);
|
||||||
|
break;
|
||||||
|
case 138:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Beacon beacon = (Beacon) block.getState();
|
||||||
|
ItemStack[] invBea = beacon.getInventory().getContents().clone();
|
||||||
|
beaconContents.put(bl, invBea);
|
||||||
|
break;
|
||||||
|
case 154:
|
||||||
|
bl = new BlockLoc(X + absX, y, Z + absZ);
|
||||||
|
Hopper hopper = (Hopper) block.getState();
|
||||||
|
ItemStack[] invHop = hopper.getInventory().getContents().clone();
|
||||||
|
hopperContents.put(bl, invHop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChunkLoc loc = new ChunkLoc(X + absX, Z + absZ);
|
||||||
|
GENERATE_BLOCKS.put(loc, ids);
|
||||||
|
GENERATE_DATA.put(loc, datas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
world.regenerateChunk(x, z);
|
||||||
|
|
||||||
|
for (BlockLoc loc: chestContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Chest) {
|
||||||
|
Chest chest = (Chest) state;
|
||||||
|
chest.getInventory().setContents(chestContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate chest: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: signContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Sign) {
|
||||||
|
Sign sign = (Sign) state;
|
||||||
|
int i = 0;
|
||||||
|
for (String line : signContents.get(loc)) {
|
||||||
|
sign.setLine(i, line);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate sign: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: dispenserContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
|
((Dispenser) (state)).getInventory().setContents(dispenserContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate dispenser: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: beaconContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Beacon) {
|
||||||
|
((Beacon) (state)).getInventory().setContents(beaconContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate beacon: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: hopperContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Hopper) {
|
||||||
|
((Hopper) (state)).getInventory().setContents(hopperContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate hopper: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: noteBlockContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof NoteBlock) {
|
||||||
|
((NoteBlock) (state)).setNote(noteBlockContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate note block: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: brewingStandContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof BrewingStand) {
|
||||||
|
((BrewingStand) (state)).getInventory().setContents(brewingStandContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate brewing stand: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockLoc loc: furnaceContents.keySet()) {
|
||||||
|
Block block = world.getBlockAt(loc.x, loc.y, loc.z);
|
||||||
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof Furnace) {
|
||||||
|
((Furnace) (state)).getInventory().setContents(furnaceContents.get(loc));
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
else { PlotMain.sendConsoleSenderMessage("&c[WARN] Plot clear failed to regenerate furnace: "+loc.x+","+loc.y+","+loc.z); }
|
||||||
|
}
|
||||||
|
chunk.unload();
|
||||||
|
chunk.load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CURRENT_PLOT_CLEAR = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,13 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
h = (prime * h) + pos1.getBlockX();
|
h = (prime * h) + pos1.getBlockX();
|
||||||
h = (prime * h) + pos1.getBlockZ();
|
h = (prime * h) + pos1.getBlockZ();
|
||||||
state = h;
|
state = h;
|
||||||
|
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
|
if (plotworld.TERRAIN != 0) {
|
||||||
|
ChunkManager.clearPlotExperimental(world, plot, isDelete);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
manager.clearPlot(world, plot, isDelete);
|
manager.clearPlot(world, plot, isDelete);
|
||||||
|
|
||||||
if (canSetFast) {
|
if (canSetFast) {
|
||||||
|
Loading…
Reference in New Issue
Block a user