geforkt von Mirrors/FastAsyncWorldEdit
Minor cleanup
Dieser Commit ist enthalten in:
Ursprung
1eacb91267
Commit
8105088d60
@ -151,10 +151,6 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
|||||||
return forkJoinPoolPrimary.submit(call);
|
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) {
|
public <T> Future<T> sync(Runnable run) {
|
||||||
return sync(run, syncTasks);
|
return sync(run, syncTasks);
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ package com.boydti.fawe.object;
|
|||||||
|
|
||||||
public final class IntTriple {
|
public final class IntTriple {
|
||||||
|
|
||||||
public int x;
|
private final int x;
|
||||||
public int y;
|
private final int y;
|
||||||
public int z;
|
private final int z;
|
||||||
|
|
||||||
public IntTriple(int x, int y, int z) {
|
public IntTriple(int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
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(); }
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -93,7 +93,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
|||||||
}
|
}
|
||||||
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMapLoc.entrySet()) {
|
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMapLoc.entrySet()) {
|
||||||
IntTriple key = entry.getKey();
|
IntTriple key = entry.getKey();
|
||||||
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
|
setTile(getIndex(key.getX(), key.getY(), key.getZ()), entry.getValue());
|
||||||
}
|
}
|
||||||
nbtMapLoc.clear();
|
nbtMapLoc.clear();
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
|||||||
nbt = null;
|
nbt = null;
|
||||||
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
|
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
|
||||||
IntTriple key = entry.getKey();
|
IntTriple key = entry.getKey();
|
||||||
int index = getIndex(key.x, key.y, key.z);
|
int index = getIndex(key.getX(), key.getY(), key.getZ());
|
||||||
if (index == i) {
|
if (index == i) {
|
||||||
nbt = entry.getValue();
|
nbt = entry.getValue();
|
||||||
break;
|
break;
|
||||||
|
@ -200,7 +200,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
|||||||
nbt = null;
|
nbt = null;
|
||||||
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
|
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
|
||||||
IntTriple trio = entry.getKey();
|
IntTriple trio = entry.getKey();
|
||||||
int index = getIndex(trio.x, trio.y, trio.z);
|
int index = getIndex(trio.getX(), trio.getY(), trio.getZ());
|
||||||
if (index == i) {
|
if (index == i) {
|
||||||
nbt = entry.getValue();
|
nbt = entry.getValue();
|
||||||
break;
|
break;
|
||||||
|
@ -99,8 +99,8 @@ public abstract class DFSVisitor implements Operation {
|
|||||||
// mutable2.mutY(from.getY() + direction.y);
|
// mutable2.mutY(from.getY() + direction.y);
|
||||||
// mutable2.mutZ(from.getZ() + direction.z);
|
// mutable2.mutZ(from.getZ() + direction.z);
|
||||||
BlockVector3 bv2 = BlockVector3
|
BlockVector3 bv2 = BlockVector3
|
||||||
.at(from.getX() + direction.x, from.getY() + direction.y,
|
.at(from.getX() + direction.getX(), from.getY() + direction.getY(),
|
||||||
from.getZ() + direction.z);
|
from.getZ() + direction.getZ());
|
||||||
if (isVisitable(bv, bv2)) {
|
if (isVisitable(bv, bv2)) {
|
||||||
Node adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
|
Node adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
|
||||||
if (!adjacent.equals(current.from)) {
|
if (!adjacent.equals(current.from)) {
|
||||||
|
@ -5,29 +5,17 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.beta.IBatchProcessor;
|
import com.boydti.fawe.beta.IBatchProcessor;
|
||||||
import com.boydti.fawe.beta.IQueueChunk;
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
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.processors.LimitProcessor;
|
||||||
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.*;
|
||||||
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.brush.visualization.VirtualWorld;
|
||||||
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
||||||
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
|
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
|
||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
import com.boydti.fawe.object.extent.*;
|
||||||
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.boydti.fawe.wrappers.WorldWrapper;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
@ -1,92 +1,51 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
import static java.lang.System.arraycopy;
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
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.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweInputStream;
|
import com.boydti.fawe.object.FaweInputStream;
|
||||||
import com.boydti.fawe.object.FaweOutputStream;
|
import com.boydti.fawe.object.FaweOutputStream;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.RunnableVal2;
|
|
||||||
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
||||||
import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
|
import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
|
||||||
import com.github.luben.zstd.ZstdInputStream;
|
import com.github.luben.zstd.ZstdInputStream;
|
||||||
import com.github.luben.zstd.ZstdOutputStream;
|
import com.github.luben.zstd.ZstdOutputStream;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.*;
|
||||||
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.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import java.awt.Graphics2D;
|
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.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.*;
|
||||||
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.lang.reflect.Array;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.*;
|
||||||
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.Channels;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.*;
|
||||||
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.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.DataFormatException;
|
import java.util.zip.*;
|
||||||
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 it.unimi.dsi.fastutil.io.FastBufferedInputStream;
|
import static java.lang.System.arraycopy;
|
||||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
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 {
|
public class MainUtil {
|
||||||
|
|
||||||
@ -112,22 +71,22 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static long getTotalSize(Path path) {
|
public static long getTotalSize(Path path) {
|
||||||
final AtomicLong size = new AtomicLong(0);
|
final AtomicLong size = new AtomicLong(0);
|
||||||
traverse(path, new RunnableVal2<Path, BasicFileAttributes>() {
|
traverse(path, new RunnableVal<BasicFileAttributes>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Path path, BasicFileAttributes attrs) {
|
public void run(BasicFileAttributes attrs) {
|
||||||
size.addAndGet(attrs.size());
|
size.addAndGet(attrs.size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return size.get();
|
return size.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void traverse(Path path, final BiConsumer<Path, BasicFileAttributes> onEach) {
|
public static void traverse(Path path, final Consumer<BasicFileAttributes> onEach) {
|
||||||
try {
|
try {
|
||||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult
|
public FileVisitResult
|
||||||
visitFile(Path file, BasicFileAttributes attrs) {
|
visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
onEach.accept(file, attrs);
|
onEach.accept(attrs);
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +128,7 @@ public class MainUtil {
|
|||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void forEachFile(Path path, final RunnableVal2<Path, BasicFileAttributes> onEach, Comparator<File> comparator) {
|
public static void forEachFile(Path path, final RunnableVal<BasicFileAttributes> onEach, Comparator<File> comparator) {
|
||||||
File dir = path.toFile();
|
File dir = path.toFile();
|
||||||
if (!dir.exists()) return;
|
if (!dir.exists()) return;
|
||||||
File[] files = path.toFile().listFiles();
|
File[] files = path.toFile().listFiles();
|
||||||
@ -178,7 +137,7 @@ public class MainUtil {
|
|||||||
Path filePath = file.toPath();
|
Path filePath = file.toPath();
|
||||||
try {
|
try {
|
||||||
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
|
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
|
||||||
onEach.run(file.toPath(), attr);
|
onEach.run(attr);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren