Revert matt's changes

Let's not break Fawe, thanks
This commit is contained in:
N0tMyFaultOG
2020-06-13 18:48:57 +02:00
parent 56f29a3962
commit bfcc6184ad
75 changed files with 687 additions and 980 deletions

View File

@ -117,6 +117,27 @@ public class FaweAPI {
// return parser != null;
// }
public static <T> T getParser(Class<T> parserClass) {
try {
Field field = AbstractFactory.class.getDeclaredField("parsers");
field.setAccessible(true);
ArrayList<InputParser> parsers = new ArrayList<>();
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getMaskFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getBlockFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getItemFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getPatternFactory()));
for (InputParser parser : parsers) {
if (parserClass.isAssignableFrom(parser.getClass())) {
return (T) parser;
}
}
return null;
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
/**
* You can either use a IQueueExtent or an EditSession to change blocks<br>
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br>

View File

@ -50,7 +50,7 @@ public class AsyncPreloader implements Preloader, Runnable {
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
try {
Region region = session.getSelection(world);
if (!(region instanceof CuboidRegion) || region.getVolume() > 50466816) {
if (!(region instanceof CuboidRegion) || region.getArea() > 50466816) {
// TOO LARGE or NOT CUBOID
return;
}

View File

@ -428,7 +428,7 @@ public class NMSRelighter implements Relighter {
}
}
for (int y = 255; y > 0; y--) {
for (RelightSkyEntry chunk : chunks) { // Propagate skylight
for (RelightSkyEntry chunk : chunks) { // Propogate skylight
int layer = y >> 4;
byte[] mask = chunk.mask;
if ((y & 15) == 15 && chunk.fix[layer] != SkipReason.NONE) {
@ -596,7 +596,7 @@ public class NMSRelighter implements Relighter {
}
}
private class RelightSkyEntry implements Comparable<RelightSkyEntry> {
private class RelightSkyEntry implements Comparable {
public final int x;
public final int z;
public final byte[] mask;
@ -625,17 +625,18 @@ public class NMSRelighter implements Relighter {
}
@Override
public int compareTo(RelightSkyEntry o) {
if (o.x < x) {
public int compareTo(Object o) {
RelightSkyEntry other = (RelightSkyEntry) o;
if (other.x < x) {
return 1;
}
if (o.x > x) {
if (other.x > x) {
return -1;
}
if (o.z < z) {
if (other.z < z) {
return 1;
}
if (o.z > z) {
if (other.z > z) {
return -1;
}
return 0;

View File

@ -52,7 +52,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public List<? extends Entity> getEntities(Region region) {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
try {
return getExtent().getEntities(region);
} catch (FaweException e) {
@ -223,8 +223,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public void addCaves(Region region) throws WorldEditException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
getExtent().addCaves(region);
} catch (FaweException e) {
@ -236,8 +236,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public void generate(Region region, GenBase gen) throws WorldEditException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
getExtent().generate(region, gen);
} catch (FaweException e) {
@ -249,8 +249,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
getExtent().addSchems(region, mask, clipboards, rarity, rotate);
} catch (FaweException e) {
@ -262,8 +262,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
getExtent().spawnResource(region, gen, rarity, frequency);
} catch (FaweException e) {
@ -275,8 +275,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
} catch (FaweException e) {
@ -288,8 +288,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public void addOres(Region region, Mask mask) throws WorldEditException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
getExtent().addOres(region, mask);
} catch (FaweException e) {
@ -301,7 +301,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public List<Countable<BlockType>> getBlockDistribution(Region region) {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
try {
return getExtent().getBlockDistribution(region);
} catch (FaweException e) {
@ -314,7 +314,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
try {
return getExtent().getBlockDistributionWithData(region);
} catch (FaweException e) {
@ -327,7 +327,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
try {
return getExtent().countBlocks(region, searchBlocks);
} catch (FaweException e) {
@ -340,7 +340,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public int countBlocks(Region region, Mask searchMask) {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
try {
return getExtent().countBlocks(region, searchMask);
} catch (FaweException e) {
@ -353,7 +353,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().setBlocks(region, block);
} catch (FaweException e) {
@ -366,7 +366,7 @@ public class LimitExtent extends PassthroughExtent {
@Override
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().setBlocks(region, pattern);
} catch (FaweException e) {
@ -379,8 +379,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().replaceBlocks(region, filter, replacement);
} catch (FaweException e) {
@ -393,8 +393,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().replaceBlocks(region, filter, pattern);
} catch (FaweException e) {
@ -407,8 +407,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().replaceBlocks(region, mask, pattern);
} catch (FaweException e) {
@ -421,8 +421,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().center(region, pattern);
} catch (FaweException e) {
@ -448,8 +448,8 @@ public class LimitExtent extends PassthroughExtent {
@Override
public <T extends Filter> T apply(Region region, T filter, boolean full) {
limit.THROW_MAX_CHECKS(region.getVolume());
limit.THROW_MAX_CHANGES(region.getVolume());
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().apply(region, filter, full);
} catch (FaweException e) {

View File

@ -151,6 +151,10 @@ public abstract class QueueHandler implements Trimable, Runnable {
return forkJoinPoolPrimary.submit(call);
}
public <T> Future<T> sync(Runnable run, T value) {
return sync(run, value, syncTasks);
}
public <T> Future<T> sync(Runnable run) {
return sync(run, syncTasks);
}

View File

@ -1,3 +1,22 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.boydti.fawe.function.mask;
import com.sk89q.worldedit.extent.Extent;

View File

@ -1,3 +1,22 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.boydti.fawe.function.mask;
import com.sk89q.worldedit.extent.Extent;

View File

@ -9,10 +9,6 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;
public XAxisMask(Extent extent) {
}
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (layer == -1) {

View File

@ -9,9 +9,6 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;
public YAxisMask(Extent extent) {
}
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (layer == -1) {

View File

@ -9,9 +9,6 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;
public ZAxisMask(Extent extent) {
}
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (layer == -1) {

View File

@ -162,9 +162,6 @@ public class FaweLimit {
public void THROW_MAX_CHANGES(int amt) {
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
}
public void THROW_MAX_CHANGES(long amt) {
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
}
public void THROW_MAX_FAILS(int amt) {
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
@ -174,10 +171,6 @@ public class FaweLimit {
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
}
public void THROW_MAX_CHECKS(long amt) {
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
}
public void THROW_MAX_ITERATIONS(int amt) {
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS;
}

View File

@ -2,9 +2,9 @@ package com.boydti.fawe.object;
public final class IntTriple {
private final int x;
private final int y;
private final int z;
public int x;
public int y;
public int z;
public IntTriple(int x, int y, int z) {
this.x = x;

View File

@ -0,0 +1,8 @@
package com.boydti.fawe.object;
import java.util.function.Supplier;
public interface Lazy<T> extends Supplier<T> {
Supplier<T> init();
public default T get() { return init().get(); }
}

View File

@ -0,0 +1,33 @@
package com.boydti.fawe.object;
import java.util.function.BiConsumer;
public abstract class RunnableVal2<T, U> implements Runnable, BiConsumer<T, U> {
public T value1;
public U value2;
public RunnableVal2() {
}
public RunnableVal2(T value1, U value2) {
this.value1 = value1;
this.value2 = value2;
}
@Override
public void run() {
run(this.value1, this.value2);
}
public abstract void run(T value1, U value2);
public RunnableVal2<T, U> runAndGet(T value1, U value2) {
run(value1, value2);
return this;
}
@Override
public void accept(T t, U u) {
run(t, u);
}
}

View File

@ -93,7 +93,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
}
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMapLoc.entrySet()) {
IntTriple key = entry.getKey();
setTile(getIndex(key.getX(), key.getY(), key.getZ()), entry.getValue());
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
}
nbtMapLoc.clear();
}

View File

@ -324,7 +324,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
nbt = null;
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple key = entry.getKey();
int index = getIndex(key.getX(), key.getY(), key.getZ());
int index = getIndex(key.x, key.y, key.z);
if (index == i) {
nbt = entry.getValue();
break;

View File

@ -200,7 +200,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
nbt = null;
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple trio = entry.getKey();
int index = getIndex(trio.getX(), trio.getY(), trio.getZ());
int index = getIndex(trio.x, trio.y, trio.z);
if (index == i) {
nbt = entry.getValue();
break;

View File

@ -1,7 +1,6 @@
package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
@ -15,7 +14,7 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
private final CachedMask mask;
private final MutableBlockVector3 mutable;
public AdjacentAnyMask(AbstractExtentMask mask) {
public AdjacentAnyMask(Mask mask) {
this.mask = CachedMask.cache(mask);
mutable = new MutableBlockVector3();
}

View File

@ -1,7 +1,6 @@
package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
@ -12,7 +11,7 @@ public class SurfaceMask extends AdjacentAnyMask {
super(getMask(extent));
}
public static AbstractExtentMask getMask(Extent extent) {
public static Mask getMask(Extent extent) {
return new BlockMaskBuilder()
.addTypes(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR)
.addAll(b -> !b.getMaterial().isMovementBlocker())

View File

@ -87,12 +87,14 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
@Override
public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) {
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getVolume() + ")"));
int size = this.region.getArea();
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")"));
}
@Override
public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) {
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getVolume() + ")"));
int size = this.region.getArea();
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")"));
}
@Override

View File

@ -99,8 +99,8 @@ public abstract class DFSVisitor implements Operation {
// mutable2.mutY(from.getY() + direction.y);
// mutable2.mutZ(from.getZ() + direction.z);
BlockVector3 bv2 = BlockVector3
.at(from.getX() + direction.getX(), from.getY() + direction.getY(),
from.getZ() + direction.getZ());
.at(from.getX() + direction.x, from.getY() + direction.y,
from.getZ() + direction.z);
if (isVisitable(bv, bv2)) {
Node adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
if (!adjacent.equals(current.from)) {

View File

@ -5,17 +5,29 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.lighting.NMSRelighter;
import com.boydti.fawe.beta.implementation.lighting.NullRelighter;
import com.boydti.fawe.beta.implementation.lighting.Relighter;
import com.boydti.fawe.beta.implementation.processors.LimitProcessor;
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.*;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.NullChangeSet;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RelightMode;
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.changeset.AbstractChangeSet;
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
import com.boydti.fawe.object.extent.*;
import com.boydti.fawe.object.extent.FaweRegionExtent;
import com.boydti.fawe.object.extent.MultiRegionExtent;
import com.boydti.fawe.object.extent.NullExtent;
import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.boydti.fawe.object.extent.SlowExtent;
import com.boydti.fawe.object.extent.StripNBTExtent;
import com.boydti.fawe.wrappers.WorldWrapper;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;

View File

@ -4,7 +4,6 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import java.lang.reflect.Field;
import org.jetbrains.annotations.NotNull;
public class ExtentTraverser<T extends Extent> {
@ -49,8 +48,21 @@ public class ExtentTraverser<T extends Extent> {
return last;
}
public boolean insert(T extent) {
try {
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
field.setAccessible(true);
field.set(extent, field.get(root));
field.set(root, extent);
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
public <U> U findAndGet(Class<U> clazz) {
ExtentTraverser<Extent> traverser = find(clazz);
ExtentTraverser<Extent> traverser = find( clazz);
return (traverser != null) ? (U) traverser.get() : null;
}

View File

@ -1,51 +1,92 @@
package com.boydti.fawe.util;
import static java.lang.System.arraycopy;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
import com.github.luben.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdOutputStream;
import com.sk89q.jnbt.*;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.DoubleTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
import net.jpountz.lz4.*;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.*;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.net.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.Map;
import java.util.Scanner;
import java.util.UUID;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.zip.*;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import static java.lang.System.arraycopy;
import static org.slf4j.LoggerFactory.getLogger;
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream;
import net.jpountz.lz4.LZ4Compressor;
import net.jpountz.lz4.LZ4Factory;
import net.jpountz.lz4.LZ4FastDecompressor;
import net.jpountz.lz4.LZ4InputStream;
import net.jpountz.lz4.LZ4Utils;
import org.jetbrains.annotations.NotNull;
public class MainUtil {
@ -71,22 +112,22 @@ public class MainUtil {
public static long getTotalSize(Path path) {
final AtomicLong size = new AtomicLong(0);
traverse(path, new RunnableVal<BasicFileAttributes>() {
traverse(path, new RunnableVal2<Path, BasicFileAttributes>() {
@Override
public void run(BasicFileAttributes attrs) {
public void run(Path path, BasicFileAttributes attrs) {
size.addAndGet(attrs.size());
}
});
return size.get();
}
public static void traverse(Path path, final Consumer<BasicFileAttributes> onEach) {
public static void traverse(Path path, final BiConsumer<Path, BasicFileAttributes> onEach) {
try {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult
visitFile(Path file, BasicFileAttributes attrs) {
onEach.accept(attrs);
onEach.accept(file, attrs);
return FileVisitResult.CONTINUE;
}
@ -128,7 +169,7 @@ public class MainUtil {
return out.toString();
}
public static void forEachFile(Path path, final RunnableVal<BasicFileAttributes> onEach, Comparator<File> comparator) {
public static void forEachFile(Path path, final RunnableVal2<Path, BasicFileAttributes> onEach, Comparator<File> comparator) {
File dir = path.toFile();
if (!dir.exists()) return;
File[] files = path.toFile().listFiles();
@ -137,7 +178,7 @@ public class MainUtil {
Path filePath = file.toPath();
try {
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
onEach.run(attr);
onEach.run(file.toPath(), attr);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -4,8 +4,6 @@ import com.boydti.fawe.object.mask.ResettableMask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import java.lang.reflect.Field;
import java.util.Collection;
@ -40,18 +38,6 @@ public class MaskTraverser {
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
}
if (mask instanceof MaskIntersection) {
MaskIntersection mask1 = (MaskIntersection) mask;
try {
Field field = mask1.getClass().getDeclaredField("masks");
field.setAccessible(true);
Collection<Mask> masks = (Collection<Mask>) field.get(mask);
for (Mask next : masks) {
reset(next, newExtent);
}
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
}
try {
Field field = current.getDeclaredField("mask");
field.setAccessible(true);

View File

@ -0,0 +1,27 @@
package com.boydti.fawe.util;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
public class RegionCacheUtil {
public RegionCacheUtil() {
}
public void cache(Region region) {
Iterator<BlockVector3> iter = region.iterator();
}
public void run() {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
}
});
}
}

View File

@ -33,9 +33,15 @@ public class WEManager {
public void cancelEditSafe(AbstractDelegateExtent parent, FaweException reason) throws FaweException {
log.warn("CancelEditSafe was hit. Please ignore this message.");
Extent currentExtent = parent.getExtent();
if (!(currentExtent instanceof NullExtent)) {
parent.extent = new NullExtent(parent.extent, reason);
try {
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
field.setAccessible(true);
Extent currentExtent = parent.getExtent();
if (!(currentExtent instanceof NullExtent)) {
field.set(parent, new NullExtent((Extent) field.get(parent), reason));
}
} catch (Exception e) {
e.printStackTrace();
}
throw reason;
}