mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Various:
- Some minor cleanup - Test for null id, not for null PlotBlock - Small fixes to schematic saving (still broken)
This commit is contained in:
parent
341e386df8
commit
90682e9f8b
8 changed files with 187 additions and 213 deletions
|
@ -124,7 +124,6 @@ public class BukkitChunkManager extends ChunkManager {
|
||||||
final World oldWorld = Bukkit.getWorld(pos1.getWorld());
|
final World oldWorld = Bukkit.getWorld(pos1.getWorld());
|
||||||
final World newWorld = Bukkit.getWorld(newPos.getWorld());
|
final World newWorld = Bukkit.getWorld(newPos.getWorld());
|
||||||
final String newWorldName = newWorld.getName();
|
final String newWorldName = newWorld.getName();
|
||||||
List<ChunkLoc> chunks = new ArrayList<>();
|
|
||||||
final ContentMap map = new ContentMap();
|
final ContentMap map = new ContentMap();
|
||||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(newWorldName, false);
|
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(newWorldName, false);
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
|
@ -144,27 +143,23 @@ public class BukkitChunkManager extends ChunkManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Runnable() {
|
}, () -> {
|
||||||
@Override public void run() {
|
for (Entry<PlotLoc, PlotBlock[]> entry : map.allBlocks.entrySet()) {
|
||||||
for (Entry<PlotLoc, PlotBlock[]> entry : map.allBlocks.entrySet()) {
|
PlotLoc loc = entry.getKey();
|
||||||
PlotLoc loc = entry.getKey();
|
PlotBlock[] blocks = entry.getValue();
|
||||||
PlotBlock[] blocks = entry.getValue();
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
if (blocks[y] != null) {
|
||||||
PlotBlock block = blocks[y];
|
PlotBlock block = blocks[y];
|
||||||
if (block != null) {
|
queue.setBlock(loc.x, y, loc.z, block);
|
||||||
queue.setBlock(loc.x, y, loc.z, block);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
|
||||||
GlobalBlockQueue.IMP.addTask(new Runnable() {
|
|
||||||
@Override public void run() {
|
|
||||||
map.restoreBlocks(newWorld, 0, 0);
|
|
||||||
map.restoreEntities(newWorld, relX, relZ);
|
|
||||||
TaskManager.runTask(whenDone);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
queue.enqueue();
|
||||||
|
GlobalBlockQueue.IMP.addTask(() -> {
|
||||||
|
map.restoreBlocks(newWorld, 0, 0);
|
||||||
|
map.restoreEntities(newWorld, relX, relZ);
|
||||||
|
TaskManager.runTask(whenDone);
|
||||||
|
});
|
||||||
}, 5);
|
}, 5);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -211,11 +206,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||||
RegionWrapper currentPlotClear =
|
RegionWrapper currentPlotClear =
|
||||||
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
||||||
AugmentedUtils.bypass(ignoreAugment, new Runnable() {
|
AugmentedUtils.bypass(ignoreAugment,
|
||||||
@Override public void run() {
|
() -> queue.regenChunkSafe(chunk.x, chunk.z));
|
||||||
queue.regenChunkSafe(chunk.x, chunk.z);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean checkX1 = false;
|
boolean checkX1 = false;
|
||||||
|
@ -278,43 +270,39 @@ public class BukkitChunkManager extends ChunkManager {
|
||||||
map.saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
|
map.saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
|
||||||
}
|
}
|
||||||
map.saveEntitiesOut(chunkObj, currentPlotClear);
|
map.saveEntitiesOut(chunkObj, currentPlotClear);
|
||||||
AugmentedUtils.bypass(ignoreAugment, new Runnable() {
|
AugmentedUtils.bypass(ignoreAugment, () -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
||||||
@Override public void run() {
|
@Override public void run(ScopedLocalBlockQueue value) {
|
||||||
setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
com.github.intellectualsites.plotsquared.plot.object.Location
|
||||||
@Override public void run(ScopedLocalBlockQueue value) {
|
min = value.getMin();
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location
|
int bx = min.getX();
|
||||||
min = value.getMin();
|
int bz = min.getZ();
|
||||||
int bx = min.getX();
|
for (int x1 = 0; x1 < 16; x1++) {
|
||||||
int bz = min.getZ();
|
for (int z1 = 0; z1 < 16; z1++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
PlotLoc loc = new PlotLoc(bx + x1, bz + z1);
|
||||||
for (int z = 0; z < 16; z++) {
|
PlotBlock[] ids = map.allBlocks.get(loc);
|
||||||
PlotLoc loc = new PlotLoc(bx + x, bz + z);
|
if (ids != null) {
|
||||||
PlotBlock[] ids = map.allBlocks.get(loc);
|
for (int y = 0;
|
||||||
if (ids != null) {
|
y < Math.min(128, ids.length); y++) {
|
||||||
for (int y = 0;
|
PlotBlock id = ids[y];
|
||||||
y < Math.min(128, ids.length); y++) {
|
if (id != null) {
|
||||||
PlotBlock id = ids[y];
|
value.setBlock(x1, y, z1, id);
|
||||||
if (id != null) {
|
} else {
|
||||||
value.setBlock(x, y, z, id);
|
value.setBlock(x1, y, z1,
|
||||||
} else {
|
PlotBlock.get("air"));
|
||||||
value.setBlock(x, y, z,
|
}
|
||||||
PlotBlock.get("air"));
|
}
|
||||||
}
|
for (int y = Math.min(128, ids.length);
|
||||||
}
|
y < ids.length; y++) {
|
||||||
for (int y = Math.min(128, ids.length);
|
PlotBlock id = ids[y];
|
||||||
y < ids.length; y++) {
|
if (id != null) {
|
||||||
PlotBlock id = ids[y];
|
value.setBlock(x1, y, z1, id);
|
||||||
if (id != null) {
|
|
||||||
value.setBlock(x, y, z, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, world, chunk);
|
}
|
||||||
}
|
}
|
||||||
});
|
}, world, chunk));
|
||||||
map.restoreBlocks(worldObj, 0, 0);
|
map.restoreBlocks(worldObj, 0, 0);
|
||||||
map.restoreEntities(worldObj, 0, 0);
|
map.restoreEntities(worldObj, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -359,11 +347,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||||
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
|
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
|
||||||
final boolean safe) {
|
final boolean safe) {
|
||||||
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(
|
||||||
@SuppressWarnings("deprecation") @Override public void run() {
|
() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe));
|
||||||
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
// Main positions
|
// Main positions
|
||||||
Location[] corners = MainUtil.getCorners(world, regions);
|
Location[] corners = MainUtil.getCorners(world, regions);
|
||||||
final Location bot = corners[0];
|
final Location bot = corners[0];
|
||||||
Location top = corners[1];
|
final Location top = corners[1];
|
||||||
|
|
||||||
CuboidRegion cuboidRegion =
|
CuboidRegion cuboidRegion =
|
||||||
new CuboidRegion(BukkitUtil.IMP.getWeWorld(world), bot.getBlockVector3(),
|
new CuboidRegion(BukkitUtil.IMP.getWeWorld(world), bot.getBlockVector3(),
|
||||||
|
@ -59,7 +59,6 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
|
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
|
||||||
schematic.put("Offset", new IntArrayTag(new int[] {0, 0, 0,}));
|
schematic.put("Offset", new IntArrayTag(new int[] {0, 0, 0,}));
|
||||||
|
|
||||||
final int[] paletteMax = {0};
|
|
||||||
Map<String, Integer> palette = new HashMap<>();
|
Map<String, Integer> palette = new HashMap<>();
|
||||||
|
|
||||||
List<CompoundTag> tileEntities = new ArrayList<>();
|
List<CompoundTag> tileEntities = new ArrayList<>();
|
||||||
|
@ -69,24 +68,20 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
if (queue.isEmpty()) {
|
if (queue.isEmpty()) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
schematic.put("PaletteMax", new IntTag(palette.size()));
|
||||||
schematic.put("PaletteMax", new IntTag(paletteMax[0]));
|
|
||||||
|
|
||||||
Map<String, Tag> paletteTag = new HashMap<>();
|
Map<String, Tag> paletteTag = new HashMap<>();
|
||||||
palette.forEach(
|
palette.forEach(
|
||||||
(key, value) -> paletteTag.put(key, new IntTag(value)));
|
(key, value) -> paletteTag.put(key, new IntTag(value)));
|
||||||
|
|
||||||
schematic.put("Palette", new CompoundTag(paletteTag));
|
schematic.put("Palette", new CompoundTag(paletteTag));
|
||||||
schematic
|
schematic.put("BlockData", new ByteArrayTag(buffer.toByteArray()));
|
||||||
.put("BlockData", new ByteArrayTag(buffer.toByteArray()));
|
schematic.put("TileEntities",
|
||||||
schematic.put("TileEntities",
|
new ListTag(CompoundTag.class, tileEntities));
|
||||||
new ListTag(CompoundTag.class, tileEntities));
|
whenDone.value = new CompoundTag(schematic);
|
||||||
whenDone.value = new CompoundTag(schematic);
|
TaskManager.runTask(whenDone);
|
||||||
TaskManager.runTask(whenDone);
|
System.gc();
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -147,13 +142,10 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
}
|
}
|
||||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||||
int ry = y - sy;
|
int ry = y - sy;
|
||||||
int i1 = ry * width * length;
|
|
||||||
for (int z = zzb; z <= zzt; z++) {
|
for (int z = zzb; z <= zzt; z++) {
|
||||||
int rz = z - bz;
|
int rz = z - bz;
|
||||||
int i2 = i1 + rz * width;
|
|
||||||
for (int x = xxb; x <= xxt; x++) {
|
for (int x = xxb; x <= xxt; x++) {
|
||||||
int rx = x - bx;
|
int rx = x - bx;
|
||||||
int index = i2 + rx;
|
|
||||||
BlockVector3 point = BlockVector3.at(x, y, z);
|
BlockVector3 point = BlockVector3.at(x, y, z);
|
||||||
BaseBlock block =
|
BaseBlock block =
|
||||||
cuboidRegion.getWorld().getFullBlock(point);
|
cuboidRegion.getWorld().getFullBlock(point);
|
||||||
|
@ -164,9 +156,8 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
values
|
values
|
||||||
.put(entry.getKey(), entry.getValue());
|
.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
// Remove 'id' if it exists. We want 'Id'
|
||||||
values.remove(
|
values.remove("id");
|
||||||
"id"); // Remove 'id' if it exists. We want 'Id'
|
|
||||||
|
|
||||||
// Positions are kept in NBT, we don't want that.
|
// Positions are kept in NBT, we don't want that.
|
||||||
values.remove("x");
|
values.remove("x");
|
||||||
|
@ -176,7 +167,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
values
|
values
|
||||||
.put("Id", new StringTag(block.getNbtId()));
|
.put("Id", new StringTag(block.getNbtId()));
|
||||||
values.put("Pos",
|
values.put("Pos",
|
||||||
new IntArrayTag(new int[] {x, y, z}));
|
new IntArrayTag(new int[] {rx, ry, rz}));
|
||||||
|
|
||||||
tileEntities.add(new CompoundTag(values));
|
tileEntities.add(new CompoundTag(values));
|
||||||
}
|
}
|
||||||
|
@ -186,9 +177,8 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
if (palette.containsKey(blockKey)) {
|
if (palette.containsKey(blockKey)) {
|
||||||
blockId = palette.get(blockKey);
|
blockId = palette.get(blockKey);
|
||||||
} else {
|
} else {
|
||||||
blockId = paletteMax[0];
|
blockId = palette.size();
|
||||||
palette.put(blockKey, blockId);
|
palette.put(blockKey, palette.size());
|
||||||
paletteMax[0]++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((blockId & -128) != 0) {
|
while ((blockId & -128) != 0) {
|
||||||
|
|
|
@ -87,8 +87,8 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
||||||
PlotBlock[] blocksLayer = (PlotBlock[]) lc.blocks[layer];
|
PlotBlock[] blocksLayer = (PlotBlock[]) lc.blocks[layer];
|
||||||
if (blocksLayer != null) {
|
if (blocksLayer != null) {
|
||||||
for (int j = 0; j < blocksLayer.length; j++) {
|
for (int j = 0; j < blocksLayer.length; j++) {
|
||||||
PlotBlock block = blocksLayer[j];
|
if (blocksLayer[j] != null) {
|
||||||
if (block != null) {
|
PlotBlock block = blocksLayer[j];
|
||||||
int x = MainUtil.x_loc[layer][j];
|
int x = MainUtil.x_loc[layer][j];
|
||||||
int y = MainUtil.y_loc[layer][j];
|
int y = MainUtil.y_loc[layer][j];
|
||||||
int z = MainUtil.z_loc[layer][j];
|
int z = MainUtil.z_loc[layer][j];
|
||||||
|
|
|
@ -24,8 +24,8 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||||
String[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ));
|
String[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ));
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
if (blocks[y] != null) {
|
||||||
if (block != null) {
|
PlotBlock block = PlotBlock.get(blocks[y]);
|
||||||
result.setBlock(x, minY + y, z, block);
|
result.setBlock(x, minY + y, z, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||||
String[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
String[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
if (blocks[y] != null) {
|
||||||
if (block != null) {
|
PlotBlock block = PlotBlock.get(blocks[y]);
|
||||||
queue.setBlock(x, minY + y, z, block);
|
queue.setBlock(x, minY + y, z, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
||||||
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
|
@ -146,7 +143,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||||
int minY = Math.min(PLOT_HEIGHT, ROAD_HEIGHT);
|
int minY = Math.min(PLOT_HEIGHT, ROAD_HEIGHT);
|
||||||
if (schematic3 != null) {
|
if (schematic3 != null) {
|
||||||
this.PLOT_SCHEMATIC = true;
|
this.PLOT_SCHEMATIC = true;
|
||||||
BlockVector3 d3 = schematic3.getClipboard().getDimensions();
|
BlockArrayClipboard blockArrayClipboard3 = schematic3.getClipboard();
|
||||||
|
|
||||||
|
BlockVector3 d3 = blockArrayClipboard3.getDimensions();
|
||||||
short w3 = (short) d3.getX();
|
short w3 = (short) d3.getX();
|
||||||
short l3 = (short) d3.getZ();
|
short l3 = (short) d3.getZ();
|
||||||
short h3 = (short) d3.getY();
|
short h3 = (short) d3.getY();
|
||||||
|
@ -168,51 +167,50 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||||
|
|
||||||
int startY = minY - PLOT_HEIGHT;
|
int startY = minY - PLOT_HEIGHT;
|
||||||
|
|
||||||
// for (short x = 0; x < w3; x++) {
|
for (short x = 0; x < w3; x++) {
|
||||||
// for (short z = 0; z < l3; z++) {
|
for (short z = 0; z < l3; z++) {
|
||||||
// for (short y = 0; y < h3; y++) {
|
for (short y = 0; y < h3; y++) {
|
||||||
// int index = (y * w3 * l3) + (z * w3) + x;
|
BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x, y, z))
|
||||||
// short id = ids[index];
|
.toBaseBlock();
|
||||||
// byte data = datas[index];
|
if (!id.getBlockType().getId().toLowerCase().contains("air")) {
|
||||||
// if (id != 0) {
|
addOverlayBlock((short) (x + shift + oddshift + centerShiftX),
|
||||||
// addOverlayBlock((short) (x + shift + oddshift + centerShiftX),
|
(short) (y + startY), (short) (z + shift + oddshift + centerShiftZ),
|
||||||
// (short) (y + startY), (short) (z + shift + oddshift + centerShiftZ),
|
id, false, h3);
|
||||||
// id, data, false, h3);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
/* HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
||||||
// HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
if (!items.isEmpty()) {
|
||||||
// if (!items.isEmpty()) {
|
this.G_SCH_STATE = new HashMap<>();
|
||||||
// this.G_SCH_STATE = new HashMap<>();
|
outer:
|
||||||
// outer:
|
for (Map.Entry<BlockLoc, CompoundTag> entry : items.entrySet()) {
|
||||||
// for (Map.Entry<BlockLoc, CompoundTag> entry : items.entrySet()) {
|
BlockLoc loc = entry.getKey();
|
||||||
// BlockLoc loc = entry.getKey();
|
short x = (short) (loc.x + shift + oddshift + centerShiftX);
|
||||||
// short x = (short) (loc.x + shift + oddshift + centerShiftX);
|
short z = (short) (loc.z + shift + oddshift + centerShiftZ);
|
||||||
// short z = (short) (loc.z + shift + oddshift + centerShiftZ);
|
short y = (short) (loc.y + this.PLOT_HEIGHT);
|
||||||
// short y = (short) (loc.y + this.PLOT_HEIGHT);
|
int pair = MathMan.pair(x, z);
|
||||||
// int pair = MathMan.pair(x, z);
|
HashMap<Integer, CompoundTag> existing = this.G_SCH_STATE.get(pair);
|
||||||
// HashMap<Integer, CompoundTag> existing = this.G_SCH_STATE.get(pair);
|
if (existing == null) {
|
||||||
// if (existing == null) {
|
existing = new HashMap<>();
|
||||||
// existing = new HashMap<>();
|
this.G_SCH_STATE.put(pair, existing);
|
||||||
// this.G_SCH_STATE.put(pair, existing);
|
}
|
||||||
// }
|
existing.put((int) y, entry.getValue());
|
||||||
// existing.put((int) y, entry.getValue());
|
|
||||||
//
|
CompoundTag tag = entry.getValue();
|
||||||
// CompoundTag tag = entry.getValue();
|
Map<String, Tag> map = ReflectionUtils.getMap(tag.getValue());
|
||||||
// Map<String, Tag> map = ReflectionUtils.getMap(tag.getValue());
|
for (int i = 1; i <= 4; i++) {
|
||||||
// for (int i = 1; i <= 4; i++) {
|
String ln = tag.getString("Line" + i);
|
||||||
// String ln = tag.getString("Line" + i);
|
if (ln == null || ln.length() > 11)
|
||||||
// if (ln == null || ln.length() > 11)
|
continue outer;
|
||||||
// continue outer;
|
}
|
||||||
// }
|
SIGN_LOCATION =
|
||||||
// SIGN_LOCATION =
|
new Location(worldname, loc.x + centerShiftX, this.PLOT_HEIGHT + loc.y,
|
||||||
// new Location(worldname, loc.x + centerShiftX, this.PLOT_HEIGHT + loc.y,
|
loc.z + centerShiftZ);
|
||||||
// loc.z + centerShiftZ);
|
ALLOW_SIGNS = true;
|
||||||
// ALLOW_SIGNS = true;
|
continue outer;
|
||||||
// continue outer;
|
}
|
||||||
// }
|
}*/
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) {
|
if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) {
|
||||||
PlotSquared.debug(C.PREFIX + "&3 - schematic: &7false");
|
PlotSquared.debug(C.PREFIX + "&3 - schematic: &7false");
|
||||||
|
|
|
@ -356,8 +356,8 @@ public abstract class HybridUtils {
|
||||||
int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT);
|
int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
if ((blocks[y] != null) {
|
||||||
if (block != null) {
|
PlotBlock block = PlotBlock.get(blocks[y]);
|
||||||
queue.setBlock(x + X + plotWorld.ROAD_OFFSET_X, minY + y,
|
queue.setBlock(x + X + plotWorld.ROAD_OFFSET_X, minY + y,
|
||||||
z + Z + plotWorld.ROAD_OFFSET_Z, block);
|
z + Z + plotWorld.ROAD_OFFSET_Z, block);
|
||||||
}
|
}
|
||||||
|
@ -365,11 +365,9 @@ public abstract class HybridUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} queue.enqueue();
|
||||||
queue.enqueue();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
import com.sk89q.jnbt.*;
|
import com.sk89q.jnbt.*;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.*;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
@ -118,13 +114,14 @@ public abstract class SchematicHandler {
|
||||||
* @return boolean true if succeeded
|
* @return boolean true if succeeded
|
||||||
*/
|
*/
|
||||||
public void paste(final Schematic schematic, final Plot plot, final int xOffset,
|
public void paste(final Schematic schematic, final Plot plot, final int xOffset,
|
||||||
final int yOffset, final int zOffset, final boolean autoHeight, final Runnable whenDone) {
|
final int yOffset, final int zOffset, final boolean autoHeight,
|
||||||
|
final RunnableVal<Boolean> whenDone) {
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
|
||||||
.getEditSession(WorldUtil.IMP.getWeWorld(plot.getWorldName()), -1);
|
|
||||||
|
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
|
if (whenDone != null) {
|
||||||
|
whenDone.value = false;
|
||||||
|
}
|
||||||
if (schematic == null) {
|
if (schematic == null) {
|
||||||
PlotSquared.debug("Schematic == null :|");
|
PlotSquared.debug("Schematic == null :|");
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
|
@ -191,62 +188,63 @@ public abstract class SchematicHandler {
|
||||||
final int bcz = p1z >> 4;
|
final int bcz = p1z >> 4;
|
||||||
final int tcx = p2x >> 4;
|
final int tcx = p2x >> 4;
|
||||||
final int tcz = p2z >> 4;
|
final int tcz = p2z >> 4;
|
||||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
/* final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||||
for (int x = bcx; x <= tcx; x++) {
|
for (int x = bcx; x <= tcx; x++) {
|
||||||
for (int z = bcz; z <= tcz; z++) {
|
for (int z = bcz; z <= tcz; z++) {
|
||||||
chunks.add(new ChunkLoc(x, z));
|
chunks.add(new ChunkLoc(x, z));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
@Override public void run(int[] value) {
|
@Override public void run(int[] value) {
|
||||||
int count = 0;
|
//int count = 0;
|
||||||
while (!chunks.isEmpty() && count < 256) {
|
//while (!chunks.isEmpty() && count < 256) {
|
||||||
count++;
|
//count++;
|
||||||
ChunkLoc chunk = chunks.remove(0);
|
ChunkLoc chunk = new ChunkLoc(value[0], value[1]);
|
||||||
int x = chunk.x;
|
PlotSquared.log(chunk.toString());
|
||||||
int z = chunk.z;
|
int x = chunk.x;
|
||||||
int xxb = x << 4;
|
int z = chunk.z;
|
||||||
int zzb = z << 4;
|
int xxb = x << 4;
|
||||||
int xxt = xxb + 15;
|
int zzb = z << 4;
|
||||||
int zzt = zzb + 15;
|
int xxt = xxb + 15;
|
||||||
if (x == bcx) {
|
int zzt = zzb + 15;
|
||||||
xxb = p1x;
|
if (x == bcx) {
|
||||||
}
|
xxb = p1x;
|
||||||
if (x == tcx) {
|
}
|
||||||
xxt = p2x;
|
if (x == tcx) {
|
||||||
}
|
xxt = p2x;
|
||||||
if (z == bcz) {
|
}
|
||||||
zzb = p1z;
|
if (z == bcz) {
|
||||||
}
|
zzb = p1z;
|
||||||
if (z == tcz) {
|
}
|
||||||
zzt = p2z;
|
if (z == tcz) {
|
||||||
}
|
zzt = p2z;
|
||||||
// Paste schematic here
|
}
|
||||||
|
// Paste schematic here
|
||||||
|
|
||||||
for (int ry = 0; ry < Math.min(256, HEIGHT); ry++) {
|
for (int ry = 0; ry < Math.min(256, HEIGHT); ry++) {
|
||||||
int yy = y_offset_actual + ry;
|
int yy = y_offset_actual + ry;
|
||||||
if (yy > 255) {
|
if (yy > 255) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int i1 = ry * WIDTH * LENGTH;
|
int i1 = ry * WIDTH * LENGTH;
|
||||||
for (int rz = zzb - p1z; rz <= (zzt - p1z); rz++) {
|
for (int rz = zzb - p1z; rz <= (zzt - p1z); rz++) {
|
||||||
int i2 = (rz * WIDTH) + i1;
|
int i2 = (rz * WIDTH) + i1;
|
||||||
for (int rx = xxb - p1x; rx <= (xxt - p1x); rx++) {
|
for (int rx = xxb - p1x; rx <= (xxt - p1x); rx++) {
|
||||||
int i = i2 + rx;
|
int i = i2 + rx;
|
||||||
int xx = p1x + rx;
|
int xx = p1x + rx;
|
||||||
int zz = p1z + rz;
|
int zz = p1z + rz;
|
||||||
BaseBlock id = blockArrayClipboard
|
BaseBlock id = blockArrayClipboard
|
||||||
.getFullBlock(BlockVector3.at(rx, ry, rz));
|
.getFullBlock(BlockVector3.at(rx, ry, rz));
|
||||||
queue.setBlock(xx, yy, zz, id);
|
queue.setBlock(xx, yy, zz, id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* }
|
||||||
if (!chunks.isEmpty()) {
|
if (!chunks.isEmpty()) {
|
||||||
this.run();
|
this.run();
|
||||||
} else {
|
} else {
|
||||||
queue.flush();
|
queue.flush();
|
||||||
/*HashMap<BlockLoc, CompoundTag> tiles = schematic.getClipboard().getTiles();
|
HashMap<BlockLoc, CompoundTag> tiles = schematic.getClipboard().getTiles();
|
||||||
if (!tiles.isEmpty()) {
|
if (!tiles.isEmpty()) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
|
@ -259,10 +257,14 @@ public abstract class SchematicHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}*/
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}, whenDone, 10);
|
}, null, 10);
|
||||||
|
if (whenDone != null) {
|
||||||
|
whenDone.value = true;
|
||||||
|
whenDone.run();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
|
@ -327,14 +329,15 @@ public abstract class SchematicHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (BuiltInClipboardFormat.SPONGE_SCHEMATIC.isFormat(file)) {
|
ClipboardFormat format = ClipboardFormats.findByFile(file);
|
||||||
SpongeSchematicReader ssr =
|
if (format == BuiltInClipboardFormat.SPONGE_SCHEMATIC) {
|
||||||
new SpongeSchematicReader(new NBTInputStream(new FileInputStream(file)));
|
SpongeSchematicReader ssr = new SpongeSchematicReader(
|
||||||
|
new NBTInputStream(new GZIPInputStream(new FileInputStream(file))));
|
||||||
BlockArrayClipboard clip = (BlockArrayClipboard) ssr.read();
|
BlockArrayClipboard clip = (BlockArrayClipboard) ssr.read();
|
||||||
return new Schematic(clip);
|
return new Schematic(clip);
|
||||||
} else if (BuiltInClipboardFormat.MCEDIT_SCHEMATIC.isFormat(file)) {
|
} else if (format == BuiltInClipboardFormat.MCEDIT_SCHEMATIC) {
|
||||||
MCEditSchematicReader msr =
|
MCEditSchematicReader msr = new MCEditSchematicReader(
|
||||||
new MCEditSchematicReader(new NBTInputStream(new FileInputStream(file)));
|
new NBTInputStream(new GZIPInputStream(new FileInputStream(file))));
|
||||||
BlockArrayClipboard clip = (BlockArrayClipboard) msr.read();
|
BlockArrayClipboard clip = (BlockArrayClipboard) msr.read();
|
||||||
return new Schematic(clip);
|
return new Schematic(clip);
|
||||||
} else {
|
} else {
|
||||||
|
@ -446,9 +449,9 @@ public abstract class SchematicHandler {
|
||||||
try {
|
try {
|
||||||
File tmp = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), path);
|
File tmp = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), path);
|
||||||
tmp.getParentFile().mkdirs();
|
tmp.getParentFile().mkdirs();
|
||||||
try (OutputStream stream = new FileOutputStream(tmp);
|
try (NBTOutputStream nbtStream = new NBTOutputStream(
|
||||||
NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream))) {
|
new GZIPOutputStream(new FileOutputStream(tmp)))) {
|
||||||
output.writeNamedTag("Schematic", tag);
|
nbtStream.writeNamedTag("Schematic", tag);
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue