mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 12:36:40 +00:00
Fixes #1098
This commit is contained in:
@ -5,6 +5,7 @@ import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.jnbt.streamer.IntValueReader;
|
||||
import com.boydti.fawe.object.IntTriple;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.UnsafeUtility;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -22,7 +23,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import net.jpountz.util.UnsafeUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -279,7 +279,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
if (cb == null || !cb.isDirect()) {
|
||||
return;
|
||||
}
|
||||
UnsafeUtils.getUNSAFE().invokeCleaner(cb);
|
||||
UnsafeUtility.getUNSAFE().invokeCleaner(cb);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,6 @@ 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.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -254,7 +253,7 @@ public class MainUtil {
|
||||
private static final LZ4FastDecompressor DECOMPRESSOR = FACTORY.fastDecompressor();
|
||||
|
||||
public static int getMaxCompressedLength(int size) {
|
||||
return LZ4Utils.maxCompressedLength(size);
|
||||
return COMPRESSOR.maxCompressedLength(size);
|
||||
}
|
||||
|
||||
public static int compress(byte[] bytes, int length, byte[] buffer, OutputStream out, Deflater deflate) throws IOException {
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* This is an internal class not meant to be used outside of the FAWE internals.
|
||||
*/
|
||||
public class UnsafeUtility {
|
||||
|
||||
private static final Unsafe UNSAFE;
|
||||
|
||||
static {
|
||||
try {
|
||||
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafe.setAccessible(true);
|
||||
UNSAFE = (Unsafe) theUnsafe.get(null);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new ExceptionInInitializerError("Cannot access Unsafe");
|
||||
}
|
||||
}
|
||||
|
||||
public static Unsafe getUNSAFE() {
|
||||
return UNSAFE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user