mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix my stupid mistake of using lamdas not creating nested classes when creating schematics. "this" doesn't work like that. Cheers Java.
This commit is contained in:
parent
9c3d2cfb02
commit
02f3c3ef50
@ -130,8 +130,7 @@ public abstract class SchematicHandler {
|
||||
name =
|
||||
plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner;
|
||||
} else {
|
||||
name = namingScheme
|
||||
.replaceAll("%id%", plot.getId().toString())
|
||||
name = namingScheme.replaceAll("%id%", plot.getId().toString())
|
||||
.replaceAll("%idx%", plot.getId().x + "")
|
||||
.replaceAll("%idy%", plot.getId().y + "")
|
||||
.replaceAll("%world%", plot.getArea().toString());
|
||||
@ -566,100 +565,114 @@ public abstract class SchematicHandler {
|
||||
final int p2z = pos2.getZ();
|
||||
final int ey = pos2.getY();
|
||||
Iterator<Integer> yiter = IntStream.range(sy, ey + 1).iterator();
|
||||
final Runnable yTask = () -> {
|
||||
long ystart = System.currentTimeMillis();
|
||||
while (yiter.hasNext() && System.currentTimeMillis() - ystart < 20) {
|
||||
final int y = yiter.next();
|
||||
Iterator<Integer> ziter = IntStream.range(p1z, p2z + 1).iterator();
|
||||
final Runnable zTask = () -> {
|
||||
long zstart = System.currentTimeMillis();
|
||||
while (ziter.hasNext()
|
||||
&& System.currentTimeMillis() - zstart < 20) {
|
||||
final int z = ziter.next();
|
||||
Iterator<Integer> xiter =
|
||||
IntStream.range(p1x, p2x + 1).iterator();
|
||||
final Runnable xTask = () -> {
|
||||
long xstart = System.currentTimeMillis();
|
||||
final int ry = y - sy;
|
||||
final int rz = z - p1z;
|
||||
while (xiter.hasNext()
|
||||
&& System.currentTimeMillis() - xstart < 20) {
|
||||
final int x = xiter.next();
|
||||
final int rx = x - p1x;
|
||||
BlockVector3 point = BlockVector3.at(x, y, z);
|
||||
BaseBlock block =
|
||||
cuboidRegion.getWorld().getFullBlock(point);
|
||||
if (block.getNbtData() != null) {
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Map.Entry<String, Tag> entry : block
|
||||
.getNbtData().getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
final Runnable yTask = new Runnable() {
|
||||
@Override public void run() {
|
||||
long ystart = System.currentTimeMillis();
|
||||
while (yiter.hasNext() && System.currentTimeMillis() - ystart < 20) {
|
||||
final int y = yiter.next();
|
||||
Iterator<Integer> ziter = IntStream.range(p1z, p2z + 1).iterator();
|
||||
final Runnable zTask = new Runnable() {
|
||||
@Override public void run() {
|
||||
long zstart = System.currentTimeMillis();
|
||||
while (ziter.hasNext()
|
||||
&& System.currentTimeMillis() - zstart < 20) {
|
||||
final int z = ziter.next();
|
||||
Iterator<Integer> xiter =
|
||||
IntStream.range(p1x, p2x + 1).iterator();
|
||||
final Runnable xTask = new Runnable() {
|
||||
@Override public void run() {
|
||||
long xstart = System.currentTimeMillis();
|
||||
final int ry = y - sy;
|
||||
final int rz = z - p1z;
|
||||
while (xiter.hasNext()
|
||||
&& System.currentTimeMillis() - xstart
|
||||
< 20) {
|
||||
final int x = xiter.next();
|
||||
final int rx = x - p1x;
|
||||
BlockVector3 point =
|
||||
BlockVector3.at(x, y, z);
|
||||
BaseBlock block = cuboidRegion.getWorld()
|
||||
.getFullBlock(point);
|
||||
if (block.getNbtData() != null) {
|
||||
Map<String, Tag> values =
|
||||
new HashMap<>();
|
||||
for (Map.Entry<String, Tag> entry : block
|
||||
.getNbtData().getValue()
|
||||
.entrySet()) {
|
||||
values.put(entry.getKey(),
|
||||
entry.getValue());
|
||||
}
|
||||
// Remove 'id' if it exists. We want 'Id'
|
||||
values.remove("id");
|
||||
|
||||
// Positions are kept in NBT, we don't want that.
|
||||
values.remove("x");
|
||||
values.remove("y");
|
||||
values.remove("z");
|
||||
|
||||
values.put("Id",
|
||||
new StringTag(block.getNbtId()));
|
||||
values.put("Pos", new IntArrayTag(
|
||||
new int[] {rx, ry, rz}));
|
||||
|
||||
tileEntities
|
||||
.add(new CompoundTag(values));
|
||||
}
|
||||
String blockKey =
|
||||
block.toImmutableState().getAsString();
|
||||
int blockId;
|
||||
if (palette.containsKey(blockKey)) {
|
||||
blockId = palette.get(blockKey);
|
||||
} else {
|
||||
blockId = palette.size();
|
||||
palette.put(blockKey, palette.size());
|
||||
}
|
||||
|
||||
while ((blockId & -128) != 0) {
|
||||
buffer.write(blockId & 127 | 128);
|
||||
blockId >>>= 7;
|
||||
}
|
||||
buffer.write(blockId);
|
||||
|
||||
if (ry > 0) {
|
||||
continue;
|
||||
}
|
||||
BlockVector2 pt = BlockVector2.at(x, z);
|
||||
BiomeType biome =
|
||||
cuboidRegion.getWorld().getBiome(pt);
|
||||
String biomeStr = biome.getId();
|
||||
int biomeId;
|
||||
if (biomePalette.containsKey(biomeStr)) {
|
||||
biomeId = biomePalette.get(biomeStr);
|
||||
} else {
|
||||
biomeId = biomePalette.size();
|
||||
biomePalette.put(biomeStr, biomeId);
|
||||
}
|
||||
while ((biomeId & -128) != 0) {
|
||||
biomeBuffer.write(biomeId & 127 | 128);
|
||||
biomeId >>>= 7;
|
||||
}
|
||||
biomeBuffer.write(biomeId);
|
||||
}
|
||||
if (xiter.hasNext()) {
|
||||
this.run();
|
||||
}
|
||||
}
|
||||
// Remove 'id' if it exists. We want 'Id'
|
||||
values.remove("id");
|
||||
|
||||
// Positions are kept in NBT, we don't want that.
|
||||
values.remove("x");
|
||||
values.remove("y");
|
||||
values.remove("z");
|
||||
|
||||
values.put("Id", new StringTag(block.getNbtId()));
|
||||
values.put("Pos",
|
||||
new IntArrayTag(new int[] {rx, ry, rz}));
|
||||
|
||||
tileEntities.add(new CompoundTag(values));
|
||||
}
|
||||
String blockKey =
|
||||
block.toImmutableState().getAsString();
|
||||
int blockId;
|
||||
if (palette.containsKey(blockKey)) {
|
||||
blockId = palette.get(blockKey);
|
||||
} else {
|
||||
blockId = palette.size();
|
||||
palette.put(blockKey, palette.size());
|
||||
}
|
||||
|
||||
while ((blockId & -128) != 0) {
|
||||
buffer.write(blockId & 127 | 128);
|
||||
blockId >>>= 7;
|
||||
}
|
||||
buffer.write(blockId);
|
||||
|
||||
if (ry > 0) {
|
||||
continue;
|
||||
}
|
||||
BlockVector2 pt = BlockVector2.at(x, z);
|
||||
BiomeType biome = cuboidRegion.getWorld().getBiome(pt);
|
||||
String biomeStr = biome.getId();
|
||||
int biomeId;
|
||||
if (biomePalette.containsKey(biomeStr)) {
|
||||
biomeId = biomePalette.get(biomeStr);
|
||||
} else {
|
||||
biomeId = biomePalette.size();
|
||||
biomePalette.put(biomeStr, biomeId);
|
||||
}
|
||||
while ((biomeId & -128) != 0) {
|
||||
biomeBuffer.write(biomeId & 127 | 128);
|
||||
biomeId >>>= 7;
|
||||
}
|
||||
biomeBuffer.write(biomeId);
|
||||
};
|
||||
xTask.run();
|
||||
}
|
||||
if (xiter.hasNext()) {
|
||||
if (ziter.hasNext()) {
|
||||
this.run();
|
||||
}
|
||||
};
|
||||
xTask.run();
|
||||
}
|
||||
if (ziter.hasNext()) {
|
||||
this.run();
|
||||
}
|
||||
};
|
||||
zTask.run();
|
||||
}
|
||||
if (yiter.hasNext()) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
} else {
|
||||
regionTask.run();
|
||||
}
|
||||
};
|
||||
zTask.run();
|
||||
}
|
||||
if (yiter.hasNext()) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
} else {
|
||||
regionTask.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
yTask.run();
|
||||
|
Loading…
Reference in New Issue
Block a user