Part 1 of upstream merge and format

This commit is contained in:
MattBDev
2020-07-13 22:50:59 -04:00
parent 79771e83e0
commit 3bc692ff11
576 changed files with 3979 additions and 3421 deletions

View File

@ -1,7 +1,5 @@
package com.boydti.fawe.util;
import static org.slf4j.LoggerFactory.getLogger;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sk89q.jnbt.CompoundTag;
@ -11,6 +9,7 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.util;
import com.sk89q.worldedit.world.block.BlockType;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.FileNotFoundException;
public class CachedTextureUtil extends DelegateTextureUtil {

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.util;
import com.sk89q.worldedit.world.block.BlockType;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;

View File

@ -9,13 +9,22 @@ 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;
@ -30,8 +39,8 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.UUID;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -2,11 +2,10 @@ package com.boydti.fawe.util;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
import org.jetbrains.annotations.NotNull;
public class ExtentTraverser<T extends Extent> {
private final T root;
private final ExtentTraverser<T> parent;

View File

@ -4,7 +4,14 @@ import com.boydti.fawe.object.io.FastByteArrayOutputStream;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

View File

@ -6,14 +6,25 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.sk89q.worldedit.util.paste.Paster;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

View File

@ -1,7 +1,5 @@
package com.boydti.fawe.util;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.URL;
@ -9,6 +7,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import static org.slf4j.LoggerFactory.getLogger;
public enum Jars {
MM_v1_7_8(

View File

@ -2,12 +2,21 @@ package com.boydti.fawe.util;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.*;
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;
@ -16,31 +25,65 @@ 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 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;
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;

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.util;
import com.boydti.fawe.config.Settings;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;

View File

@ -1,7 +1,6 @@
package com.boydti.fawe.util;
import com.sk89q.worldedit.world.block.BlockType;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.FileNotFoundException;

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.util;
import com.boydti.fawe.Fawe;
import org.jetbrains.annotations.NotNull;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
@ -13,8 +14,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
public class ReflectionUtils {

View File

@ -1,15 +1,11 @@
package com.boydti.fawe.util;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RunnableVal;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.ExecutionException;
@ -17,6 +13,9 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import static org.slf4j.LoggerFactory.getLogger;
public abstract class TaskManager {
@ -25,16 +24,15 @@ public abstract class TaskManager {
private final ForkJoinPool pool = new ForkJoinPool();
/**
* Run a repeating task on the main thread
* Run a repeating task on the main thread.
*
* @param runnable
* @param runnable the task to run
* @param interval in ticks
* @return
*/
public abstract int repeat(@NotNull final Runnable runnable, final int interval);
/**
* Run a repeating task asynchronously
* Run a repeating task asynchronously.
*
* @param runnable the task to run
* @param interval in ticks
@ -43,34 +41,31 @@ public abstract class TaskManager {
public abstract int repeatAsync(@NotNull final Runnable runnable, final int interval);
/**
* Run a task asynchronously
* Run a task asynchronously.
*
* @param runnable the task to run
*/
public abstract void async(@NotNull final Runnable runnable);
/**
* Run a task on the main thread
* Run a task on the main thread.
*
* @param runnable the task to run
*/
public abstract void task(@NotNull final Runnable runnable);
/**
* Get the public ForkJoinPool<br>
* Get the public ForkJoinPool.
* - ONLY SUBMIT SHORT LIVED TASKS<br>
* - DO NOT USE SLEEP/WAIT/LOCKS IN ANY SUBMITTED TASKS<br>
*
* @return
*/
public ForkJoinPool getPublicForkJoinPool() {
return pool;
}
/**
* Run a bunch of tasks in parallel using the shared thread pool
*
* @param runnables
* Run a bunch of tasks in parallel using the shared thread pool.
*/
public void parallel(Collection<Runnable> runnables) {
for (Runnable run : runnables) {
@ -80,7 +75,7 @@ public abstract class TaskManager {
}
/**
* Run a bunch of tasks in parallel
* Run a bunch of tasks in parallel.
*
* @param runnables the tasks to run
* @param numThreads number of threads (null = config.yml parallel threads)
@ -136,9 +131,7 @@ public abstract class TaskManager {
}
/**
* Disable async catching for a specific task
*
* @param run
* Disable async catching for a specific task.
*/
public void runUnsafe(Runnable run) {
QueueHandler queue = Fawe.get().getQueueHandler();
@ -152,7 +145,7 @@ public abstract class TaskManager {
}
/**
* Run a task on the current thread or asynchronously
* Run a task on the current thread or asynchronously.
* - If it's already the main thread, it will just call run()
*
* @param runnable the task to run
@ -167,7 +160,7 @@ public abstract class TaskManager {
}
/**
* Run a task as soon as possible on the main thread
* Run a task as soon as possible on the main thread.
* - Non blocking if not calling from the main thread
*
* @param runnable the task to run
@ -181,7 +174,7 @@ public abstract class TaskManager {
}
/**
* Run a task as soon as possible not on the main thread
* Run a task as soon as possible not on the main thread.
*
* @param runnable the task to run
* @see Fawe#isMainThread()
@ -191,9 +184,9 @@ public abstract class TaskManager {
}
/**
* Run a task on the main thread at the next tick or now async
* Run a task on the main thread at the next tick or now async.
*
* @param runnable the task to run.
* @param runnable the task to run.
* @param async whether the task should run on the main thread
*/
public void taskSoonMain(@NotNull final Runnable runnable, boolean async) {
@ -206,7 +199,7 @@ public abstract class TaskManager {
/**
* Run a task later on the main thread
* Run a task later on the main thread.
*
* @param runnable the task to run
* @param delay in ticks
@ -214,7 +207,7 @@ public abstract class TaskManager {
public abstract void later(@NotNull final Runnable runnable, final int delay);
/**
* Run a task later asynchronously
* Run a task later asynchronously.
*
* @param runnable the task to run
* @param delay in ticks
@ -222,7 +215,7 @@ public abstract class TaskManager {
public abstract void laterAsync(@NotNull final Runnable runnable, final int delay);
/**
* Cancel a task
* Cancel a task.
*
* @param task the id of the task to cancel
*/
@ -289,12 +282,9 @@ public abstract class TaskManager {
}
/**
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish:<br>
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish.
* - Useful if you need to access something from the Bukkit API from another thread<br>
* - Usually wait time is around 25ms<br>
*
* @param function
* @return
*/
public <T> T syncWhenFree(@NotNull final RunnableVal<T> function) {
if (Fawe.isMainThread()) {
@ -309,7 +299,7 @@ public abstract class TaskManager {
}
/**
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish:<br>
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish.
* - Useful if you need to access something from the Bukkit API from another thread<br>
* - Usually wait time is around 25ms<br>
*/
@ -325,24 +315,18 @@ public abstract class TaskManager {
}
/**
* Quickly run a task on the main thread, and wait for execution to finish:<br>
* Quickly run a task on the main thread, and wait for execution to finish.
* - Useful if you need to access something from the Bukkit API from another thread<br>
* - Usually wait time is around 25ms<br>
*
* @param function
* @return
* - Usually wait time is around 25ms
*/
public <T> T sync(@NotNull final RunnableVal<T> function) {
return sync((Supplier<T>) function);
}
/**
* Quickly run a task on the main thread, and wait for execution to finish:<br>
* Quickly run a task on the main thread, and wait for execution to finish.
* - Useful if you need to access something from the Bukkit API from another thread<br>
* - Usually wait time is around 25ms<br>
*
* @param function
* @return
*/
public <T> T sync(final Supplier<T> function) {
if (Fawe.isMainThread()) {

View File

@ -1,7 +1,5 @@
package com.boydti.fawe.util;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock;
import com.boydti.fawe.config.Settings;
@ -9,7 +7,6 @@ import com.boydti.fawe.util.image.ImageUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
@ -21,6 +18,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArraySet;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
@ -45,6 +43,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.imageio.ImageIO;
import static org.slf4j.LoggerFactory.getLogger;
// TODO FIXME
public class TextureUtil implements TextureHolder {

View File

@ -8,20 +8,19 @@ import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.lang.reflect.Field;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WEManager {

View File

@ -7,7 +7,6 @@ import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.binding.ProvideBindings;
import javax.annotation.Nullable;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Transparency;
@ -20,6 +19,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.annotation.Nullable;
public class ImageUtil {