Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-20 01:40:06 +01:00
Javadoc and Formatting fixes. (#619)
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
Dieser Commit ist enthalten in:
Ursprung
b06d943f7c
Commit
96dcb95b7c
@ -17,9 +17,11 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons
|
|||||||
|
|
||||||
## Downloads
|
## Downloads
|
||||||
### 1.15+
|
### 1.15+
|
||||||
* [Download](https://intellectualsites.github.io/download/fawe.html)
|
* [Download](https://www.spigotmc.org/resources/fast-async-worldedit.13932/)
|
||||||
* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/)
|
* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/)
|
||||||
|
|
||||||
|
Looking builds for older versions? Download them [here](https://intellectualsites.github.io/download/).
|
||||||
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
FAWE uses gradle to build
|
FAWE uses gradle to build
|
||||||
|
@ -19,6 +19,7 @@ import org.gradle.kotlin.dsl.withType
|
|||||||
fun Project.applyPlatformAndCoreConfiguration() {
|
fun Project.applyPlatformAndCoreConfiguration() {
|
||||||
applyCommonConfiguration()
|
applyCommonConfiguration()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
apply(plugin = "eclipse")
|
||||||
apply(plugin = "idea")
|
apply(plugin = "idea")
|
||||||
apply(plugin = "maven")
|
apply(plugin = "maven")
|
||||||
// apply(plugin = "checkstyle")
|
// apply(plugin = "checkstyle")
|
||||||
|
@ -10,4 +10,13 @@
|
|||||||
<suppress files=".*[\\/]TracedEditSession.java" checks="NoFinalizer"/>
|
<suppress files=".*[\\/]TracedEditSession.java" checks="NoFinalizer"/>
|
||||||
<!-- None of the old command stuff really matters -->
|
<!-- None of the old command stuff really matters -->
|
||||||
<suppress files=".*[\\/]minecraft[\\/]util[\\/]commands[\\/].*\.java" checks=".*"/>
|
<suppress files=".*[\\/]minecraft[\\/]util[\\/]commands[\\/].*\.java" checks=".*"/>
|
||||||
|
<!-- FAWE ADDITIONS -->
|
||||||
|
<suppress files=".*[\\/]MathMan.java" checks="MethodName"/>
|
||||||
|
<suppress files=".*[\\/]net[\\/]jpountz[\\/]lz4[\\/].*\.java" checks=".*"/>
|
||||||
|
<suppress files=".*[\\/]BufferedRandomAccessFile.java" checks=".*"/>
|
||||||
|
<suppress files=".*[\\/]ByteBufferUtils.java" checks="NoWhitespaceBefore"/>
|
||||||
|
<suppress files=".*[\\/]Settings.java" checks="MemberName"/>
|
||||||
|
<suppress files=".*[\\/]FaweLimit.java" checks="MemberName"/>
|
||||||
|
<suppress files=".*[\\/]SimplexNoise.java" checks="MemberName"/>
|
||||||
|
<suppress files=".*[\\/]SparseBitSet.java" checks=".*"/>
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
@ -96,6 +96,7 @@ Checks based on Google Checks, modified for EngineHub.
|
|||||||
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="ParameterName">
|
<module name="ParameterName">
|
||||||
|
<property name="severity" value="warning"/>
|
||||||
<property name="format" value="^([a-z][a-z0-9][_a-zA-Z0-9]*|[a-z])$"/>
|
<property name="format" value="^([a-z][a-z0-9][_a-zA-Z0-9]*|[a-z])$"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||||
@ -106,6 +107,7 @@ Checks based on Google Checks, modified for EngineHub.
|
|||||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="MethodTypeParameterName">
|
<module name="MethodTypeParameterName">
|
||||||
|
<property name="severity" value="warning"/>
|
||||||
<property name="format" value="(^[A-Z][0-9]?)$|(^[A-Z][a-zA-Z0-9]*$)"/>
|
<property name="format" value="(^[A-Z][0-9]?)$|(^[A-Z][a-zA-Z0-9]*$)"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
@ -186,6 +188,7 @@ Checks based on Google Checks, modified for EngineHub.
|
|||||||
<module name="CommentsIndentation"/>
|
<module name="CommentsIndentation"/>
|
||||||
<!-- Validate String.to(Lower|Upper)Case() calls include Locale argument -->
|
<!-- Validate String.to(Lower|Upper)Case() calls include Locale argument -->
|
||||||
<module name="Regexp">
|
<module name="Regexp">
|
||||||
|
<property name="severity" value="warning"/>
|
||||||
<property name="message" value="Case-conversion calls must include an explicit Locale"/>
|
<property name="message" value="Case-conversion calls must include an explicit Locale"/>
|
||||||
<property name="format" value="(?!Character)\.to(Lower|Upper)Case\(\)"/>
|
<property name="format" value="(?!Character)\.to(Lower|Upper)Case\(\)"/>
|
||||||
<property name="illegalPattern" value="true"/>
|
<property name="illegalPattern" value="true"/>
|
||||||
|
@ -9,7 +9,7 @@ import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler;
|
|||||||
import com.boydti.fawe.bukkit.listener.BrushListener;
|
import com.boydti.fawe.bukkit.listener.BrushListener;
|
||||||
import com.boydti.fawe.bukkit.listener.BukkitImageListener;
|
import com.boydti.fawe.bukkit.listener.BukkitImageListener;
|
||||||
import com.boydti.fawe.bukkit.listener.CFIPacketListener;
|
import com.boydti.fawe.bukkit.listener.CFIPacketListener;
|
||||||
import com.boydti.fawe.bukkit.listener.ChunkListener_9;
|
import com.boydti.fawe.bukkit.listener.ChunkListener9;
|
||||||
import com.boydti.fawe.bukkit.listener.RenderListener;
|
import com.boydti.fawe.bukkit.listener.RenderListener;
|
||||||
import com.boydti.fawe.bukkit.regions.FreeBuildRegion;
|
import com.boydti.fawe.bukkit.regions.FreeBuildRegion;
|
||||||
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
|
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
|
||||||
@ -95,7 +95,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin);
|
Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin);
|
||||||
|
|
||||||
// The tick limiter
|
// The tick limiter
|
||||||
new ChunkListener_9();
|
new ChunkListener9();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
this.imageListener = new BukkitImageListener(plugin);
|
this.imageListener = new BukkitImageListener(plugin);
|
||||||
}
|
}
|
||||||
return viewer;
|
return viewer;
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -252,7 +252,8 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
|
|
||||||
private volatile boolean keepUnloaded;
|
private volatile boolean keepUnloaded;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR) public void onWorldLoad(WorldLoadEvent event) {
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onWorldLoad(WorldLoadEvent event) {
|
||||||
if (keepUnloaded) {
|
if (keepUnloaded) {
|
||||||
org.bukkit.World world = event.getWorld();
|
org.bukkit.World world = event.getWorld();
|
||||||
world.setKeepSpawnInMemory(false);
|
world.setKeepSpawnInMemory(false);
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package com.boydti.fawe.bukkit.adapter;
|
package com.boydti.fawe.bukkit.adapter;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
import co.aikar.timings.Timings;
|
import co.aikar.timings.Timings;
|
||||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||||
import com.boydti.fawe.bukkit.listener.ChunkListener;
|
import com.boydti.fawe.bukkit.listener.ChunkListener;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import org.spigotmc.AsyncCatcher;
|
import org.spigotmc.AsyncCatcher;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
public class BukkitQueueHandler extends QueueHandler {
|
public class BukkitQueueHandler extends QueueHandler {
|
||||||
private volatile boolean timingsEnabled;
|
private volatile boolean timingsEnabled;
|
||||||
private static boolean alertTimingsChange = true;
|
private static boolean alertTimingsChange = true;
|
||||||
@ -17,7 +18,8 @@ public class BukkitQueueHandler extends QueueHandler {
|
|||||||
try {
|
try {
|
||||||
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
|
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
|
||||||
methodCheck.setAccessible(true);
|
methodCheck.setAccessible(true);
|
||||||
} catch (Throwable ignore){}
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,13 @@ package com.boydti.fawe.bukkit.adapter.mc1_15_2;
|
|||||||
|
|
||||||
import com.sk89q.util.ReflectionUtil;
|
import com.sk89q.util.ReflectionUtil;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
import net.minecraft.server.v1_15_R1.Block;
|
||||||
|
import net.minecraft.server.v1_15_R1.BlockAccessAir;
|
||||||
|
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_15_R1.EnumPistonReaction;
|
||||||
|
import net.minecraft.server.v1_15_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_15_R1.ITileEntity;
|
||||||
|
import net.minecraft.server.v1_15_R1.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||||
|
|
||||||
public class BlockMaterial_1_15_2 implements BlockMaterial {
|
public class BlockMaterial_1_15_2 implements BlockMaterial {
|
||||||
|
@ -52,22 +52,22 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
/*
|
/*
|
||||||
NMS fields
|
NMS fields
|
||||||
*/
|
*/
|
||||||
public final static Field fieldBits;
|
public static final Field fieldBits;
|
||||||
public final static Field fieldPalette;
|
public static final Field fieldPalette;
|
||||||
public final static Field fieldSize;
|
public static final Field fieldSize;
|
||||||
|
|
||||||
public final static Field fieldFluidCount;
|
public static final Field fieldFluidCount;
|
||||||
public final static Field fieldTickingBlockCount;
|
public static final Field fieldTickingBlockCount;
|
||||||
public final static Field fieldNonEmptyBlockCount;
|
public static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
private final static Field fieldDirtyCount;
|
private static final Field fieldDirtyCount;
|
||||||
private final static Field fieldDirtyBits;
|
private static final Field fieldDirtyBits;
|
||||||
|
|
||||||
private static final Field fieldBiomeArray;
|
private static final Field fieldBiomeArray;
|
||||||
|
|
||||||
private final static MethodHandle methodGetVisibleChunk;
|
private final static MethodHandle methodGetVisibleChunk;
|
||||||
|
|
||||||
public final static MethodHandle methodSetLightNibbleArray;
|
public static final MethodHandle methodSetLightNibbleArray;
|
||||||
|
|
||||||
private static final int CHUNKSECTION_BASE;
|
private static final int CHUNKSECTION_BASE;
|
||||||
private static final int CHUNKSECTION_SHIFT;
|
private static final int CHUNKSECTION_SHIFT;
|
||||||
@ -114,8 +114,9 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
||||||
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);
|
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);
|
||||||
int scale = unsafe.arrayIndexScale(ChunkSection[].class);
|
int scale = unsafe.arrayIndexScale(ChunkSection[].class);
|
||||||
if ((scale & (scale - 1)) != 0)
|
if ((scale & (scale - 1)) != 0) {
|
||||||
throw new Error("data type scale not a power of two");
|
throw new Error("data type scale not a power of two");
|
||||||
|
}
|
||||||
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw e;
|
throw e;
|
||||||
@ -152,17 +153,17 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk nmsChunk = nmsWorld.getChunkIfLoaded(X, Z);
|
Chunk nmsChunk = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
|
||||||
if (nmsChunk != null) {
|
if (nmsChunk != null) {
|
||||||
return nmsChunk;
|
return nmsChunk;
|
||||||
}
|
}
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return nmsWorld.getChunkAt(X, Z);
|
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
CraftWorld craftWorld = nmsWorld.getWorld();
|
CraftWorld craftWorld = nmsWorld.getWorld();
|
||||||
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(X, Z, true);
|
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
||||||
try {
|
try {
|
||||||
CraftChunk chunk = (CraftChunk) future.get();
|
CraftChunk chunk = (CraftChunk) future.get();
|
||||||
return chunk.getHandle();
|
return chunk.getHandle();
|
||||||
@ -171,7 +172,7 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO optimize
|
// TODO optimize
|
||||||
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(X, Z));
|
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
||||||
@ -183,8 +184,8 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask, boolean lighting) {
|
public static void sendChunk(WorldServer nmsWorld, int chunkX, int chunkZ, int mask, boolean lighting) {
|
||||||
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, X, Z);
|
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, chunkX, chunkZ);
|
||||||
if (playerChunk == null) {
|
if (playerChunk == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -205,7 +206,7 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
fieldDirtyCount.set(playerChunk, 64);
|
fieldDirtyCount.set(playerChunk, 64);
|
||||||
|
|
||||||
if (lighting) {
|
if (lighting) {
|
||||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(X, Z);
|
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine());
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine());
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
p.playerConnection.sendPacket(packet);
|
p.playerConnection.sendPacket(packet);
|
||||||
@ -259,7 +260,9 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
|
|
||||||
final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
|
final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
|
||||||
if (num_palette == 1) {
|
if (num_palette == 1) {
|
||||||
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
|
for (int i = 0; i < blockBitArrayEnd; i++) {
|
||||||
|
blockStates[i] = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
|
final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
|
||||||
bitArray.fromRaw(blocksCopy);
|
bitArray.fromRaw(blocksCopy);
|
||||||
@ -273,7 +276,6 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
|||||||
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
|
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
|
||||||
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||||
final DataPalette<IBlockData> palette;
|
final DataPalette<IBlockData> palette;
|
||||||
// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);
|
|
||||||
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d);
|
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d);
|
||||||
|
|
||||||
// set palette
|
// set palette
|
||||||
|
@ -58,7 +58,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.AbstractSet;
|
import java.util.AbstractSet;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -72,6 +71,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
@ -80,24 +80,29 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_15_2.class);
|
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_15_2.class);
|
||||||
|
|
||||||
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_15_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
private static final Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_15_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
public ChunkSection[] sections;
|
public ChunkSection[] sections;
|
||||||
public Chunk nmsChunk;
|
public Chunk nmsChunk;
|
||||||
public WorldServer world;
|
public WorldServer world;
|
||||||
public int X, Z;
|
public int chunkX;
|
||||||
|
public int chunkZ;
|
||||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||||
private boolean createCopy = false;
|
private boolean createCopy = false;
|
||||||
private BukkitGetBlocks_1_15_2_Copy copy = null;
|
private BukkitGetBlocks_1_15_2_Copy copy = null;
|
||||||
|
|
||||||
public BukkitGetBlocks_1_15_2(World world, int X, int Z) {
|
public BukkitGetBlocks_1_15_2(World world, int chunkX, int chunkZ) {
|
||||||
this(((CraftWorld) world).getHandle(), X, Z);
|
this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitGetBlocks_1_15_2(WorldServer world, int X, int Z) {
|
public BukkitGetBlocks_1_15_2(WorldServer world, int chunkX, int chunkZ) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.X = X;
|
this.chunkX = chunkX;
|
||||||
this.Z = Z;
|
this.chunkZ = chunkZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChunkX() {
|
||||||
|
return chunkX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,12 +120,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getChunkZ() {
|
||||||
return X;
|
return chunkZ;
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ() {
|
|
||||||
return Z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,7 +131,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
if (y == -1) {
|
if (y == -1) {
|
||||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
||||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||||
if (base != null) break;
|
if (base != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||||
@ -140,7 +143,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTile(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (
|
||||||
|
chunkX << 4), y, (z & 15) + (chunkZ << 4)));
|
||||||
if (tileEntity == null) {
|
if (tileEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -227,7 +231,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (List<Entity> slice : slices) {
|
for (List<Entity> slice : slices) {
|
||||||
if (slice != null) size += slice.size();
|
if (slice != null) {
|
||||||
|
size += slice.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (slices.length == 0) {
|
if (slices.length == 0) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
@ -304,16 +310,16 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
entity.die();
|
entity.die();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk ensureLoaded(net.minecraft.server.v1_15_R1.World nmsWorld, int X, int Z) {
|
public Chunk ensureLoaded(net.minecraft.server.v1_15_R1.World nmsWorld, int chunkX, int chunkZ) {
|
||||||
return BukkitAdapter_1_15_2.ensureLoaded(nmsWorld, X, Z);
|
return BukkitAdapter_1_15_2.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||||
copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world, getX(), getZ()) : null;
|
copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world, getChunkX(), getChunkZ()) : null;
|
||||||
try {
|
try {
|
||||||
WorldServer nmsWorld = world;
|
WorldServer nmsWorld = world;
|
||||||
Chunk nmsChunk = ensureLoaded(nmsWorld, X, Z);
|
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||||
boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE;
|
boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE;
|
||||||
|
|
||||||
// Remove existing tiles
|
// Remove existing tiles
|
||||||
@ -368,7 +374,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
} else {
|
} else {
|
||||||
existingSection = sections[layer];
|
existingSection = sections[layer];
|
||||||
if (existingSection == null) {
|
if (existingSection == null) {
|
||||||
log.error("Skipping invalid null section. chunk:" + X + "," + Z + " layer: " + layer);
|
log.error("Skipping invalid null section. chunk:" + chunkX + ","
|
||||||
|
+ chunkZ + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,7 +402,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode);
|
newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode);
|
||||||
if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||||
log.error("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
|
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||||
@ -458,12 +465,14 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
|
|
||||||
Runnable[] syncTasks = null;
|
Runnable[] syncTasks = null;
|
||||||
|
|
||||||
int bx = X << 4;
|
int bx = chunkX << 4;
|
||||||
int bz = Z << 4;
|
int bz = chunkZ << 4;
|
||||||
|
|
||||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[3];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[2] = () -> {
|
syncTasks[2] = () -> {
|
||||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||||
@ -488,7 +497,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
|
|
||||||
Set<CompoundTag> entities = set.getEntities();
|
Set<CompoundTag> entities = set.getEntities();
|
||||||
if (entities != null && !entities.isEmpty()) {
|
if (entities != null && !entities.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[2];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[1] = () -> {
|
syncTasks[1] = () -> {
|
||||||
for (final CompoundTag nativeTag : entities) {
|
for (final CompoundTag nativeTag : entities) {
|
||||||
@ -530,7 +541,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
// set tiles
|
// set tiles
|
||||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||||
if (tiles != null && !tiles.isEmpty()) {
|
if (tiles != null && !tiles.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[1];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[0] = () -> {
|
syncTasks[0] = () -> {
|
||||||
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
||||||
@ -572,8 +585,10 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
nmsChunk.mustNotSave = false;
|
nmsChunk.mustNotSave = false;
|
||||||
nmsChunk.markDirty();
|
nmsChunk.markDirty();
|
||||||
// send to player
|
// send to player
|
||||||
BukkitAdapter_1_15_2.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
BukkitAdapter_1_15_2.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (syncTasks != null) {
|
if (syncTasks != null) {
|
||||||
@ -590,7 +605,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return queueHandler.async(callback, null);
|
return queueHandler.async(callback, null);
|
||||||
@ -603,7 +620,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
return (T) (Future) queueHandler.sync(chain);
|
return (T) (Future) queueHandler.sync(chain);
|
||||||
} else {
|
} else {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
@ -753,7 +772,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
tmp = nmsChunk;
|
tmp = nmsChunk;
|
||||||
if (tmp == null) {
|
if (tmp == null) {
|
||||||
nmsChunk = tmp = ensureLoaded(this.world, X, Z);
|
nmsChunk = tmp = ensureLoaded(this.world, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,13 @@ import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||||
private static final int UPDATE = 1, NOTIFY = 2;
|
private static final int UPDATE = 1;
|
||||||
|
private static final int NOTIFY = 2;
|
||||||
|
|
||||||
private final FAWE_Spigot_v1_15_R2 adapter;
|
private final FAWE_Spigot_v1_15_R2 adapter;
|
||||||
private final WeakReference<World> world;
|
private final WeakReference<World> world;
|
||||||
|
@ -2,7 +2,14 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_1;
|
|||||||
|
|
||||||
import com.sk89q.util.ReflectionUtil;
|
import com.sk89q.util.ReflectionUtil;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_16_R1.*;
|
import net.minecraft.server.v1_16_R1.Block;
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockAccessAir;
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockBase;
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R1.EnumPistonReaction;
|
||||||
|
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R1.ITileEntity;
|
||||||
|
import net.minecraft.server.v1_16_R1.Material;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
||||||
|
|
||||||
public class BlockMaterial_1_16_1 implements BlockMaterial {
|
public class BlockMaterial_1_16_1 implements BlockMaterial {
|
||||||
|
@ -14,7 +14,23 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import net.jpountz.util.UnsafeUtils;
|
import net.jpountz.util.UnsafeUtils;
|
||||||
import net.minecraft.server.v1_16_R1.*;
|
import net.minecraft.server.v1_16_R1.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R1.BiomeStorage;
|
||||||
|
import net.minecraft.server.v1_16_R1.Block;
|
||||||
|
import net.minecraft.server.v1_16_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R1.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.server.v1_16_R1.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataBits;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPalette;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPaletteBlock;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPaletteLinear;
|
||||||
|
import net.minecraft.server.v1_16_R1.GameProfileSerializer;
|
||||||
|
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R1.PacketPlayOutLightUpdate;
|
||||||
|
import net.minecraft.server.v1_16_R1.PlayerChunk;
|
||||||
|
import net.minecraft.server.v1_16_R1.PlayerChunkMap;
|
||||||
|
import net.minecraft.server.v1_16_R1.World;
|
||||||
|
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||||
import sun.misc.Unsafe;
|
import sun.misc.Unsafe;
|
||||||
@ -34,18 +50,18 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
/*
|
/*
|
||||||
NMS fields
|
NMS fields
|
||||||
*/
|
*/
|
||||||
public final static Field fieldBits;
|
public static final Field fieldBits;
|
||||||
public final static Field fieldPalette;
|
public static final Field fieldPalette;
|
||||||
public final static Field fieldSize;
|
public static final Field fieldSize;
|
||||||
|
|
||||||
public final static Field fieldBitsPerEntry;
|
public static final Field fieldBitsPerEntry;
|
||||||
|
|
||||||
public final static Field fieldFluidCount;
|
public static final Field fieldFluidCount;
|
||||||
public final static Field fieldTickingBlockCount;
|
public static final Field fieldTickingBlockCount;
|
||||||
public final static Field fieldNonEmptyBlockCount;
|
public static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
private final static Field fieldDirtyCount;
|
private static final Field fieldDirtyCount;
|
||||||
private final static Field fieldDirtyBits;
|
private static final Field fieldDirtyBits;
|
||||||
|
|
||||||
private static final Field fieldBiomeArray;
|
private static final Field fieldBiomeArray;
|
||||||
|
|
||||||
@ -95,8 +111,9 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
||||||
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);
|
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);
|
||||||
int scale = unsafe.arrayIndexScale(ChunkSection[].class);
|
int scale = unsafe.arrayIndexScale(ChunkSection[].class);
|
||||||
if ((scale & (scale - 1)) != 0)
|
if ((scale & (scale - 1)) != 0) {
|
||||||
throw new Error("data type scale not a power of two");
|
throw new Error("data type scale not a power of two");
|
||||||
|
}
|
||||||
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw e;
|
throw e;
|
||||||
@ -133,17 +150,17 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(X, Z, false);
|
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
||||||
if (nmsChunk != null) {
|
if (nmsChunk != null) {
|
||||||
return nmsChunk;
|
return nmsChunk;
|
||||||
}
|
}
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return nmsWorld.getChunkAt(X, Z);
|
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
CraftWorld craftWorld = nmsWorld.getWorld();
|
CraftWorld craftWorld = nmsWorld.getWorld();
|
||||||
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(X, Z, true);
|
CompletableFuture<org.bukkit.Chunk> future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true);
|
||||||
try {
|
try {
|
||||||
CraftChunk chunk = (CraftChunk) future.get();
|
CraftChunk chunk = (CraftChunk) future.get();
|
||||||
return chunk.getHandle();
|
return chunk.getHandle();
|
||||||
@ -152,7 +169,7 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO optimize
|
// TODO optimize
|
||||||
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(X, Z));
|
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
|
||||||
@ -164,8 +181,8 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask, boolean lighting) {
|
public static void sendChunk(WorldServer nmsWorld, int chunkX, int chunkZ, int mask, boolean lighting) {
|
||||||
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, X, Z);
|
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, chunkX, chunkZ);
|
||||||
if (playerChunk == null) {
|
if (playerChunk == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,7 +203,7 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
fieldDirtyCount.set(playerChunk, 64);
|
fieldDirtyCount.set(playerChunk, 64);
|
||||||
|
|
||||||
if (lighting) {
|
if (lighting) {
|
||||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(X, Z);
|
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
boolean trustEdges = false; //Added in 1.16.1 Not sure what it does.
|
boolean trustEdges = false; //Added in 1.16.1 Not sure what it does.
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
@ -241,7 +258,9 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
final int blockBitArrayEnd = MathMan.ceilZero((float) 4096 / blocksPerLong);
|
final int blockBitArrayEnd = MathMan.ceilZero((float) 4096 / blocksPerLong);
|
||||||
|
|
||||||
if (num_palette == 1) {
|
if (num_palette == 1) {
|
||||||
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
|
for (int i = 0; i < blockBitArrayEnd; i++) {
|
||||||
|
blockStates[i] = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
|
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
|
||||||
bitArray.fromRaw(blocksCopy);
|
bitArray.fromRaw(blocksCopy);
|
||||||
@ -255,7 +274,6 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
|||||||
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
|
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
|
||||||
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||||
final DataPalette<IBlockData> palette;
|
final DataPalette<IBlockData> palette;
|
||||||
// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);
|
|
||||||
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::c);
|
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::c);
|
||||||
|
|
||||||
// set palette
|
// set palette
|
||||||
|
@ -15,8 +15,10 @@ import com.boydti.fawe.object.collection.AdaptedMap;
|
|||||||
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.ListTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.jnbt.*;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
@ -25,7 +27,28 @@ import com.sk89q.worldedit.internal.Constants;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import net.minecraft.server.v1_16_R1.*;
|
import net.minecraft.server.v1_16_R1.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R1.BiomeStorage;
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R1.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataBits;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPalette;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPaletteBlock;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPaletteHash;
|
||||||
|
import net.minecraft.server.v1_16_R1.DataPaletteLinear;
|
||||||
|
import net.minecraft.server.v1_16_R1.Entity;
|
||||||
|
import net.minecraft.server.v1_16_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_16_R1.EnumSkyBlock;
|
||||||
|
import net.minecraft.server.v1_16_R1.HeightMap;
|
||||||
|
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R1.LightEngine;
|
||||||
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_16_R1.NBTTagInt;
|
||||||
|
import net.minecraft.server.v1_16_R1.NibbleArray;
|
||||||
|
import net.minecraft.server.v1_16_R1.SectionPosition;
|
||||||
|
import net.minecraft.server.v1_16_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||||
@ -35,11 +58,20 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import java.util.AbstractSet;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
@ -48,24 +80,30 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_1.class);
|
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_1.class);
|
||||||
|
|
||||||
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
private static final Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
public ChunkSection[] sections;
|
public ChunkSection[] sections;
|
||||||
public Chunk nmsChunk;
|
public Chunk nmsChunk;
|
||||||
public WorldServer world;
|
public WorldServer world;
|
||||||
public int X, Z;
|
public int chunkX;
|
||||||
|
public int chunkZ;
|
||||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||||
private boolean createCopy = false;
|
private boolean createCopy = false;
|
||||||
private BukkitGetBlocks_1_16_1_Copy copy = null;
|
private BukkitGetBlocks_1_16_1_Copy copy = null;
|
||||||
|
|
||||||
public BukkitGetBlocks_1_16_1(World world, int X, int Z) {
|
public BukkitGetBlocks_1_16_1(World world, int chunkX, int chunkZ) {
|
||||||
this(((CraftWorld) world).getHandle(), X, Z);
|
this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitGetBlocks_1_16_1(WorldServer world, int X, int Z) {
|
public BukkitGetBlocks_1_16_1(WorldServer world, int chunkX, int chunkZ) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.X = X;
|
this.chunkX = chunkX;
|
||||||
this.Z = Z;
|
this.chunkZ = chunkZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getChunkX() {
|
||||||
|
return chunkX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -83,12 +121,8 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getChunkZ() {
|
||||||
return X;
|
return chunkZ;
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ() {
|
|
||||||
return Z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,7 +132,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
if (y == -1) {
|
if (y == -1) {
|
||||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
||||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||||
if (base != null) break;
|
if (base != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||||
@ -108,7 +144,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTile(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (
|
||||||
|
chunkX << 4), y, (z & 15) + (
|
||||||
|
chunkZ << 4)));
|
||||||
if (tileEntity == null) {
|
if (tileEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -193,7 +231,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (List<Entity> slice : slices) {
|
for (List<Entity> slice : slices) {
|
||||||
if (slice != null) size += slice.size();
|
if (slice != null) {
|
||||||
|
size += slice.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (slices.length == 0) {
|
if (slices.length == 0) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
@ -270,16 +310,16 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
entity.die();
|
entity.die();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R1.World nmsWorld, int X, int Z) {
|
public Chunk ensureLoaded(net.minecraft.server.v1_16_R1.World nmsWorld, int chunkX, int chunkZ) {
|
||||||
return BukkitAdapter_1_16_1.ensureLoaded(nmsWorld, X, Z);
|
return BukkitAdapter_1_16_1.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||||
copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world, getX(), getZ()) : null;
|
copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world, getChunkX(), getChunkZ()) : null;
|
||||||
try {
|
try {
|
||||||
WorldServer nmsWorld = world;
|
WorldServer nmsWorld = world;
|
||||||
Chunk nmsChunk = ensureLoaded(nmsWorld, X, Z);
|
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||||
boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE;
|
boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE;
|
||||||
|
|
||||||
// Remove existing tiles
|
// Remove existing tiles
|
||||||
@ -334,7 +374,8 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
} else {
|
} else {
|
||||||
existingSection = sections[layer];
|
existingSection = sections[layer];
|
||||||
if (existingSection == null) {
|
if (existingSection == null) {
|
||||||
log.error("Skipping invalid null section. chunk:" + X + "," + Z + " layer: " + layer);
|
log.error("Skipping invalid null section. chunk:" + chunkX + "," +
|
||||||
|
chunkZ + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +404,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||||
if (!BukkitAdapter_1_16_1
|
if (!BukkitAdapter_1_16_1
|
||||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||||
log.error("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
|
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||||
@ -426,12 +467,14 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
|
|
||||||
Runnable[] syncTasks = null;
|
Runnable[] syncTasks = null;
|
||||||
|
|
||||||
int bx = X << 4;
|
int bx = chunkX << 4;
|
||||||
int bz = Z << 4;
|
int bz = chunkZ << 4;
|
||||||
|
|
||||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[3];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[2] = () -> {
|
syncTasks[2] = () -> {
|
||||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||||
@ -456,7 +499,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
|
|
||||||
Set<CompoundTag> entities = set.getEntities();
|
Set<CompoundTag> entities = set.getEntities();
|
||||||
if (entities != null && !entities.isEmpty()) {
|
if (entities != null && !entities.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[2];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[1] = () -> {
|
syncTasks[1] = () -> {
|
||||||
for (final CompoundTag nativeTag : entities) {
|
for (final CompoundTag nativeTag : entities) {
|
||||||
@ -498,7 +543,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
// set tiles
|
// set tiles
|
||||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||||
if (tiles != null && !tiles.isEmpty()) {
|
if (tiles != null && !tiles.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[1];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[0] = () -> {
|
syncTasks[0] = () -> {
|
||||||
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
||||||
@ -540,8 +587,10 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
nmsChunk.mustNotSave = false;
|
nmsChunk.mustNotSave = false;
|
||||||
nmsChunk.markDirty();
|
nmsChunk.markDirty();
|
||||||
// send to player
|
// send to player
|
||||||
BukkitAdapter_1_16_1.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
BukkitAdapter_1_16_1.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (syncTasks != null) {
|
if (syncTasks != null) {
|
||||||
@ -558,7 +607,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return queueHandler.async(callback, null);
|
return queueHandler.async(callback, null);
|
||||||
@ -571,7 +622,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
return (T) (Future) queueHandler.sync(chain);
|
return (T) (Future) queueHandler.sync(chain);
|
||||||
} else {
|
} else {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
@ -721,7 +774,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
tmp = nmsChunk;
|
tmp = nmsChunk;
|
||||||
if (tmp == null) {
|
if (tmp == null) {
|
||||||
nmsChunk = tmp = ensureLoaded(this.world, X, Z);
|
nmsChunk = tmp = ensureLoaded(this.world, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,13 @@ import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||||
private static final int UPDATE = 1, NOTIFY = 2;
|
private static final int UPDATE = 1;
|
||||||
|
private static final int NOTIFY = 2;
|
||||||
|
|
||||||
private final FAWE_Spigot_v1_16_R1 adapter;
|
private final FAWE_Spigot_v1_16_R1 adapter;
|
||||||
private final WeakReference<World> world;
|
private final WeakReference<World> world;
|
||||||
|
@ -2,7 +2,14 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_2;
|
|||||||
|
|
||||||
import com.sk89q.util.ReflectionUtil;
|
import com.sk89q.util.ReflectionUtil;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_16_R2.*;
|
import net.minecraft.server.v1_16_R2.Block;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockAccessAir;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.EnumPistonReaction;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.ITileEntity;
|
||||||
|
import net.minecraft.server.v1_16_R2.Material;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||||
|
|
||||||
public class BlockMaterial_1_16_2 implements BlockMaterial {
|
public class BlockMaterial_1_16_2 implements BlockMaterial {
|
||||||
|
@ -114,14 +114,15 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
||||||
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);
|
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);
|
||||||
int scale = unsafe.arrayIndexScale(ChunkSection[].class);
|
int scale = unsafe.arrayIndexScale(ChunkSection[].class);
|
||||||
if ((scale & (scale - 1)) != 0)
|
if ((scale & (scale - 1)) != 0) {
|
||||||
throw new Error("data type scale not a power of two");
|
throw new Error("data type scale not a power of two");
|
||||||
|
}
|
||||||
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||||
|
|
||||||
Class clsShortArraySet;
|
Class<?> clsShortArraySet;
|
||||||
try { //paper
|
try { //paper
|
||||||
clsShortArraySet = Class.forName(new String(new char[]{'i', 't', '.', 'u', 'n', 'i', 'm', 'i', '.', 'd', 's', 'i', '.', 'f', 'a', 's', 't', 'u', 't', 'i', 'l', '.', 's', 'h', 'o', 'r', 't', 's', '.', 'S', 'h', 'o', 'r', 't', 'A', 'r', 'r', 'a', 'y', 'S', 'e', 't'}));
|
clsShortArraySet = Class.forName(new String(new char[]{'i', 't', '.', 'u', 'n', 'i', 'm', 'i', '.', 'd', 's', 'i', '.', 'f', 'a', 's', 't', 'u', 't', 'i', 'l', '.', 's', 'h', 'o', 'r', 't', 's', '.', 'S', 'h', 'o', 'r', 't', 'A', 'r', 'r', 'a', 'y', 'S', 'e', 't'}));
|
||||||
} catch (Throwable t) {// still using spigot boooo
|
} catch (Throwable t) { // still using spigot boo
|
||||||
clsShortArraySet = Class.forName(new String(new char[]{'o', 'r', 'g', '.', 'b', 'u', 'k', 'k', 'i', 't', '.', 'c', 'r', 'a', 'f', 't', 'b', 'u', 'k', 'k', 'i', 't', '.', 'l', 'i', 'b', 's', '.', 'i', 't', '.', 'u', 'n', 'i', 'm', 'i', '.', 'd', 's', 'i', '.', 'f', 'a', 's', 't', 'u', 't', 'i', 'l', '.', 's', 'h', 'o', 'r', 't', 's', '.', 'S', 'h', 'o', 'r', 't', 'A', 'r', 'r', 'a', 'y', 'S', 'e', 't'}));
|
clsShortArraySet = Class.forName(new String(new char[]{'o', 'r', 'g', '.', 'b', 'u', 'k', 'k', 'i', 't', '.', 'c', 'r', 'a', 'f', 't', 'b', 'u', 'k', 'k', 'i', 't', '.', 'l', 'i', 'b', 's', '.', 'i', 't', '.', 'u', 'n', 'i', 'm', 'i', '.', 'd', 's', 'i', '.', 'f', 'a', 's', 't', 'u', 't', 'i', 'l', '.', 's', 'h', 'o', 'r', 't', 's', '.', 'S', 'h', 'o', 'r', 't', 'A', 'r', 'r', 'a', 'y', 'S', 'e', 't'}));
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
@ -207,7 +208,6 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lighting) {
|
if (lighting) {
|
||||||
// ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
|
||||||
boolean trustEdges = true; //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
boolean trustEdges = true; //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
||||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
@ -258,7 +258,9 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
final int blockBitArrayEnd = MathMan.ceilZero((float) 4096 / blocksPerLong);
|
final int blockBitArrayEnd = MathMan.ceilZero((float) 4096 / blocksPerLong);
|
||||||
|
|
||||||
if (num_palette == 1) {
|
if (num_palette == 1) {
|
||||||
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
|
for (int i = 0; i < blockBitArrayEnd; i++) {
|
||||||
|
blockStates[i] = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
|
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
|
||||||
bitArray.fromRaw(blocksCopy);
|
bitArray.fromRaw(blocksCopy);
|
||||||
@ -272,7 +274,6 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
|||||||
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
|
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
|
||||||
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||||
final DataPalette<IBlockData> palette;
|
final DataPalette<IBlockData> palette;
|
||||||
// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);
|
|
||||||
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::c);
|
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::c);
|
||||||
|
|
||||||
// set palette
|
// set palette
|
||||||
|
@ -15,8 +15,10 @@ import com.boydti.fawe.object.collection.AdaptedMap;
|
|||||||
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.ListTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.jnbt.*;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
@ -25,7 +27,29 @@ import com.sk89q.worldedit.internal.Constants;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import net.minecraft.server.v1_16_R2.*;
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeStorage;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_16_R2.DataBits;
|
||||||
|
import net.minecraft.server.v1_16_R2.DataPalette;
|
||||||
|
import net.minecraft.server.v1_16_R2.DataPaletteBlock;
|
||||||
|
import net.minecraft.server.v1_16_R2.DataPaletteHash;
|
||||||
|
import net.minecraft.server.v1_16_R2.DataPaletteLinear;
|
||||||
|
import net.minecraft.server.v1_16_R2.Entity;
|
||||||
|
import net.minecraft.server.v1_16_R2.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_16_R2.EnumSkyBlock;
|
||||||
|
import net.minecraft.server.v1_16_R2.HeightMap;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||||
|
import net.minecraft.server.v1_16_R2.LightEngine;
|
||||||
|
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_16_R2.NBTTagInt;
|
||||||
|
import net.minecraft.server.v1_16_R2.NibbleArray;
|
||||||
|
import net.minecraft.server.v1_16_R2.SectionPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.TileEntity;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
@ -35,11 +59,20 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import java.util.AbstractSet;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
@ -48,24 +81,29 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_2.class);
|
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_2.class);
|
||||||
|
|
||||||
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
private static final Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
public ChunkSection[] sections;
|
public ChunkSection[] sections;
|
||||||
public Chunk nmsChunk;
|
public Chunk nmsChunk;
|
||||||
public WorldServer world;
|
public WorldServer world;
|
||||||
public int X, Z;
|
public int chunkX;
|
||||||
|
public int chunkZ;
|
||||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||||
private boolean createCopy = false;
|
private boolean createCopy = false;
|
||||||
private BukkitGetBlocks_1_16_2_Copy copy = null;
|
private BukkitGetBlocks_1_16_2_Copy copy = null;
|
||||||
|
|
||||||
public BukkitGetBlocks_1_16_2(World world, int X, int Z) {
|
public BukkitGetBlocks_1_16_2(World world, int chunkX, int chunkZ) {
|
||||||
this(((CraftWorld) world).getHandle(), X, Z);
|
this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitGetBlocks_1_16_2(WorldServer world, int X, int Z) {
|
public BukkitGetBlocks_1_16_2(WorldServer world, int chunkX, int chunkZ) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.X = X;
|
this.chunkX = chunkX;
|
||||||
this.Z = Z;
|
this.chunkZ = chunkZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChunkX() {
|
||||||
|
return chunkX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -83,12 +121,8 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getChunkZ() {
|
||||||
return X;
|
return chunkZ;
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ() {
|
|
||||||
return Z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,7 +132,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
if (y == -1) {
|
if (y == -1) {
|
||||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
||||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||||
if (base != null) break;
|
if (base != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||||
@ -108,7 +144,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTile(int x, int y, int z) {
|
public CompoundTag getTile(int x, int y, int z) {
|
||||||
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (
|
||||||
|
chunkX << 4), y, (z & 15) + (
|
||||||
|
chunkZ << 4)));
|
||||||
if (tileEntity == null) {
|
if (tileEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -196,7 +234,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (List<Entity> slice : slices) {
|
for (List<Entity> slice : slices) {
|
||||||
if (slice != null) size += slice.size();
|
if (slice != null) {
|
||||||
|
size += slice.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (slices.length == 0) {
|
if (slices.length == 0) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
@ -273,16 +313,16 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
entity.die();
|
entity.die();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R2.World nmsWorld, int X, int Z) {
|
public Chunk ensureLoaded(net.minecraft.server.v1_16_R2.World nmsWorld, int chunkX, int chunkZ) {
|
||||||
return BukkitAdapter_1_16_2.ensureLoaded(nmsWorld, X, Z);
|
return BukkitAdapter_1_16_2.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||||
copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world, getX(), getZ()) : null;
|
copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world, getChunkX(), getChunkZ()) : null;
|
||||||
try {
|
try {
|
||||||
WorldServer nmsWorld = world;
|
WorldServer nmsWorld = world;
|
||||||
Chunk nmsChunk = ensureLoaded(nmsWorld, X, Z);
|
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||||
boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE;
|
boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE;
|
||||||
|
|
||||||
// Remove existing tiles
|
// Remove existing tiles
|
||||||
@ -337,7 +377,8 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
} else {
|
} else {
|
||||||
existingSection = sections[layer];
|
existingSection = sections[layer];
|
||||||
if (existingSection == null) {
|
if (existingSection == null) {
|
||||||
log.error("Skipping invalid null section. chunk:" + X + "," + Z + " layer: " + layer);
|
log.error("Skipping invalid null section. chunk:" + chunkX + ","
|
||||||
|
+ chunkZ + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +407,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||||
if (!BukkitAdapter_1_16_2
|
if (!BukkitAdapter_1_16_2
|
||||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||||
log.error("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
|
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||||
@ -429,12 +470,14 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
|
|
||||||
Runnable[] syncTasks = null;
|
Runnable[] syncTasks = null;
|
||||||
|
|
||||||
int bx = X << 4;
|
int bx = chunkX << 4;
|
||||||
int bz = Z << 4;
|
int bz = chunkZ << 4;
|
||||||
|
|
||||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[3];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[2] = () -> {
|
syncTasks[2] = () -> {
|
||||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||||
@ -459,7 +502,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
|
|
||||||
Set<CompoundTag> entities = set.getEntities();
|
Set<CompoundTag> entities = set.getEntities();
|
||||||
if (entities != null && !entities.isEmpty()) {
|
if (entities != null && !entities.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[2];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[1] = () -> {
|
syncTasks[1] = () -> {
|
||||||
for (final CompoundTag nativeTag : entities) {
|
for (final CompoundTag nativeTag : entities) {
|
||||||
@ -501,7 +546,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
// set tiles
|
// set tiles
|
||||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||||
if (tiles != null && !tiles.isEmpty()) {
|
if (tiles != null && !tiles.isEmpty()) {
|
||||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
if (syncTasks == null) {
|
||||||
|
syncTasks = new Runnable[1];
|
||||||
|
}
|
||||||
|
|
||||||
syncTasks[0] = () -> {
|
syncTasks[0] = () -> {
|
||||||
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
||||||
@ -543,8 +590,10 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
nmsChunk.mustNotSave = false;
|
nmsChunk.mustNotSave = false;
|
||||||
nmsChunk.markDirty();
|
nmsChunk.markDirty();
|
||||||
// send to player
|
// send to player
|
||||||
BukkitAdapter_1_16_2.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
BukkitAdapter_1_16_2.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (syncTasks != null) {
|
if (syncTasks != null) {
|
||||||
@ -561,7 +610,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return queueHandler.async(callback, null);
|
return queueHandler.async(callback, null);
|
||||||
@ -574,7 +625,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
return (T) (Future) queueHandler.sync(chain);
|
return (T) (Future) queueHandler.sync(chain);
|
||||||
} else {
|
} else {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
if (finalizer != null) finalizer.run();
|
if (finalizer != null) {
|
||||||
|
finalizer.run();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
@ -724,7 +777,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
tmp = nmsChunk;
|
tmp = nmsChunk;
|
||||||
if (tmp == null) {
|
if (tmp == null) {
|
||||||
nmsChunk = tmp = ensureLoaded(this.world, X, Z);
|
nmsChunk = tmp = ensureLoaded(this.world, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,13 @@ import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||||
private static final int UPDATE = 1, NOTIFY = 2;
|
private static final int UPDATE = 1;
|
||||||
|
private static final int NOTIFY = 2;
|
||||||
|
|
||||||
private final FAWE_Spigot_v1_16_R2 adapter;
|
private final FAWE_Spigot_v1_16_R2 adapter;
|
||||||
private final WeakReference<World> world;
|
private final WeakReference<World> world;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.boydti.fawe.bukkit.filter;
|
package com.boydti.fawe.bukkit.filter;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
@ -14,6 +11,9 @@ import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
|||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
public class WorldGuardFilter extends CuboidRegionFilter {
|
public class WorldGuardFilter extends CuboidRegionFilter {
|
||||||
private final World world;
|
private final World world;
|
||||||
private boolean large;
|
private boolean large;
|
||||||
@ -23,6 +23,7 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
|||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateRegions() {
|
public void calculateRegions() {
|
||||||
Fawe.get().getQueueHandler().sync(() -> {
|
Fawe.get().getQueueHandler().sync(() -> {
|
||||||
@ -43,7 +44,9 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsChunk(int chunkX, int chunkZ) {
|
public boolean containsChunk(int chunkX, int chunkZ) {
|
||||||
if (!large) return super.containsChunk(chunkX, chunkZ);
|
if (!large) {
|
||||||
|
return super.containsChunk(chunkX, chunkZ);
|
||||||
|
}
|
||||||
BlockVector3 pos1 = BlockVector3.at(chunkX << 4, 0, chunkZ << 4);
|
BlockVector3 pos1 = BlockVector3.at(chunkX << 4, 0, chunkZ << 4);
|
||||||
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||||
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||||
@ -53,7 +56,9 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsRegion(int mcaX, int mcaZ) {
|
public boolean containsRegion(int mcaX, int mcaZ) {
|
||||||
if (!large) return super.containsRegion(mcaX, mcaZ);
|
if (!large) {
|
||||||
|
return super.containsRegion(mcaX, mcaZ);
|
||||||
|
}
|
||||||
BlockVector3 pos1 = BlockVector3.at(mcaX << 9, 0, mcaZ << 9);
|
BlockVector3 pos1 = BlockVector3.at(mcaX << 9, 0, mcaZ << 9);
|
||||||
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||||
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||||
|
@ -1,39 +1,17 @@
|
|||||||
package com.boydti.fawe.bukkit.listener;
|
package com.boydti.fawe.bukkit.listener;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
|
||||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||||
import com.boydti.fawe.object.brush.BrushSettings;
|
|
||||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
|
||||||
import com.boydti.fawe.util.ExtentTraverser;
|
|
||||||
import com.boydti.fawe.util.TaskManager;
|
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
|
||||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Rotation;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -41,13 +19,15 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BukkitImageListener implements Listener {
|
public class BukkitImageListener implements Listener {
|
||||||
|
|
||||||
private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
||||||
@ -57,31 +37,32 @@ public class BukkitImageListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO Fix along with CFI code 2020-02-04
|
//TODO Fix along with CFI code 2020-02-04
|
||||||
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
/*
|
||||||
// public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
// Set<Player> recipients = event.getRecipients();
|
public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
||||||
// Iterator<Player> iter = recipients.iterator();
|
Set<Player> recipients = event.getRecipients();
|
||||||
// while (iter.hasNext()) {
|
Iterator<Player> iter = recipients.iterator();
|
||||||
// Player player = iter.next();
|
while (iter.hasNext()) {
|
||||||
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
Player player = iter.next();
|
||||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||||
// if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||||
// continue;
|
if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
||||||
// }
|
continue;
|
||||||
//
|
}
|
||||||
// String name = player.getName().toLowerCase();
|
|
||||||
// if (!event.getMessage().toLowerCase().contains(name)) {
|
String name = player.getName().toLowerCase(Locale.ROOT);
|
||||||
// ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
if (!event.getMessage().toLowerCase(Locale.ROOT).contains(name)) {
|
||||||
// if (buffered == null) {
|
ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
||||||
// bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
if (buffered == null) {
|
||||||
// }
|
bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||||
// String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
}
|
||||||
// event.getMessage());
|
String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
||||||
// buffered.add(full);
|
event.getMessage());
|
||||||
// iter.remove();
|
buffered.add(full);
|
||||||
// }
|
iter.remove();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||||
@ -185,126 +166,127 @@ public class BukkitImageListener implements Listener {
|
|||||||
|
|
||||||
private void handleInteract(Event event, Player player, Entity entity, boolean primary) {
|
private void handleInteract(Event event, Player player, Entity entity, boolean primary) {
|
||||||
//todo fix with cfi code 2020-02-04
|
//todo fix with cfi code 2020-02-04
|
||||||
// if (!(entity instanceof ItemFrame)) {
|
/*
|
||||||
// return;
|
if (!(entity instanceof ItemFrame)) {
|
||||||
// }
|
return;
|
||||||
// ItemFrame itemFrame = (ItemFrame) entity;
|
}
|
||||||
//
|
ItemFrame itemFrame = (ItemFrame) entity;
|
||||||
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
|
||||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||||
// HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||||
// BukkitImageViewer viewer = get(generator);
|
HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
||||||
// if (viewer == null) {
|
BukkitImageViewer viewer = get(generator);
|
||||||
// return;
|
if (viewer == null) {
|
||||||
// }
|
return;
|
||||||
//
|
}
|
||||||
// if (itemFrame.getRotation() != Rotation.NONE) {
|
|
||||||
// itemFrame.setRotation(Rotation.NONE);
|
if (itemFrame.getRotation() != Rotation.NONE) {
|
||||||
// }
|
itemFrame.setRotation(Rotation.NONE);
|
||||||
//
|
}
|
||||||
// LocalSession session = bukkitPlayer.getSession();
|
|
||||||
// BrushTool tool;
|
LocalSession session = bukkitPlayer.getSession();
|
||||||
// try {
|
BrushTool tool;
|
||||||
// tool = session.getBrushTool(bukkitPlayer, false);
|
try {
|
||||||
// } catch (InvalidToolBindException e) {
|
tool = session.getBrushTool(bukkitPlayer, false);
|
||||||
// return;
|
} catch (InvalidToolBindException e) {
|
||||||
// }
|
return;
|
||||||
//
|
}
|
||||||
// ItemFrame[][] frames = viewer.getItemFrames();
|
|
||||||
// if (frames == null || tool == null) {
|
ItemFrame[][] frames = viewer.getItemFrames();
|
||||||
// viewer.selectFrame(itemFrame);
|
if (frames == null || tool == null) {
|
||||||
// player.updateInventory();
|
viewer.selectFrame(itemFrame);
|
||||||
// TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
player.updateInventory();
|
||||||
// return;
|
TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||||
// }
|
return;
|
||||||
//
|
}
|
||||||
// BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
|
||||||
// Brush brush = context.getBrush();
|
BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||||
// if (brush == null) {
|
Brush brush = context.getBrush();
|
||||||
// return;
|
if (brush == null) {
|
||||||
// }
|
return;
|
||||||
// tool.setContext(context);
|
}
|
||||||
//
|
tool.setContext(context);
|
||||||
// if (event instanceof Cancellable) {
|
|
||||||
// ((Cancellable) event).setCancelled(true);
|
if (event instanceof Cancellable) {
|
||||||
// }
|
((Cancellable) event).setCancelled(true);
|
||||||
//
|
}
|
||||||
// Location target = itemFrame.getLocation();
|
|
||||||
// Location source = player.getLocation();
|
Location target = itemFrame.getLocation();
|
||||||
//
|
Location source = player.getLocation();
|
||||||
// double yawRad = Math.toRadians(source.getYaw() + 90d);
|
|
||||||
// double pitchRad = Math.toRadians(-source.getPitch());
|
double yawRad = Math.toRadians(source.getYaw() + 90d);
|
||||||
//
|
double pitchRad = Math.toRadians(-source.getPitch());
|
||||||
// double a = Math.cos(pitchRad);
|
|
||||||
// double xRat = Math.cos(yawRad) * a;
|
double a = Math.cos(pitchRad);
|
||||||
// double zRat = Math.sin(yawRad) * a;
|
double xRat = Math.cos(yawRad) * a;
|
||||||
//
|
double zRat = Math.sin(yawRad) * a;
|
||||||
// BlockFace facing = itemFrame.getFacing();
|
|
||||||
// double thickness = 1 / 32D + 1 / 128D;
|
BlockFace facing = itemFrame.getFacing();
|
||||||
// double modX = facing.getModX();
|
double thickness = 1 / 32D + 1 / 128D;
|
||||||
// double modZ = facing.getModZ();
|
double modX = facing.getModX();
|
||||||
// double dx = source.getX() - target.getX() - modX * thickness;
|
double modZ = facing.getModZ();
|
||||||
// double dy = source.getY() + player.getEyeHeight() - target.getY();
|
double dx = source.getX() - target.getX() - modX * thickness;
|
||||||
// double dz = source.getZ() - target.getZ() - modZ * thickness;
|
double dy = source.getY() + player.getEyeHeight() - target.getY();
|
||||||
//
|
double dz = source.getZ() - target.getZ() - modZ * thickness;
|
||||||
// double offset;
|
|
||||||
// double localX;
|
double offset;
|
||||||
// if (modX != 0) {
|
double localX;
|
||||||
// offset = dx / xRat;
|
if (modX != 0) {
|
||||||
// localX = (-modX) * (dz - offset * zRat);
|
offset = dx / xRat;
|
||||||
// } else {
|
localX = (-modX) * (dz - offset * zRat);
|
||||||
// offset = dz / zRat;
|
} else {
|
||||||
// localX = (modZ) * (dx - offset * xRat);
|
offset = dz / zRat;
|
||||||
// }
|
localX = (modZ) * (dx - offset * xRat);
|
||||||
// double localY = dy - offset * Math.sin(pitchRad);
|
}
|
||||||
// int localPixelX = (int) ((localX + 0.5) * 128);
|
double localY = dy - offset * Math.sin(pitchRad);
|
||||||
// int localPixelY = (int) ((localY + 0.5) * 128);
|
int localPixelX = (int) ((localX + 0.5) * 128);
|
||||||
//
|
int localPixelY = (int) ((localY + 0.5) * 128);
|
||||||
// UUID uuid = itemFrame.getUniqueId();
|
|
||||||
// for (int blockX = 0; blockX < frames.length; blockX++) {
|
UUID uuid = itemFrame.getUniqueId();
|
||||||
// for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
for (int blockX = 0; blockX < frames.length; blockX++) {
|
||||||
// if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
||||||
// int pixelX = localPixelX + blockX * 128;
|
if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
||||||
// int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
int pixelX = localPixelX + blockX * 128;
|
||||||
//
|
int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
||||||
// int width = generator.getWidth();
|
|
||||||
// int length = generator.getLength();
|
int width = generator.getWidth();
|
||||||
// int worldX = (int) (pixelX * width / (frames.length * 128d));
|
int length = generator.getLength();
|
||||||
// int worldZ = (int) (pixelY * length / (frames[0].length * 128d));
|
int worldX = (int) (pixelX * width / (frames.length * 128d));
|
||||||
//
|
int worldZ = (int) (pixelY * length / (frames[0].length * 128d));
|
||||||
// if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) {
|
|
||||||
// return;
|
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) {
|
||||||
// }
|
return;
|
||||||
//
|
}
|
||||||
// bukkitPlayer.runAction(() -> {
|
|
||||||
// BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
bukkitPlayer.runAction(() -> {
|
||||||
// viewer.refresh();
|
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||||
// int topY = generator
|
viewer.refresh();
|
||||||
// .getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
int topY = generator
|
||||||
// 0, 255);
|
.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
||||||
// wPos = wPos.withY(topY);
|
0, 255);
|
||||||
//
|
wPos = wPos.withY(topY);
|
||||||
// EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
|
||||||
// .combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
||||||
// .build();
|
.combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
||||||
// ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
.build();
|
||||||
// Extent extent = last.get();
|
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||||
// if (extent instanceof IQueueExtent) {
|
Extent extent = last.get();
|
||||||
// last = last.previous();
|
if (extent instanceof IQueueExtent) {
|
||||||
// }
|
last = last.previous();
|
||||||
// last.setNext(generator);
|
}
|
||||||
// try {
|
last.setNext(generator);
|
||||||
// brush.build(es, wPos, context.getMaterial(), context.getSize());
|
try {
|
||||||
// } catch (WorldEditException e) {
|
brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||||
// e.printStackTrace();
|
} catch (WorldEditException e) {
|
||||||
// }
|
e.printStackTrace();
|
||||||
// es.flushQueue();
|
}
|
||||||
// viewer.view(generator);
|
es.flushQueue();
|
||||||
// }, true, true);
|
viewer.view(generator);
|
||||||
//
|
}, true, true);
|
||||||
// return;
|
|
||||||
// }
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,10 @@ import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
|||||||
import com.sk89q.worldedit.event.platform.Interaction;
|
import com.sk89q.worldedit.event.platform.Interaction;
|
||||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -40,13 +33,17 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CFIPacketListener handles packets for editing the VirtualWorld
|
* The CFIPacketListener handles packets for editing the {@link VirtualWorld}.
|
||||||
* The generator is a virtual world which only the creator can see
|
*
|
||||||
* - The virtual world is displayed inside the current world
|
* <p>
|
||||||
* - Block/Chunk/Movement packets need to be handled properly
|
* The virtual world will be displayed inside the current world. Block/Chunk/Movement packets
|
||||||
|
* need to be handled properly.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class CFIPacketListener implements Listener {
|
public class CFIPacketListener implements Listener {
|
||||||
|
|
||||||
@ -122,7 +119,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) {
|
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
if (!event.isServerPacket() || FaweCache.IMP.CHUNK_FLAG.get().get()) return;
|
if (!event.isServerPacket() || FaweCache.IMP.CHUNK_FLAG.get().get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
VirtualWorld gen = getGenerator(event);
|
VirtualWorld gen = getGenerator(event);
|
||||||
if (gen != null) {
|
if (gen != null) {
|
||||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||||
@ -147,7 +146,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_VELOCITY) {
|
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_VELOCITY) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
if (!event.isServerPacket()) return;
|
if (!event.isServerPacket()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location pos = player.getLocation();
|
Location pos = player.getLocation();
|
||||||
@ -172,7 +173,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.POSITION) {
|
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.POSITION) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
if (!event.isServerPacket()) return;
|
if (!event.isServerPacket()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location pos = player.getLocation();
|
Location pos = player.getLocation();
|
||||||
@ -202,7 +205,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
|
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
if (!event.isServerPacket()) return;
|
if (!event.isServerPacket()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VirtualWorld gen = getGenerator(event);
|
VirtualWorld gen = getGenerator(event);
|
||||||
if (gen != null) {
|
if (gen != null) {
|
||||||
@ -260,7 +265,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
private VirtualWorld getGenerator(Player player) {
|
private VirtualWorld getGenerator(Player player) {
|
||||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||||
VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
|
VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
|
||||||
if (vw != null) return vw;
|
if (vw != null) {
|
||||||
|
return vw;
|
||||||
|
}
|
||||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||||
// if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
// if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
||||||
// return settings.getGenerator();
|
// return settings.getGenerator();
|
||||||
@ -272,7 +279,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
PacketContainer packet = event.getPacket();
|
PacketContainer packet = event.getPacket();
|
||||||
StructureModifier<BlockPosition> position = packet.getBlockPositionModifier();
|
StructureModifier<BlockPosition> position = packet.getBlockPositionModifier();
|
||||||
BlockPosition loc = position.readSafely(0);
|
BlockPosition loc = position.readSafely(0);
|
||||||
if (loc == null) return null;
|
if (loc == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
BlockVector3 origin = generator.getOrigin().toBlockPoint();
|
BlockVector3 origin = generator.getOrigin().toBlockPoint();
|
||||||
return BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
return BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||||
}
|
}
|
||||||
@ -282,7 +291,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
if (gen != null) {
|
if (gen != null) {
|
||||||
BlockVector3 pt = getRelPos(event, gen);
|
BlockVector3 pt = getRelPos(event, gen);
|
||||||
if (pt != null) {
|
if (pt != null) {
|
||||||
if (relative) pt = getRelative(event, pt);
|
if (relative) {
|
||||||
|
pt = getRelative(event, pt);
|
||||||
|
}
|
||||||
if (gen.contains(pt)) {
|
if (gen.contains(pt)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
task.run(event, gen, pt);
|
task.run(event, gen, pt);
|
||||||
@ -295,7 +306,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, type) {
|
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, type) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(final PacketEvent event) {
|
public void onPacketReceiving(final PacketEvent event) {
|
||||||
if (type.isClient() || event.isServerPacket()) handleBlockEvent(event, relative, task);
|
if (type.isClient() || event.isServerPacket()) {
|
||||||
|
handleBlockEvent(event, relative, task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -309,7 +322,9 @@ public class CFIPacketListener implements Listener {
|
|||||||
PacketContainer packet = container.getPacket();
|
PacketContainer packet = container.getPacket();
|
||||||
StructureModifier<EnumWrappers.Direction> dirs = packet.getDirections();
|
StructureModifier<EnumWrappers.Direction> dirs = packet.getDirections();
|
||||||
EnumWrappers.Direction dir = dirs.readSafely(0);
|
EnumWrappers.Direction dir = dirs.readSafely(0);
|
||||||
if (dir == null) return pt;
|
if (dir == null) {
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
switch (dir.ordinal()) {
|
switch (dir.ordinal()) {
|
||||||
case 0: return pt.add(0, -1, 0);
|
case 0: return pt.add(0, -1, 0);
|
||||||
case 1: return pt.add(0, 1, 0);
|
case 1: return pt.add(0, 1, 0);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.boydti.fawe.bukkit.listener;
|
package com.boydti.fawe.bukkit.listener;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
@ -25,6 +23,7 @@ import org.bukkit.event.block.BlockCanBuildEvent;
|
|||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
import org.bukkit.event.block.BlockExpEvent;
|
import org.bukkit.event.block.BlockExpEvent;
|
||||||
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.block.BlockFadeEvent;
|
import org.bukkit.event.block.BlockFadeEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.block.BlockGrowEvent;
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
@ -45,6 +44,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
public abstract class ChunkListener implements Listener {
|
public abstract class ChunkListener implements Listener {
|
||||||
|
|
||||||
private final Logger logger = getLogger(ChunkListener.class);
|
private final Logger logger = getLogger(ChunkListener.class);
|
||||||
@ -58,10 +59,6 @@ public abstract class ChunkListener implements Listener {
|
|||||||
PluginManager plm = Bukkit.getPluginManager();
|
PluginManager plm = Bukkit.getPluginManager();
|
||||||
Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin();
|
Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin();
|
||||||
plm.registerEvents(this, plugin);
|
plm.registerEvents(this, plugin);
|
||||||
try {
|
|
||||||
plm.registerEvents(new ChunkListener_8Plus(this), plugin);
|
|
||||||
} catch (Throwable ignore) {
|
|
||||||
}
|
|
||||||
TaskManager.IMP.repeat(() -> {
|
TaskManager.IMP.repeat(() -> {
|
||||||
Location tmpLoc = lastCancelPos;
|
Location tmpLoc = lastCancelPos;
|
||||||
if (tmpLoc != null) {
|
if (tmpLoc != null) {
|
||||||
@ -98,7 +95,8 @@ public abstract class ChunkListener implements Listener {
|
|||||||
|
|
||||||
protected final Long2ObjectOpenHashMap<Boolean> badChunks = new Long2ObjectOpenHashMap<>();
|
protected final Long2ObjectOpenHashMap<Boolean> badChunks = new Long2ObjectOpenHashMap<>();
|
||||||
private Long2ObjectOpenHashMap<int[]> counter = new Long2ObjectOpenHashMap<>();
|
private Long2ObjectOpenHashMap<int[]> counter = new Long2ObjectOpenHashMap<>();
|
||||||
private int lastX = Integer.MIN_VALUE, lastZ = Integer.MIN_VALUE;
|
private int lastX = Integer.MIN_VALUE;
|
||||||
|
private int lastZ = Integer.MIN_VALUE;
|
||||||
private int[] lastCount;
|
private int[] lastCount;
|
||||||
|
|
||||||
public int[] getCount(int cx, int cz) {
|
public int[] getCount(int cx, int cz) {
|
||||||
@ -138,6 +136,11 @@ public abstract class ChunkListener implements Listener {
|
|||||||
physCancel = false;
|
physCancel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void event(BlockExplodeEvent event) {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void event(BlockBurnEvent event) {
|
public void event(BlockBurnEvent event) {
|
||||||
reset();
|
reset();
|
||||||
@ -250,14 +253,6 @@ public abstract class ChunkListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// switch (event.getChangedType()) {
|
|
||||||
// case AIR:
|
|
||||||
// case CAVE_AIR:
|
|
||||||
// case VOID_AIR:
|
|
||||||
// break;
|
|
||||||
// case REDSTONE_WIRE::
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
Exception e = new Exception();
|
Exception e = new Exception();
|
||||||
int depth = getDepth(e);
|
int depth = getDepth(e);
|
||||||
if (depth >= 256) {
|
if (depth >= 256) {
|
||||||
@ -354,9 +349,7 @@ public abstract class ChunkListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent FireWorks from loading chunks
|
* Prevent firework from loading chunks.
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
|
@ -9,12 +9,12 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
public class ChunkListener_9 extends ChunkListener {
|
public class ChunkListener9 extends ChunkListener {
|
||||||
|
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
private StackTraceElement[] elements;
|
private StackTraceElement[] elements;
|
||||||
|
|
||||||
public ChunkListener_9() {
|
public ChunkListener9() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,6 @@ public class ChunkListener_9 extends ChunkListener {
|
|||||||
cancelNearby(cx, cz);
|
cancelNearby(cx, cz);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
physCancel = true;
|
physCancel = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +0,0 @@
|
|||||||
package com.boydti.fawe.bukkit.listener;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
|
||||||
|
|
||||||
public class ChunkListener_8Plus implements Listener{
|
|
||||||
private final ChunkListener listener;
|
|
||||||
|
|
||||||
public ChunkListener_8Plus(ChunkListener listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void event(BlockExplodeEvent event) {
|
|
||||||
listener.reset();
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,10 +3,6 @@ package com.boydti.fawe.bukkit.listener;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -19,6 +15,11 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class RenderListener implements Listener {
|
public class RenderListener implements Listener {
|
||||||
|
|
||||||
private final Map<UUID, int[]> views = new ConcurrentHashMap<>();
|
private final Map<UUID, int[]> views = new ConcurrentHashMap<>();
|
||||||
@ -32,7 +33,9 @@ public class RenderListener implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (views.isEmpty()) return;
|
if (views.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
int tps32 = (int) (Math.round(Fawe.get().getTimer().getTPS()) * 32);
|
int tps32 = (int) (Math.round(Fawe.get().getTimer().getTPS()) * 32);
|
||||||
@ -64,8 +67,9 @@ public class RenderListener implements Listener {
|
|||||||
setViewDistance(player, Math.max(4, value[0] + 1));
|
setViewDistance(player, Math.max(4, value[0] + 1));
|
||||||
long spent = System.currentTimeMillis() - now;
|
long spent = System.currentTimeMillis() - now;
|
||||||
if (spent > 5) {
|
if (spent > 5) {
|
||||||
if (spent > 10)
|
if (spent > 10) {
|
||||||
value[1] = nowTick + 20;
|
value[1] = nowTick + 20;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,9 @@ public class PluginPreloader extends PluginBase {
|
|||||||
loaded = region.getChunks();
|
loaded = region.getChunks();
|
||||||
Iterator<BlockVector2> iter = loaded.iterator();
|
Iterator<BlockVector2> iter = loaded.iterator();
|
||||||
|
|
||||||
if (!invalidator.get()) return;
|
if (!invalidator.get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Fawe.get().getQueueHandler().syncWhenFree(() -> {
|
Fawe.get().getQueueHandler().syncWhenFree(() -> {
|
||||||
for (; iter.hasNext() && invalidator.get();index++) {
|
for (; iter.hasNext() && invalidator.get();index++) {
|
||||||
BlockVector2 chunk = iter.next();
|
BlockVector2 chunk = iter.next();
|
||||||
@ -95,22 +97,26 @@ public class PluginPreloader extends PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull File getDataFolder() {
|
@NotNull
|
||||||
|
public File getDataFolder() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull PluginDescriptionFile getDescription() {
|
@NotNull
|
||||||
|
public PluginDescriptionFile getDescription() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FileConfiguration getConfig() {
|
@NotNull
|
||||||
|
public FileConfiguration getConfig() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable InputStream getResource(@NotNull String filename) {
|
@Nullable
|
||||||
|
public InputStream getResource(@NotNull String filename) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,12 +141,14 @@ public class PluginPreloader extends PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull PluginLoader getPluginLoader() {
|
@NotNull
|
||||||
|
public PluginLoader getPluginLoader() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Server getServer() {
|
@NotNull
|
||||||
|
public Server getServer() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,12 +183,14 @@ public class PluginPreloader extends PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
|
@Nullable
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Logger getLogger() {
|
@NotNull
|
||||||
|
public Logger getLogger() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +200,8 @@ public class PluginPreloader extends PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
@Nullable
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.EventException;
|
import org.bukkit.event.EventException;
|
||||||
@ -17,6 +16,9 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class FreeBuildRegion extends BukkitMaskManager {
|
public class FreeBuildRegion extends BukkitMaskManager {
|
||||||
private final ArrayList<RegisteredListener> listeners;
|
private final ArrayList<RegisteredListener> listeners;
|
||||||
|
|
||||||
@ -25,8 +27,12 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
|||||||
this.listeners = new ArrayList<>();
|
this.listeners = new ArrayList<>();
|
||||||
RegisteredListener[] listeners = BlockBreakEvent.getHandlerList().getRegisteredListeners();
|
RegisteredListener[] listeners = BlockBreakEvent.getHandlerList().getRegisteredListeners();
|
||||||
for (RegisteredListener listener : listeners) {
|
for (RegisteredListener listener : listeners) {
|
||||||
if (listener.getPriority() == EventPriority.MONITOR) continue;
|
if (listener.getPriority() == EventPriority.MONITOR) {
|
||||||
if (!listener.isIgnoringCancelled()) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (!listener.isIgnoringCancelled()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this.listeners.add(listener);
|
this.listeners.add(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,14 +44,20 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(Player player, MaskType type) {
|
public FaweMask getMask(Player player, MaskType type) {
|
||||||
if (type != MaskType.MEMBER) return null;
|
if (type != MaskType.MEMBER) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
ArrayList<RegisteredListener> currRegList = new ArrayList<>();
|
ArrayList<RegisteredListener> currRegList = new ArrayList<>();
|
||||||
for (RegisteredListener listener : this.listeners) {
|
for (RegisteredListener listener : this.listeners) {
|
||||||
String name = listener.getPlugin().getName();
|
String name = listener.getPlugin().getName();
|
||||||
if (!player.hasPermission("fawe.freebuild." + name.toLowerCase())) continue;
|
if (!player.hasPermission("fawe.freebuild." + name.toLowerCase(Locale.ROOT))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
currRegList.add(listener);
|
currRegList.add(listener);
|
||||||
}
|
}
|
||||||
if (currRegList.isEmpty()) return null;
|
if (currRegList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]);
|
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]);
|
||||||
|
|
||||||
World bukkitWorld = BukkitAdapter.adapt(player.getWorld());
|
World bukkitWorld = BukkitAdapter.adapt(player.getWorld());
|
||||||
@ -73,12 +85,15 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
|||||||
return contains(x, 127, z);
|
return contains(x, 127, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int lastX = Integer.MIN_VALUE, lastZ = Integer.MIN_VALUE;
|
private int lastX = Integer.MIN_VALUE;
|
||||||
|
private int lastZ = Integer.MIN_VALUE;
|
||||||
private boolean lastResult;
|
private boolean lastResult;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
if (x == lastX && z == lastZ) return lastResult;
|
if (x == lastX && z == lastZ) {
|
||||||
|
return lastResult;
|
||||||
|
}
|
||||||
lastX = x;
|
lastX = x;
|
||||||
lastZ = z;
|
lastZ = z;
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
|
@ -38,7 +38,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
|||||||
if (block.getResident().equals(resident)) {
|
if (block.getResident().equals(resident)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException ignore) {}
|
} catch (NotRegisteredException ignored) {
|
||||||
|
}
|
||||||
Town town = block.getTown();
|
Town town = block.getTown();
|
||||||
if (town.isMayor(resident)) {
|
if (town.isMayor(resident)) {
|
||||||
return true;
|
return true;
|
||||||
@ -54,7 +55,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException ignore) {}
|
} catch (NotRegisteredException ignored) {
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +89,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class Worldguard extends BukkitMaskManager implements Listener {
|
public class Worldguard extends BukkitMaskManager implements Listener {
|
||||||
private final WorldGuardPlugin worldguard;
|
private final WorldGuardPlugin worldguard;
|
||||||
|
|
||||||
@ -78,9 +80,9 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
|||||||
//Check if player is the owner of the region, the region's ID contains the player's name (why?), or if the region's owners contains "*".
|
//Check if player is the owner of the region, the region's ID contains the player's name (why?), or if the region's owners contains "*".
|
||||||
if (region.isOwner(localplayer) || region.isOwner(localplayer.getName())) {
|
if (region.isOwner(localplayer) || region.isOwner(localplayer.getName())) {
|
||||||
return true;
|
return true;
|
||||||
} else if (region.getId().toLowerCase().equals(localplayer.getName().toLowerCase())) {
|
} else if (region.getId().toLowerCase(Locale.ROOT).equals(localplayer.getName().toLowerCase(Locale.ROOT))) {
|
||||||
return true;
|
return true;
|
||||||
} else if (region.getId().toLowerCase().contains(localplayer.getName().toLowerCase() + "//")) {
|
} else if (region.getId().toLowerCase(Locale.ROOT).contains(localplayer.getName().toLowerCase(Locale.ROOT) + "//")) {
|
||||||
return true;
|
return true;
|
||||||
} else if (region.isOwner("*")) {
|
} else if (region.isOwner("*")) {
|
||||||
return true;
|
return true;
|
||||||
@ -90,9 +92,10 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
|||||||
if (localplayer.hasPermission("fawe.worldguard.member")) {
|
if (localplayer.hasPermission("fawe.worldguard.member")) {
|
||||||
if (region.isMember(localplayer) || region.isMember(localplayer.getName())) {
|
if (region.isMember(localplayer) || region.isMember(localplayer.getName())) {
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else {
|
||||||
return region.isMember("*");
|
return region.isMember("*");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +125,6 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||||
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
|
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.boydti.fawe.bukkit.regions.plotsquared;
|
package com.boydti.fawe.bukkit.regions.plotsquared;
|
||||||
|
|
||||||
import static org.bukkit.Bukkit.getWorld;
|
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
||||||
@ -29,6 +27,8 @@ import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -39,7 +39,8 @@ import java.net.URL;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
|
||||||
|
import static org.bukkit.Bukkit.getWorld;
|
||||||
|
|
||||||
public class FaweSchematicHandler extends SchematicHandler {
|
public class FaweSchematicHandler extends SchematicHandler {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package com.boydti.fawe.bukkit.regions.plotsquared;
|
package com.boydti.fawe.bukkit.regions.plotsquared;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||||
private final PlotArea area;
|
private final PlotArea area;
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ public class PlotRegionFilter extends CuboidRegionFilter {
|
|||||||
checkNotNull(area);
|
checkNotNull(area);
|
||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateRegions() {
|
public void calculateRegions() {
|
||||||
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
||||||
|
@ -24,11 +24,12 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.biome.Biomes;
|
import com.sk89q.worldedit.world.biome.Biomes;
|
||||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "generatebiome",
|
command = "generatebiome",
|
||||||
|
@ -23,13 +23,15 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PlotSquaredFeature extends FaweMaskManager {
|
public class PlotSquaredFeature extends FaweMaskManager {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PlotSquaredFeature.class);
|
private static final Logger log = LoggerFactory.getLogger(PlotSquaredFeature.class);
|
||||||
@ -46,7 +48,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
log.debug("Please update PlotSquared: https://www.spigotmc.org/resources/plotsquared-v5.77506/");
|
log.debug("Please update PlotSquared: https://www.spigotmc.org/resources/plotsquared-v5.77506/");
|
||||||
}
|
}
|
||||||
if (Settings.PLATFORM.toLowerCase().startsWith("bukkit")) {
|
if (Settings.PLATFORM.toLowerCase(Locale.ROOT).startsWith("bukkit")) {
|
||||||
new FaweTrim();
|
new FaweTrim();
|
||||||
}
|
}
|
||||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||||
@ -93,12 +95,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID uid = player.getUniqueId();
|
UUID uid = player.getUniqueId();
|
||||||
return !plot.getFlag(NoWorldeditFlag.class) && (plot.isOwner(uid)
|
return !plot.getFlag(NoWorldeditFlag.class) && (plot.isOwner(uid) || type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot
|
||||||
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
|
.getTrusted().contains(DBFunc.EVERYONE) || (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player
|
||||||
.contains(DBFunc.EVERYONE)
|
.hasPermission("fawe.plotsquared.member")) || player.hasPermission("fawe.plotsquared.admin"));
|
||||||
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
|
|
||||||
&& player.hasPermission("fawe.plotsquared.member")) || player
|
|
||||||
.hasPermission("fawe.plotsquared.admin"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -141,7 +140,10 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
maskedRegion = new CuboidRegion(pos1, pos2);
|
maskedRegion = new CuboidRegion(pos1, pos2);
|
||||||
} else {
|
} else {
|
||||||
World world = FaweAPI.getWorld(area.getWorldName());
|
World world = FaweAPI.getWorld(area.getWorldName());
|
||||||
maskedRegion = new RegionIntersection(world, new ArrayList<>(regions));
|
List<Region> weRegions = regions.stream().map(
|
||||||
|
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
|
||||||
|
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()))).collect(Collectors.toList());
|
||||||
|
maskedRegion = new RegionIntersection(world, weRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FaweMask(maskedRegion) {
|
return new FaweMask(maskedRegion) {
|
||||||
@ -158,7 +160,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
@Override
|
@Override
|
||||||
public RegionFilter getFilter(String world) {
|
public RegionFilter getFilter(String world) {
|
||||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||||
if (area != null) return new PlotRegionFilter(area);
|
if (area != null) {
|
||||||
|
return new PlotRegionFilter(area);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
||||||
|
|
||||||
import static org.bukkit.Bukkit.getWorld;
|
|
||||||
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
@ -18,8 +16,11 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import static org.bukkit.Bukkit.getWorld;
|
||||||
|
|
||||||
public class FaweChunkManager extends ChunkManager {
|
public class FaweChunkManager extends ChunkManager {
|
||||||
|
|
||||||
private ChunkManager parent;
|
private ChunkManager parent;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
||||||
|
|
||||||
import static org.bukkit.Bukkit.getWorld;
|
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
||||||
@ -29,6 +27,8 @@ import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -39,7 +39,8 @@ import java.net.URL;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
|
||||||
|
import static org.bukkit.Bukkit.getWorld;
|
||||||
|
|
||||||
public class FaweSchematicHandler extends SchematicHandler {
|
public class FaweSchematicHandler extends SchematicHandler {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||||
private final PlotArea area;
|
private final PlotArea area;
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ public class PlotRegionFilter extends CuboidRegionFilter {
|
|||||||
checkNotNull(area);
|
checkNotNull(area);
|
||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculateRegions() {
|
public void calculateRegions() {
|
||||||
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
||||||
|
@ -10,7 +10,6 @@ import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
|
import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
@ -18,21 +17,21 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class PlotSquaredFeature extends FaweMaskManager {
|
public class PlotSquaredFeature extends FaweMaskManager {
|
||||||
|
|
||||||
@ -48,9 +47,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
setupSchematicHandler();
|
setupSchematicHandler();
|
||||||
setupChunkManager();
|
setupChunkManager();
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
|
log.debug("Please update PlotSquared: https://www.spigotmc.org/resources/77506/");
|
||||||
}
|
}
|
||||||
if (Settings.PLATFORM.toLowerCase().startsWith("bukkit")) {
|
if (Settings.PLATFORM.toLowerCase(Locale.ROOT).startsWith("bukkit")) {
|
||||||
new FaweTrim();
|
new FaweTrim();
|
||||||
}
|
}
|
||||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||||
@ -168,7 +167,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
@Override
|
@Override
|
||||||
public RegionFilter getFilter(String world) {
|
public RegionFilter getFilter(String world) {
|
||||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||||
if (area != null) return new PlotRegionFilter(area);
|
if (area != null) {
|
||||||
|
return new PlotRegionFilter(area);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,9 @@ public class ItemUtil {
|
|||||||
public Object getNMSItem(ItemStack item) {
|
public Object getNMSItem(ItemStack item) {
|
||||||
try {
|
try {
|
||||||
Object nmsItem = fieldHandle.get(item);
|
Object nmsItem = fieldHandle.get(item);
|
||||||
if (nmsItem == null) nmsItem = methodAsNMSCopy.invoke(null, item);
|
if (nmsItem == null) {
|
||||||
|
nmsItem = methodAsNMSCopy.invoke(null, item);
|
||||||
|
}
|
||||||
return nmsItem;
|
return nmsItem;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -57,12 +59,18 @@ public class ItemUtil {
|
|||||||
|
|
||||||
public CompoundTag getNBT(ItemStack item) {
|
public CompoundTag getNBT(ItemStack item) {
|
||||||
try {
|
try {
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Object nmsItem = fieldHandle.get(item);
|
Object nmsItem = fieldHandle.get(item);
|
||||||
if (nmsItem == null) nmsItem = methodAsNMSCopy.invoke(null, item);
|
if (nmsItem == null) {
|
||||||
|
nmsItem = methodAsNMSCopy.invoke(null, item);
|
||||||
|
}
|
||||||
if (methodHasTag.invoke(nmsItem).equals(true)) {
|
if (methodHasTag.invoke(nmsItem).equals(true)) {
|
||||||
Object nmsTag = methodGetTag.invoke(nmsItem);
|
Object nmsTag = methodGetTag.invoke(nmsItem);
|
||||||
if (nmsTag == null) return null;
|
if (nmsTag == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Int2ObjectOpenHashMap<WeakReference<Tag>> map = hashToNMSTag.get();
|
Int2ObjectOpenHashMap<WeakReference<Tag>> map = hashToNMSTag.get();
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
@ -72,7 +80,9 @@ public class ItemUtil {
|
|||||||
WeakReference<Tag> nativeTagRef = map.get(nmsTag.hashCode());
|
WeakReference<Tag> nativeTagRef = map.get(nmsTag.hashCode());
|
||||||
if (nativeTagRef != null) {
|
if (nativeTagRef != null) {
|
||||||
Tag nativeTag = nativeTagRef.get();
|
Tag nativeTag = nativeTagRef.get();
|
||||||
if (nativeTag != null) return (CompoundTag) nativeTag;
|
if (nativeTag != null) {
|
||||||
|
return (CompoundTag) nativeTag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Tag nativeTag = adapter.toNative(nmsTag);
|
Tag nativeTag = adapter.toNative(nmsTag);
|
||||||
map.put(nmsTag.hashCode(), new WeakReference<>(nativeTag));
|
map.put(nmsTag.hashCode(), new WeakReference<>(nativeTag));
|
||||||
@ -94,7 +104,9 @@ public class ItemUtil {
|
|||||||
}
|
}
|
||||||
Object nmsTag = adapter.fromNative(tag);
|
Object nmsTag = adapter.fromNative(tag);
|
||||||
methodSetTag.invoke(nmsItem, nmsTag);
|
methodSetTag.invoke(nmsItem, nmsTag);
|
||||||
if (copy) return (ItemStack) methodAsBukkitCopy.invoke(null, nmsItem);
|
if (copy) {
|
||||||
|
return (ItemStack) methodAsBukkitCopy.invoke(null, nmsItem);
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -3,11 +3,6 @@ package com.boydti.fawe.bukkit.util.image;
|
|||||||
import com.boydti.fawe.util.image.Drawable;
|
import com.boydti.fawe.util.image.Drawable;
|
||||||
import com.boydti.fawe.util.image.ImageUtil;
|
import com.boydti.fawe.util.image.ImageUtil;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collection;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -25,6 +20,12 @@ import org.inventivetalent.mapmanager.controller.MultiMapController;
|
|||||||
import org.inventivetalent.mapmanager.manager.MapManager;
|
import org.inventivetalent.mapmanager.manager.MapManager;
|
||||||
import org.inventivetalent.mapmanager.wrapper.MapWrapper;
|
import org.inventivetalent.mapmanager.wrapper.MapWrapper;
|
||||||
|
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BukkitImageViewer implements ImageViewer {
|
public class BukkitImageViewer implements ImageViewer {
|
||||||
private final MapManager mapManager;
|
private final MapManager mapManager;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
@ -116,7 +117,9 @@ public class BukkitImageViewer implements ImageViewer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!contains) return null;
|
if (!contains) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,11 +136,15 @@ public class BukkitImageViewer implements ImageViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void view(@Nullable BufferedImage image, @Nullable Drawable drawable) {
|
private void view(@Nullable BufferedImage image, @Nullable Drawable drawable) {
|
||||||
if (image == null && drawable == null) throw new IllegalArgumentException("An image or drawable must be provided. Both cannot be null");
|
if (image == null && drawable == null) {
|
||||||
|
throw new IllegalArgumentException("An image or drawable must be provided. Both cannot be null");
|
||||||
|
}
|
||||||
boolean initializing = last == null;
|
boolean initializing = last == null;
|
||||||
|
|
||||||
if (this.frames != null) {
|
if (this.frames != null) {
|
||||||
if (image == null && drawable != null) image = drawable.draw();
|
if (image == null && drawable != null) {
|
||||||
|
image = drawable.draw();
|
||||||
|
}
|
||||||
last = image;
|
last = image;
|
||||||
int width = frames.length;
|
int width = frames.length;
|
||||||
int height = frames[0].length;
|
int height = frames[0].length;
|
||||||
@ -158,7 +165,9 @@ public class BukkitImageViewer implements ImageViewer {
|
|||||||
} else if (player.getInventory().getHeldItemSlot() != slot) {
|
} else if (player.getInventory().getHeldItemSlot() != slot) {
|
||||||
player.getInventory().setHeldItemSlot(slot);
|
player.getInventory().setHeldItemSlot(slot);
|
||||||
}
|
}
|
||||||
if (image == null && drawable != null) image = drawable.draw();
|
if (image == null && drawable != null) {
|
||||||
|
image = drawable.draw();
|
||||||
|
}
|
||||||
last = image;
|
last = image;
|
||||||
BufferedImage scaled = ImageUtil.getScaledInstance(image, 128, 128, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
BufferedImage scaled = ImageUtil.getScaledInstance(image, 128, 128, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||||
MapWrapper mapWrapper = mapManager.wrapImage(scaled);
|
MapWrapper mapWrapper = mapManager.wrapImage(scaled);
|
||||||
@ -181,7 +190,9 @@ public class BukkitImageViewer implements ImageViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
if (last != null) view(last, null);
|
if (last != null) {
|
||||||
|
view(last, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,13 +107,13 @@ public class AsyncBlock implements Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean setCombinedId(int combinedId) {
|
public boolean setTypeIdAndPropertyId(int id, int propertyId) {
|
||||||
return world.setBlock(x, y, z, BlockState.getFromInternalId(combinedId));
|
return setCombinedId(id + (propertyId << BlockTypesCache.BIT_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean setTypeIdAndPropertyId(int id, int propertyId) {
|
public boolean setCombinedId(int combinedId) {
|
||||||
return setCombinedId(id + (propertyId << BlockTypesCache.BIT_OFFSET));
|
return world.setBlock(x, y, z, BlockState.getFromInternalId(combinedId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -361,6 +361,10 @@ public class AsyncBlock implements Block {
|
|||||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool));
|
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<ItemStack> getDrops(ItemStack tool, Entity entity) {
|
||||||
|
return Collections.emptyList(); //todo
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) {
|
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) {
|
||||||
this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue);
|
this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue);
|
||||||
@ -409,12 +413,9 @@ public class AsyncBlock implements Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull BlockSoundGroup getSoundGroup() {
|
@NotNull
|
||||||
|
public BlockSoundGroup getSoundGroup() {
|
||||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getSoundGroup());
|
return TaskManager.IMP.sync(() -> getUnsafeBlock().getSoundGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ItemStack> getDrops(ItemStack tool, Entity entity) {
|
|
||||||
return Collections.emptyList(); //todo
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,8 @@ public class AsyncChunk implements Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull BlockState[] getTileEntities(boolean useSnapshot) {
|
@NotNull
|
||||||
|
public BlockState[] getTileEntities(boolean useSnapshot) {
|
||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return new BlockState[0];
|
return new BlockState[0];
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.object.RunnableVal;
|
|||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.destroystokyo.paper.HeightmapType;
|
import com.destroystokyo.paper.HeightmapType;
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
@ -13,6 +14,7 @@ import com.sk89q.worldedit.extent.PassthroughExtent;
|
|||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import io.papermc.paper.world.MoonPhase;
|
||||||
import org.bukkit.BlockChangeDelegate;
|
import org.bukkit.BlockChangeDelegate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -60,7 +62,6 @@ import org.bukkit.util.RayTraceResult;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import io.papermc.paper.world.MoonPhase;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -81,6 +82,7 @@ import java.util.function.Predicate;
|
|||||||
* @see #wrap(World)
|
* @see #wrap(World)
|
||||||
* @see #create(WorldCreator)
|
* @see #create(WorldCreator)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class AsyncWorld extends PassthroughExtent implements World {
|
public class AsyncWorld extends PassthroughExtent implements World {
|
||||||
|
|
||||||
private World parent;
|
private World parent;
|
||||||
@ -93,9 +95,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent Parent world
|
* An internal constructor for using a world asynchronously in FAWE. Do not use!
|
||||||
* @param autoQueue
|
|
||||||
* @deprecated use {@link #wrap(World)} instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public AsyncWorld(World parent, boolean autoQueue) {
|
public AsyncWorld(World parent, boolean autoQueue) {
|
||||||
@ -107,9 +107,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent
|
* An internal constructor for using a world asynchronously in FAWE. Do not use!
|
||||||
* @param extent
|
|
||||||
* @deprecated use {@link #wrap(World)} instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public AsyncWorld(World parent, Extent extent) {
|
public AsyncWorld(World parent, Extent extent) {
|
||||||
@ -120,9 +118,6 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a world for async usage.
|
* Wrap a world for async usage.
|
||||||
*
|
|
||||||
* @param world
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static AsyncWorld wrap(World world) {
|
public static AsyncWorld wrap(World world) {
|
||||||
if (world instanceof AsyncWorld) {
|
if (world instanceof AsyncWorld) {
|
||||||
@ -141,13 +136,11 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a world async (untested)
|
* Create a world async. This is not tested and may be removed in the future due to
|
||||||
* - Only optimized for 1.10
|
* synchronization problems.
|
||||||
*
|
|
||||||
* @param creator
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public synchronized static AsyncWorld create(final WorldCreator creator) {
|
@Beta
|
||||||
|
public static synchronized AsyncWorld create(final WorldCreator creator) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
@Nullable World world = adapter.createWorld(creator);
|
@Nullable World world = adapter.createWorld(creator);
|
||||||
return wrap(world);
|
return wrap(world);
|
||||||
@ -164,7 +157,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull WorldBorder getWorldBorder() {
|
@NotNull
|
||||||
|
public WorldBorder getWorldBorder() {
|
||||||
return TaskManager.IMP.sync(() -> parent.getWorldBorder());
|
return TaskManager.IMP.sync(() -> parent.getWorldBorder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,12 +232,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncBlock getBlockAt(final int x, final int y, final int z) {
|
@NotNull
|
||||||
|
public AsyncBlock getBlockAt(final int x, final int y, final int z) {
|
||||||
return new AsyncBlock(this, x, y, z);
|
return new AsyncBlock(this, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncBlock getBlockAt(Location loc) {
|
@NotNull
|
||||||
|
public AsyncBlock getBlockAt(Location loc) {
|
||||||
return getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
return getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,13 +260,15 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncBlock getHighestBlockAt(int x, int z) {
|
@NotNull
|
||||||
|
public AsyncBlock getHighestBlockAt(int x, int z) {
|
||||||
int y = getHighestBlockYAt(x, z);
|
int y = getHighestBlockYAt(x, z);
|
||||||
return getBlockAt(x, y, z);
|
return getBlockAt(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncBlock getHighestBlockAt(Location loc) {
|
@NotNull
|
||||||
|
public AsyncBlock getHighestBlockAt(Location loc) {
|
||||||
return getHighestBlockAt(loc.getBlockX(), loc.getBlockZ());
|
return getHighestBlockAt(loc.getBlockX(), loc.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,28 +283,33 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Block getHighestBlockAt(int i, int i1, @NotNull HeightMap heightMap) {
|
@NotNull
|
||||||
|
public Block getHighestBlockAt(int i, int i1, @NotNull HeightMap heightMap) {
|
||||||
return parent.getHighestBlockAt(i, i1, heightMap);
|
return parent.getHighestBlockAt(i, i1, heightMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Block getHighestBlockAt(@NotNull Location location,
|
@NotNull
|
||||||
|
public Block getHighestBlockAt(@NotNull Location location,
|
||||||
@NotNull HeightMap heightMap) {
|
@NotNull HeightMap heightMap) {
|
||||||
return parent.getHighestBlockAt(location, heightMap);
|
return parent.getHighestBlockAt(location, heightMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncChunk getChunkAt(int x, int z) {
|
@NotNull
|
||||||
|
public AsyncChunk getChunkAt(int x, int z) {
|
||||||
return new AsyncChunk(this, x, z);
|
return new AsyncChunk(this, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncChunk getChunkAt(Location location) {
|
@NotNull
|
||||||
|
public AsyncChunk getChunkAt(Location location) {
|
||||||
return getChunkAt(location.getBlockX(), location.getBlockZ());
|
return getChunkAt(location.getBlockX(), location.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull AsyncChunk getChunkAt(Block block) {
|
@NotNull
|
||||||
|
public AsyncChunk getChunkAt(Block block) {
|
||||||
return getChunkAt(block.getX(), block.getZ());
|
return getChunkAt(block.getX(), block.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +323,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
return chunk.isLoaded();
|
return chunk.isLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Chunk[] getLoadedChunks() {
|
public Chunk[] getLoadedChunks() {
|
||||||
return parent.getLoadedChunks();
|
return parent.getLoadedChunks();
|
||||||
@ -357,6 +361,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public boolean isChunkInUse(int x, int z) {
|
public boolean isChunkInUse(int x, int z) {
|
||||||
return parent.isChunkInUse(x, z);
|
return parent.isChunkInUse(x, z);
|
||||||
}
|
}
|
||||||
@ -411,6 +416,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public boolean regenerateChunk(final int x, final int z) {
|
public boolean regenerateChunk(final int x, final int z) {
|
||||||
return TaskManager.IMP.sync(() -> parent.regenerateChunk(x, z));
|
return TaskManager.IMP.sync(() -> parent.regenerateChunk(x, z));
|
||||||
}
|
}
|
||||||
@ -422,104 +428,148 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Item dropItem(final @NotNull Location location, final @NotNull ItemStack item) {
|
@NotNull
|
||||||
|
public Item dropItem(
|
||||||
|
@NotNull
|
||||||
|
final Location location, @NotNull
|
||||||
|
final ItemStack item) {
|
||||||
return TaskManager.IMP.sync(() -> parent.dropItem(location, item));
|
return TaskManager.IMP.sync(() -> parent.dropItem(location, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Item dropItemNaturally(final @NotNull Location location,
|
@NotNull
|
||||||
final @NotNull ItemStack item) {
|
public Item dropItemNaturally(
|
||||||
|
@NotNull
|
||||||
|
final Location location,
|
||||||
|
@NotNull
|
||||||
|
final ItemStack item) {
|
||||||
return TaskManager.IMP.sync(() -> parent.dropItemNaturally(location, item));
|
return TaskManager.IMP.sync(() -> parent.dropItemNaturally(location, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Arrow spawnArrow(final @NotNull Location location,
|
@NotNull
|
||||||
final @NotNull Vector direction, final float speed, final float spread) {
|
public Arrow spawnArrow(
|
||||||
|
@NotNull
|
||||||
|
final Location location,
|
||||||
|
@NotNull
|
||||||
|
final Vector direction, final float speed, final float spread) {
|
||||||
return TaskManager.IMP.sync(() -> parent.spawnArrow(location, direction, speed, spread));
|
return TaskManager.IMP.sync(() -> parent.spawnArrow(location, direction, speed, spread));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends AbstractArrow> @NotNull T spawnArrow(@NotNull Location location,
|
public <T extends AbstractArrow> T spawnArrow(@NotNull Location location,
|
||||||
@NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
|
@NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
|
||||||
return parent.spawnArrow(location, direction, speed, spread, clazz);
|
return parent.spawnArrow(location, direction, speed, spread, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(final @NotNull Location location, final @NotNull TreeType type) {
|
public boolean generateTree(
|
||||||
|
@NotNull
|
||||||
|
final Location location, @NotNull
|
||||||
|
final TreeType type) {
|
||||||
return TaskManager.IMP.sync(() -> parent.generateTree(location, type));
|
return TaskManager.IMP.sync(() -> parent.generateTree(location, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(final @NotNull Location loc, final @NotNull TreeType type,
|
public boolean generateTree(
|
||||||
final @NotNull BlockChangeDelegate delegate) {
|
@NotNull
|
||||||
|
final Location loc, @NotNull
|
||||||
|
final TreeType type,
|
||||||
|
@NotNull
|
||||||
|
final BlockChangeDelegate delegate) {
|
||||||
return TaskManager.IMP.sync(() -> parent.generateTree(loc, type, delegate));
|
return TaskManager.IMP.sync(() -> parent.generateTree(loc, type, delegate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Entity spawnEntity(@NotNull Location loc, EntityType type) {
|
@NotNull
|
||||||
|
public Entity spawnEntity(@NotNull Location loc, EntityType type) {
|
||||||
return spawn(loc, type.getEntityClass());
|
return spawn(loc, type.getEntityClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LightningStrike strikeLightning(final @NotNull Location loc) {
|
@NotNull
|
||||||
|
public LightningStrike strikeLightning(
|
||||||
|
@NotNull
|
||||||
|
final Location loc) {
|
||||||
return TaskManager.IMP.sync(() -> parent.strikeLightning(loc));
|
return TaskManager.IMP.sync(() -> parent.strikeLightning(loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LightningStrike strikeLightningEffect(final @NotNull Location loc) {
|
@NotNull
|
||||||
|
public LightningStrike strikeLightningEffect(
|
||||||
|
@NotNull
|
||||||
|
final Location loc) {
|
||||||
return TaskManager.IMP.sync(() -> parent.strikeLightningEffect(loc));
|
return TaskManager.IMP.sync(() -> parent.strikeLightningEffect(loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List getEntities() {
|
@NotNull
|
||||||
|
public List getEntities() {
|
||||||
return TaskManager.IMP.sync(() -> parent.getEntities());
|
return TaskManager.IMP.sync(() -> parent.getEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<LivingEntity> getLivingEntities() {
|
@NotNull
|
||||||
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return TaskManager.IMP.sync(() -> parent.getLivingEntities());
|
return TaskManager.IMP.sync(() -> parent.getLivingEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public <T extends Entity> @NotNull Collection<T> getEntitiesByClass(final Class<T>... classes) {
|
public <T extends Entity> Collection<T> getEntitiesByClass(
|
||||||
|
@NotNull
|
||||||
|
final Class<T>... classes) {
|
||||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(classes));
|
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(classes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends Entity> @NotNull Collection<T> getEntitiesByClass(
|
public <T extends Entity> Collection<T> getEntitiesByClass(
|
||||||
final @NotNull Class<T> cls) {
|
@NotNull
|
||||||
|
final Class<T> cls) {
|
||||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
|
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Entity> getEntitiesByClasses(final Class<?>... classes) {
|
@NotNull
|
||||||
|
public Collection<Entity> getEntitiesByClasses(
|
||||||
|
@NotNull
|
||||||
|
final Class<?>... classes) {
|
||||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClasses(classes));
|
return TaskManager.IMP.sync(() -> parent.getEntitiesByClasses(classes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<Player> getPlayers() {
|
@NotNull
|
||||||
|
public List<Player> getPlayers() {
|
||||||
return TaskManager.IMP.sync(() -> parent.getPlayers());
|
return TaskManager.IMP.sync(() -> parent.getPlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Entity> getNearbyEntities(final @NotNull Location location,
|
@NotNull
|
||||||
|
public Collection<Entity> getNearbyEntities(
|
||||||
|
@NotNull
|
||||||
|
final Location location,
|
||||||
final double x, final double y, final double z) {
|
final double x, final double y, final double z) {
|
||||||
return TaskManager.IMP.sync(() -> parent.getNearbyEntities(location, x, y, z));
|
return TaskManager.IMP.sync(() -> parent.getNearbyEntities(location, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getName() {
|
@NotNull
|
||||||
|
public String getName() {
|
||||||
return parent.getName();
|
return parent.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull UUID getUID() {
|
@NotNull
|
||||||
|
public UUID getUID() {
|
||||||
return parent.getUID();
|
return parent.getUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Location getSpawnLocation() {
|
@NotNull
|
||||||
|
public Location getSpawnLocation() {
|
||||||
return parent.getSpawnLocation();
|
return parent.getSpawnLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +584,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull MoonPhase getMoonPhase() {
|
@NotNull
|
||||||
|
public MoonPhase getMoonPhase() {
|
||||||
return parent.getMoonPhase();
|
return parent.getMoonPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,44 +720,51 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<BlockPopulator> getPopulators() {
|
@NotNull
|
||||||
|
public List<BlockPopulator> getPopulators() {
|
||||||
return parent.getPopulators();
|
return parent.getPopulators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends Entity> @NotNull T spawn(final @NotNull Location location,
|
public <T extends Entity> T spawn(@NotNull final Location location, @NotNull final Class<T> clazz) throws IllegalArgumentException {
|
||||||
final @NotNull Class<T> clazz) throws IllegalArgumentException {
|
|
||||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
|
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||||
Consumer<T> function) throws IllegalArgumentException {
|
Consumer<T> function) throws IllegalArgumentException {
|
||||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
|
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||||
@Nullable Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason)
|
@Nullable Consumer<T> function, @NotNull
|
||||||
|
CreatureSpawnEvent.SpawnReason reason)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
return null;
|
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
@NotNull
|
||||||
|
public FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||||
@NotNull MaterialData data) throws IllegalArgumentException {
|
@NotNull MaterialData data) throws IllegalArgumentException {
|
||||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, data));
|
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
@NotNull
|
||||||
|
public FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||||
@NotNull Material material, byte data) throws IllegalArgumentException {
|
@NotNull Material material, byte data) throws IllegalArgumentException {
|
||||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data));
|
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
@NotNull
|
||||||
|
public FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||||
@NotNull BlockData blockData) throws IllegalArgumentException {
|
@NotNull BlockData blockData) throws IllegalArgumentException {
|
||||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
|
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
|
||||||
}
|
}
|
||||||
@ -717,7 +775,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playEffect(final @NotNull Location location, final @NotNull Effect effect,
|
public void playEffect(
|
||||||
|
@NotNull
|
||||||
|
final Location location, @NotNull
|
||||||
|
final Effect effect,
|
||||||
final int data, final int radius) {
|
final int data, final int radius) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
@ -733,7 +794,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> void playEffect(final @NotNull Location location, final @NotNull Effect effect,
|
public <T> void playEffect(
|
||||||
|
@NotNull
|
||||||
|
final Location location, @NotNull
|
||||||
|
final Effect effect,
|
||||||
final T data, final int radius) {
|
final T data, final int radius) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
@ -744,7 +808,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z,
|
@NotNull
|
||||||
|
public ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z,
|
||||||
final boolean includeBiome, final boolean includeBiomeTempRain) {
|
final boolean includeBiome, final boolean includeBiomeTempRain) {
|
||||||
return TaskManager.IMP
|
return TaskManager.IMP
|
||||||
.sync(() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain));
|
.sync(() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain));
|
||||||
@ -766,12 +831,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Biome getBiome(int x, int z) {
|
@NotNull
|
||||||
|
public Biome getBiome(int x, int z) {
|
||||||
return adapter.adapt(getExtent().getBiomeType(x, 0, z));
|
return adapter.adapt(getExtent().getBiomeType(x, 0, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Biome getBiome(int x, int y, int z) {
|
@NotNull
|
||||||
|
public Biome getBiome(int x, int y, int z) {
|
||||||
return adapter.adapt(getExtent().getBiomeType(x, y, z));
|
return adapter.adapt(getExtent().getBiomeType(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,6 +855,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public double getTemperature(int x, int z) {
|
public double getTemperature(int x, int z) {
|
||||||
return parent.getTemperature(x, z);
|
return parent.getTemperature(x, z);
|
||||||
}
|
}
|
||||||
@ -798,6 +866,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public double getHumidity(int x, int z) {
|
public double getHumidity(int x, int z) {
|
||||||
return parent.getHumidity(x, z);
|
return parent.getHumidity(x, z);
|
||||||
}
|
}
|
||||||
@ -848,16 +917,19 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Difficulty getDifficulty() {
|
@NotNull
|
||||||
|
public Difficulty getDifficulty() {
|
||||||
return parent.getDifficulty();
|
return parent.getDifficulty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull File getWorldFolder() {
|
@NotNull
|
||||||
|
public File getWorldFolder() {
|
||||||
return parent.getWorldFolder();
|
return parent.getWorldFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public WorldType getWorldType() {
|
public WorldType getWorldType() {
|
||||||
return parent.getWorldType();
|
return parent.getWorldType();
|
||||||
}
|
}
|
||||||
@ -948,7 +1020,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playSound(final @NotNull Location location, final @NotNull Sound sound,
|
public void playSound(
|
||||||
|
@NotNull
|
||||||
|
final Location location, @NotNull
|
||||||
|
final Sound sound,
|
||||||
final float volume, final float pitch) {
|
final float volume, final float pitch) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
@ -959,7 +1034,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playSound(final @NotNull Location location, final @NotNull String sound,
|
public void playSound(
|
||||||
|
@NotNull
|
||||||
|
final Location location, @NotNull
|
||||||
|
final String sound,
|
||||||
final float volume, final float pitch) {
|
final float volume, final float pitch) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
@ -991,17 +1069,20 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String[] getGameRules() {
|
public String[] getGameRules() {
|
||||||
return parent.getGameRules();
|
return parent.getGameRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public String getGameRuleValue(String rule) {
|
public String getGameRuleValue(String rule) {
|
||||||
return parent.getGameRuleValue(rule);
|
return parent.getGameRuleValue(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) {
|
public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) {
|
||||||
return parent.setGameRuleValue(rule, value);
|
return parent.setGameRuleValue(rule, value);
|
||||||
}
|
}
|
||||||
@ -1012,6 +1093,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public <T> T getGameRuleValue(@NotNull GameRule<T> gameRule) {
|
public <T> T getGameRuleValue(@NotNull GameRule<T> gameRule) {
|
||||||
return parent.getGameRuleValue(gameRule);
|
return parent.getGameRuleValue(gameRule);
|
||||||
}
|
}
|
||||||
@ -1027,22 +1109,28 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Spigot spigot() {
|
@NotNull
|
||||||
|
public Spigot spigot() {
|
||||||
return parent.spigot();
|
return parent.spigot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Raid locateNearestRaid(@NotNull Location location, int i) {
|
@Nullable
|
||||||
|
public Raid locateNearestRaid(@NotNull Location location, int i) {
|
||||||
return parent.locateNearestRaid(location, i);
|
return parent.locateNearestRaid(location, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<Raid> getRaids() {
|
@NotNull
|
||||||
|
public List<Raid> getRaids() {
|
||||||
return parent.getRaids();
|
return parent.getRaids();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMetadata(final @NotNull String key, final @NotNull MetadataValue meta) {
|
public void setMetadata(
|
||||||
|
@NotNull
|
||||||
|
final String key, @NotNull
|
||||||
|
final MetadataValue meta) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
@ -1052,7 +1140,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<MetadataValue> getMetadata(@NotNull String key) {
|
@NotNull
|
||||||
|
public List<MetadataValue> getMetadata(@NotNull String key) {
|
||||||
return parent.getMetadata(key);
|
return parent.getMetadata(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1062,7 +1151,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeMetadata(final @NotNull String key, final @NotNull Plugin plugin) {
|
public void removeMetadata(
|
||||||
|
@NotNull
|
||||||
|
final String key, @NotNull
|
||||||
|
final Plugin plugin) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
@ -1072,12 +1164,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, byte[] message) {
|
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull
|
||||||
|
byte[] message) {
|
||||||
parent.sendPluginMessage(source, channel, message);
|
parent.sendPluginMessage(source, channel, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<String> getListeningPluginChannels() {
|
@NotNull
|
||||||
|
public Set<String> getListeningPluginChannels() {
|
||||||
return parent.getListeningPluginChannels();
|
return parent.getListeningPluginChannels();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,18 +1180,21 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0) {
|
@NotNull
|
||||||
|
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0) {
|
||||||
return parent.getNearbyEntities(arg0);
|
return parent.getNearbyEntities(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0,
|
@NotNull
|
||||||
|
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0,
|
||||||
Predicate<Entity> arg1) {
|
Predicate<Entity> arg1) {
|
||||||
return parent.getNearbyEntities(arg0, arg1);
|
return parent.getNearbyEntities(arg0, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1,
|
@NotNull
|
||||||
|
public Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1,
|
||||||
double arg2, double arg3, Predicate<Entity> arg4) {
|
double arg2, double arg3, Predicate<Entity> arg4) {
|
||||||
return parent.getNearbyEntities(arg0, arg1, arg2, arg3, arg4);
|
return parent.getNearbyEntities(arg0, arg1, arg2, arg3, arg4);
|
||||||
}
|
}
|
||||||
@ -1196,7 +1293,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Chunk> getForceLoadedChunks() {
|
@NotNull
|
||||||
|
public Collection<Chunk> getForceLoadedChunks() {
|
||||||
return parent.getForceLoadedChunks();
|
return parent.getForceLoadedChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1216,18 +1314,22 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Plugin> getPluginChunkTickets(int x, int z) {
|
@NotNull
|
||||||
|
public Collection<Plugin> getPluginChunkTickets(int x, int z) {
|
||||||
return getBukkitWorld().getPluginChunkTickets(x, z);
|
return getBukkitWorld().getPluginChunkTickets(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
|
@NotNull
|
||||||
|
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
|
||||||
return getBukkitWorld().getPluginChunkTickets();
|
return getBukkitWorld().getPluginChunkTickets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public int getHighestBlockYAt(int x, int z,
|
public int getHighestBlockYAt(int x, int z,
|
||||||
com.destroystokyo.paper.@NotNull HeightmapType heightmap)
|
@NotNull
|
||||||
|
com.destroystokyo.paper.HeightmapType heightmap)
|
||||||
throws UnsupportedOperationException {
|
throws UnsupportedOperationException {
|
||||||
return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap));
|
return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap));
|
||||||
}
|
}
|
||||||
@ -1258,14 +1360,16 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull CompletableFuture<Chunk> getChunkAtAsync(int arg0, int arg1, boolean arg2) {
|
@NotNull
|
||||||
return parent.getChunkAtAsync(arg0, arg1, arg2);
|
public CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen) {
|
||||||
|
return parent.getChunkAtAsync(x, z, gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen,
|
@NotNull
|
||||||
|
public CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen,
|
||||||
boolean urgent) {
|
boolean urgent) {
|
||||||
return null;
|
return parent.getChunkAtAsync(x, z, gen, urgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1274,16 +1378,19 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void getChunkAtAsync(int x, int z, @NotNull ChunkLoadCallback cb) {
|
public void getChunkAtAsync(int x, int z, @NotNull ChunkLoadCallback cb) {
|
||||||
parent.getChunkAtAsync(x, z, cb);
|
parent.getChunkAtAsync(x, z, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void getChunkAtAsync(@NotNull Location location, @NotNull ChunkLoadCallback cb) {
|
public void getChunkAtAsync(@NotNull Location location, @NotNull ChunkLoadCallback cb) {
|
||||||
parent.getChunkAtAsync(location, cb);
|
parent.getChunkAtAsync(location, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void getChunkAtAsync(@NotNull Block block, @NotNull ChunkLoadCallback cb) {
|
public void getChunkAtAsync(@NotNull Block block, @NotNull ChunkLoadCallback cb) {
|
||||||
parent.getChunkAtAsync(block, cb);
|
parent.getChunkAtAsync(block, cb);
|
||||||
}
|
}
|
||||||
@ -1343,19 +1450,24 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightmapType heightmap)
|
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightmapType heightmap)
|
||||||
throws UnsupportedOperationException {
|
throws UnsupportedOperationException {
|
||||||
return parent.getHighestBlockYAt(location, heightmap);
|
return parent.getHighestBlockYAt(location, heightmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Block getHighestBlockAt(int x, int z, @NotNull HeightmapType heightmap)
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
|
public Block getHighestBlockAt(int x, int z, @NotNull HeightmapType heightmap)
|
||||||
throws UnsupportedOperationException {
|
throws UnsupportedOperationException {
|
||||||
return parent.getHighestBlockAt(x, z, heightmap);
|
return parent.getHighestBlockAt(x, z, heightmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Block getHighestBlockAt(@NotNull Location location,
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
|
public Block getHighestBlockAt(@NotNull Location location,
|
||||||
@NotNull HeightmapType heightmap) throws UnsupportedOperationException {
|
@NotNull HeightmapType heightmap) throws UnsupportedOperationException {
|
||||||
return parent.getHighestBlockAt(location, heightmap);
|
return parent.getHighestBlockAt(location, heightmap);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,12 @@ package com.boydti.fawe.bukkit.wrapper.state;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.persistence.PersistentDataAdapterContext;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -11,13 +17,6 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.persistence.PersistentDataAdapterContext;
|
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class AsyncDataContainer implements PersistentDataContainer {
|
public final class AsyncDataContainer implements PersistentDataContainer {
|
||||||
private final CompoundTag root;
|
private final CompoundTag root;
|
||||||
|
|
||||||
@ -38,7 +37,9 @@ public final class AsyncDataContainer implements PersistentDataContainer {
|
|||||||
CompoundTag tag = root();
|
CompoundTag tag = root();
|
||||||
Map<String, Tag> raw;
|
Map<String, Tag> raw;
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
if (!create) return Collections.emptyMap();
|
if (!create) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
Map<String, Tag> map = root.getValue();
|
Map<String, Tag> map = root.getValue();
|
||||||
map.put("PublicBukkitValues", new CompoundTag(raw = new HashMap<>()));
|
map.put("PublicBukkitValues", new CompoundTag(raw = new HashMap<>()));
|
||||||
} else {
|
} else {
|
||||||
@ -58,7 +59,9 @@ public final class AsyncDataContainer implements PersistentDataContainer {
|
|||||||
Validate.notNull(key, "The provided key for the custom value was null");
|
Validate.notNull(key, "The provided key for the custom value was null");
|
||||||
Validate.notNull(type, "The provided type for the custom value was null");
|
Validate.notNull(type, "The provided type for the custom value was null");
|
||||||
Tag value = get(false).get(key.toString());
|
Tag value = get(false).get(key.toString());
|
||||||
if (value == null) return type == null;
|
if (value == null) {
|
||||||
|
return type == null;
|
||||||
|
}
|
||||||
return type.getPrimitiveType() == value.getValue().getClass();
|
return type.getPrimitiveType() == value.getValue().getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,15 +8,15 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
|
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
|
||||||
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
|
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class AsyncSign extends AsyncBlockState implements Sign {
|
public class AsyncSign extends AsyncBlockState implements Sign {
|
||||||
public AsyncSign(AsyncBlock block, BaseBlock state) {
|
public AsyncSign(AsyncBlock block, BaseBlock state) {
|
||||||
@ -38,12 +38,16 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String fromJson(String jsonInput) {
|
private String fromJson(String jsonInput) {
|
||||||
if (jsonInput == null || jsonInput.isEmpty()) return "";
|
if (jsonInput == null || jsonInput.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return GsonComponentSerializer.INSTANCE.deserialize(jsonInput).toString();
|
return GsonComponentSerializer.INSTANCE.deserialize(jsonInput).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toJson(String oldInput) {
|
private String toJson(String oldInput) {
|
||||||
if (oldInput == null || oldInput.isEmpty()) return "";
|
if (oldInput == null || oldInput.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return LegacyComponentSerializer.INSTANCE.serialize(TextComponent.of(oldInput));
|
return LegacyComponentSerializer.INSTANCE.serialize(TextComponent.of(oldInput));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,16 +77,20 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull PersistentDataContainer getPersistentDataContainer() {
|
@NotNull
|
||||||
|
public PersistentDataContainer getPersistentDataContainer() {
|
||||||
return new AsyncDataContainer(getNbtData());
|
return new AsyncDataContainer(getNbtData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable DyeColor getColor() {
|
@Nullable
|
||||||
|
public DyeColor getColor() {
|
||||||
CompoundTag nbt = getNbtData();
|
CompoundTag nbt = getNbtData();
|
||||||
if (nbt != null) {
|
if (nbt != null) {
|
||||||
String color = nbt.getString("Color").toUpperCase();
|
String color = nbt.getString("Color").toUpperCase(Locale.ROOT);
|
||||||
if (!color.isEmpty()) return DyeColor.valueOf(color);
|
if (!color.isEmpty()) {
|
||||||
|
return DyeColor.valueOf(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return DyeColor.BLACK;
|
return DyeColor.BLACK;
|
||||||
}
|
}
|
||||||
@ -92,7 +100,7 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
|||||||
CompoundTag nbt = getNbtData();
|
CompoundTag nbt = getNbtData();
|
||||||
if (nbt != null) {
|
if (nbt != null) {
|
||||||
Map<String, Tag> map = nbt.getValue();
|
Map<String, Tag> map = nbt.getValue();
|
||||||
map.put("Color", new StringTag(color.name().toLowerCase()));
|
map.put("Color", new StringTag(color.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
@ -42,9 +40,6 @@ import com.sk89q.worldedit.world.entity.EntityType;
|
|||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -55,6 +50,12 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapts between Bukkit and WorldEdit equivalent objects.
|
* Adapts between Bukkit and WorldEdit equivalent objects.
|
||||||
*/
|
*/
|
||||||
@ -83,7 +84,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
* Checks equality between a WorldEdit BlockType and a Bukkit Material.
|
||||||
*
|
*
|
||||||
* @param blockType The WorldEdit BlockType
|
* @param blockType The WorldEdit BlockType
|
||||||
* @param type The Bukkit Material
|
* @param type The Bukkit Material
|
||||||
@ -117,7 +118,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit Actor from a Bukkit CommandSender
|
* Create a WorldEdit Actor from a Bukkit CommandSender.
|
||||||
*
|
*
|
||||||
* @param sender The Bukkit CommandSender
|
* @param sender The Bukkit CommandSender
|
||||||
* @return The WorldEdit Actor
|
* @return The WorldEdit Actor
|
||||||
@ -284,7 +285,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit Material form a WorldEdit ItemType
|
* Create a Bukkit Material form a WorldEdit ItemType.
|
||||||
*
|
*
|
||||||
* @param itemType The WorldEdit ItemType
|
* @param itemType The WorldEdit ItemType
|
||||||
* @return The Bukkit Material
|
* @return The Bukkit Material
|
||||||
@ -294,7 +295,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit Material form a WorldEdit BlockType
|
* Create a Bukkit Material form a WorldEdit BlockType.
|
||||||
*
|
*
|
||||||
* @param blockType The WorldEdit BlockType
|
* @param blockType The WorldEdit BlockType
|
||||||
* @return The Bukkit Material
|
* @return The Bukkit Material
|
||||||
@ -345,7 +346,7 @@ public enum BukkitAdapter {
|
|||||||
private static EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
|
private static EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Material to a BlockType
|
* Converts a Material to a BlockType.
|
||||||
*
|
*
|
||||||
* @param material The material
|
* @param material The material
|
||||||
* @return The blocktype
|
* @return The blocktype
|
||||||
@ -356,7 +357,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Material to a ItemType
|
* Converts a Material to a ItemType.
|
||||||
*
|
*
|
||||||
* @param material The material
|
* @param material The material
|
||||||
* @return The itemtype
|
* @return The itemtype
|
||||||
@ -370,7 +371,7 @@ public enum BukkitAdapter {
|
|||||||
private static Map<String, BlockState> blockStateStringCache = new HashMap<>();
|
private static Map<String, BlockState> blockStateStringCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BlockState from a Bukkit BlockData
|
* Create a WorldEdit BlockState from a Bukkit BlockData.
|
||||||
*
|
*
|
||||||
* @param blockData The Bukkit BlockData
|
* @param blockData The Bukkit BlockData
|
||||||
* @return The WorldEdit BlockState
|
* @return The WorldEdit BlockState
|
||||||
@ -382,7 +383,7 @@ public enum BukkitAdapter {
|
|||||||
private static Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
|
private static Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder.
|
||||||
*
|
*
|
||||||
* @param block The WorldEdit BlockStateHolder
|
* @param block The WorldEdit BlockStateHolder
|
||||||
* @return The Bukkit BlockData
|
* @return The Bukkit BlockData
|
||||||
@ -392,7 +393,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BlockState from a Bukkit ItemStack
|
* Create a WorldEdit BlockState from a Bukkit ItemStack.
|
||||||
*
|
*
|
||||||
* @param itemStack The Bukkit ItemStack
|
* @param itemStack The Bukkit ItemStack
|
||||||
* @return The WorldEdit BlockState
|
* @return The WorldEdit BlockState
|
||||||
@ -402,7 +403,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack
|
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack.
|
||||||
*
|
*
|
||||||
* @param itemStack The Bukkit ItemStack
|
* @param itemStack The Bukkit ItemStack
|
||||||
* @return The WorldEdit BaseItemStack
|
* @return The WorldEdit BaseItemStack
|
||||||
@ -412,7 +413,7 @@ public enum BukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit ItemStack from a WorldEdit BaseItemStack
|
* Create a Bukkit ItemStack from a WorldEdit BaseItemStack.
|
||||||
*
|
*
|
||||||
* @param item The WorldEdit BaseItemStack
|
* @param item The WorldEdit BaseItemStack
|
||||||
* @return The Bukkit ItemStack
|
* @return The Bukkit ItemStack
|
||||||
|
@ -94,6 +94,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
|||||||
print(TextComponent.of(part, TextColor.RED));
|
print(TextComponent.of(part, TextColor.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(Component component) {
|
public void print(Component component) {
|
||||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||||
|
@ -23,18 +23,17 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
|||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||||
|
|
||||||
@ -46,7 +45,9 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
|||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
BlockMaterial result = adapter.getMaterial(blockType);
|
BlockMaterial result = adapter.getMaterial(blockType);
|
||||||
if (result != null) return result;
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Material mat = BukkitAdapter.adapt(blockType);
|
Material mat = BukkitAdapter.adapt(blockType);
|
||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
@ -69,7 +70,9 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
|||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
BlockMaterial result = adapter.getMaterial(state);
|
BlockMaterial result = adapter.getMaterial(state);
|
||||||
if (result != null) return result;
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.getMaterial(state);
|
return super.getMaterial(state);
|
||||||
}
|
}
|
||||||
@ -81,6 +84,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
|||||||
}
|
}
|
||||||
return OptionalInt.empty();
|
return OptionalInt.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
|
@ -19,13 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
|
|
||||||
|
|
||||||
import com.sk89q.bukkit.util.CommandInspector;
|
import com.sk89q.bukkit.util.CommandInspector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import java.util.Optional;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
@ -33,10 +29,13 @@ import org.enginehub.piston.inject.InjectedValueStore;
|
|||||||
import org.enginehub.piston.inject.Key;
|
import org.enginehub.piston.inject.Key;
|
||||||
import org.enginehub.piston.inject.MapBackedValueStore;
|
import org.enginehub.piston.inject.MapBackedValueStore;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
|
||||||
|
|
||||||
class BukkitCommandInspector implements CommandInspector {
|
class BukkitCommandInspector implements CommandInspector {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(BukkitCommandInspector.class);
|
private static final Logger logger = LoggerFactory.getLogger(BukkitCommandInspector.class);
|
||||||
|
@ -19,25 +19,24 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
|
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
|
||||||
import com.sk89q.worldedit.session.SessionKey;
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||||
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class BukkitCommandSender extends AbstractNonPlayerActor {
|
public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,8 +44,8 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
|||||||
*/
|
*/
|
||||||
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
|
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
|
||||||
|
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
private WorldEditPlugin plugin;
|
private final WorldEditPlugin plugin;
|
||||||
|
|
||||||
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
||||||
checkNotNull(plugin);
|
checkNotNull(plugin);
|
||||||
@ -68,6 +67,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void printRaw(String msg) {
|
public void printRaw(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
sender.sendMessage(part);
|
sender.sendMessage(part);
|
||||||
@ -75,25 +75,29 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void print(String msg) {
|
public void print(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
sender.sendMessage("\u00A7d" + part);
|
sender.sendMessage("§d" + part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void printDebug(String msg) {
|
public void printDebug(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
sender.sendMessage("\u00A77" + part);
|
sender.sendMessage("§7" + part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public void printError(String msg) {
|
public void printError(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
sender.sendMessage("\u00A7c" + part);
|
sender.sendMessage("§c" + part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(Component component) {
|
public void print(Component component) {
|
||||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||||
import org.bukkit.entity.Ambient;
|
import org.bukkit.entity.Ambient;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
@ -44,6 +42,8 @@ import org.bukkit.entity.Tameable;
|
|||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
class BukkitEntityProperties implements EntityProperties {
|
class BukkitEntityProperties implements EntityProperties {
|
||||||
|
|
||||||
private final Entity entity;
|
private final Entity entity;
|
||||||
|
@ -14,7 +14,9 @@ public class BukkitEntityRegistry implements EntityRegistry {
|
|||||||
for (EntityType type : EntityType.values()) {
|
for (EntityType type : EntityType.values()) {
|
||||||
String name = type.getName();
|
String name = type.getName();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
if (name.indexOf(':') == -1) name = "minecraft:" + name;
|
if (name.indexOf(':') == -1) {
|
||||||
|
name = "minecraft:" + name;
|
||||||
|
}
|
||||||
types.add(name);
|
types.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,11 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.permissions.PermissionAttachment;
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BukkitPlayer extends AbstractPlayerActor {
|
public class BukkitPlayer extends AbstractPlayerActor {
|
||||||
@ -173,23 +172,24 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
@Override
|
@Override
|
||||||
public void print(String msg) {
|
public void print(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
player.sendMessage("\u00A7d" + part);
|
player.sendMessage("§d" + part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printDebug(String msg) {
|
public void printDebug(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
player.sendMessage("\u00A77" + part);
|
player.sendMessage("§7" + part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printError(String msg) {
|
public void printError(String msg) {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
player.sendMessage("\u00A7c" + part);
|
player.sendMessage("§c" + part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(Component component) {
|
public void print(Component component) {
|
||||||
component = Caption.color(TranslatableComponent.of("prefix", component), getLocale());
|
component = Caption.color(TranslatableComponent.of("prefix", component), getLocale());
|
||||||
|
@ -44,14 +44,14 @@ import org.enginehub.piston.inject.MapBackedValueStore;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all events thrown in relation to a Player
|
* Handles all events thrown in relation to a Player.
|
||||||
*/
|
*/
|
||||||
public class WorldEditListener implements Listener {
|
public class WorldEditListener implements Listener {
|
||||||
|
|
||||||
private WorldEditPlugin plugin;
|
private final WorldEditPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object;
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin
|
* @param plugin the plugin
|
||||||
*/
|
*/
|
||||||
@ -84,7 +84,7 @@ public class WorldEditListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player interacts
|
* Called when a player interacts.
|
||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
|
@ -42,10 +42,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
@ -55,6 +51,11 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for adapters of various Bukkit implementations.
|
* An interface for adapters of various Bukkit implementations.
|
||||||
*/
|
*/
|
||||||
@ -68,7 +69,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
int getDataVersion();
|
int getDataVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a data fixer, or null if not supported
|
* Get a data fixer, or null if not supported.
|
||||||
*
|
*
|
||||||
* @return the data fixer
|
* @return the data fixer
|
||||||
*/
|
*/
|
||||||
@ -76,6 +77,8 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
DataFixer getDataFixer();
|
DataFixer getDataFixer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Check if this adapter supports the watchdog.
|
||||||
|
*
|
||||||
* @return {@code true} if {@link #tickWatchdog()} is implemented
|
* @return {@code true} if {@link #tickWatchdog()} is implemented
|
||||||
*/
|
*/
|
||||||
default boolean supportsWatchdog() {
|
default boolean supportsWatchdog() {
|
||||||
@ -217,14 +220,13 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
default @Nullable World createWorld(WorldCreator creator) {
|
@Nullable
|
||||||
|
default World createWorld(WorldCreator creator) {
|
||||||
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a fake chunk packet to a player
|
* Send a fake chunk packet to a player.
|
||||||
* @param player
|
|
||||||
* @param packet
|
|
||||||
*/
|
*/
|
||||||
default void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) {
|
default void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) {
|
||||||
throw new UnsupportedOperationException("Cannot send fake chunks");
|
throw new UnsupportedOperationException("Cannot send fake chunks");
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter;
|
package com.sk89q.worldedit.bukkit.adapter;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -9,11 +7,14 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import java.util.List;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||||
private int[] itemTypes;
|
private int[] itemTypes;
|
||||||
private int[] blockTypes;
|
private int[] blockTypes;
|
||||||
@ -25,7 +26,9 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
|||||||
blockTypes = new int[materials.length];
|
blockTypes = new int[materials.length];
|
||||||
for (int i = 0; i < materials.length; i++) {
|
for (int i = 0; i < materials.length; i++) {
|
||||||
Material material = materials[i];
|
Material material = materials[i];
|
||||||
if (material.isLegacy()) continue;
|
if (material.isLegacy()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
NamespacedKey key = material.getKey();
|
NamespacedKey key = material.getKey();
|
||||||
String id = key.getNamespace() + ":" + key.getKey();
|
String id = key.getNamespace() + ":" + key.getKey();
|
||||||
if (material.isBlock()) {
|
if (material.isBlock()) {
|
||||||
@ -41,7 +44,7 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Material to a ItemType
|
* Converts a Material to a ItemType.
|
||||||
*
|
*
|
||||||
* @param material The material
|
* @param material The material
|
||||||
* @return The itemtype
|
* @return The itemtype
|
||||||
@ -51,7 +54,9 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
|||||||
try {
|
try {
|
||||||
return ItemTypes.get(itemTypes[material.ordinal()]);
|
return ItemTypes.get(itemTypes[material.ordinal()]);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
if (init()) return asItemType(material);
|
if (init()) {
|
||||||
|
return asItemType(material);
|
||||||
|
}
|
||||||
return ItemTypes.get(itemTypes[material.ordinal()]);
|
return ItemTypes.get(itemTypes[material.ordinal()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,13 +66,15 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
|||||||
try {
|
try {
|
||||||
return BlockTypesCache.values[blockTypes[material.ordinal()]];
|
return BlockTypesCache.values[blockTypes[material.ordinal()]];
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
if (init()) return asBlockType(material);
|
if (init()) {
|
||||||
|
return asBlockType(material);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BlockStateHolder from a Bukkit BlockData
|
* Create a WorldEdit BlockStateHolder from a Bukkit BlockData.
|
||||||
*
|
*
|
||||||
* @param blockData The Bukkit BlockData
|
* @param blockData The Bukkit BlockData
|
||||||
* @return The WorldEdit BlockState
|
* @return The WorldEdit BlockState
|
||||||
@ -79,11 +86,15 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
|||||||
Material material = blockData.getMaterial();
|
Material material = blockData.getMaterial();
|
||||||
BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]);
|
BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]);
|
||||||
List<? extends Property> propList = type.getProperties();
|
List<? extends Property> propList = type.getProperties();
|
||||||
if (propList.size() == 0) return type.getDefaultState();
|
if (propList.size() == 0) {
|
||||||
|
return type.getDefaultState();
|
||||||
|
}
|
||||||
String properties = blockData.getAsString();
|
String properties = blockData.getAsString();
|
||||||
return BlockState.get(type, properties, type.getDefaultState());
|
return BlockState.get(type, properties, type.getDefaultState());
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
if (init()) return adapt(blockData);
|
if (init()) {
|
||||||
|
return adapt(blockData);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,9 @@ public interface IBukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
default ItemStack adapt(BaseItemStack item) {
|
default ItemStack adapt(BaseItemStack item) {
|
||||||
checkNotNull(item);
|
checkNotNull(item);
|
||||||
if (item instanceof BukkitItemStack) return ((BukkitItemStack) item).getBukkitItemStack();
|
if (item instanceof BukkitItemStack) {
|
||||||
|
return ((BukkitItemStack) item).getBukkitItemStack();
|
||||||
|
}
|
||||||
return new ItemStack(adapt(item.getType()), item.getAmount());
|
return new ItemStack(adapt(item.getType()), item.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,9 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
|
|||||||
private BlockData[][] blockDataCache;
|
private BlockData[][] blockDataCache;
|
||||||
|
|
||||||
private boolean init() {
|
private boolean init() {
|
||||||
if (blockDataCache != null) return false;
|
if (blockDataCache != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.blockDataCache = new BlockData[BlockTypes.size()][];
|
this.blockDataCache = new BlockData[BlockTypes.size()][];
|
||||||
blockDataCache[0] = new BlockData[] {Material.AIR.createBlockData()};
|
blockDataCache[0] = new BlockData[] {Material.AIR.createBlockData()};
|
||||||
return true;
|
return true;
|
||||||
@ -42,7 +44,9 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
|
|||||||
}
|
}
|
||||||
return blockData;
|
return blockData;
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
if (init()) return adapt(block);
|
if (init()) {
|
||||||
|
return adapt(block);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,15 @@ import com.boydti.fawe.beta.IQueueChunk;
|
|||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||||
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
|
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
|
||||||
import com.boydti.fawe.bukkit.adapter.mc1_15_2.*;
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.BlockMaterial_1_15_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.BukkitAdapter_1_15_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.BukkitGetBlocks_1_15_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.FAWEWorldNativeAccess_1_15_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.MapChunkUtil_1_15_2;
|
||||||
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2;
|
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
@ -48,11 +53,39 @@ import com.sk89q.worldedit.registry.state.Property;
|
|||||||
import com.sk89q.worldedit.util.SideEffect;
|
import com.sk89q.worldedit.util.SideEffect;
|
||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.*;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
import net.minecraft.server.v1_15_R1.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_15_R1.Block;
|
||||||
|
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_15_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_15_R1.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.server.v1_15_R1.ChunkProviderServer;
|
||||||
|
import net.minecraft.server.v1_15_R1.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_15_R1.Entity;
|
||||||
|
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_15_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_15_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_15_R1.IRegistry;
|
||||||
|
import net.minecraft.server.v1_15_R1.ItemStack;
|
||||||
|
import net.minecraft.server.v1_15_R1.MinecraftKey;
|
||||||
|
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||||
|
import net.minecraft.server.v1_15_R1.NBTBase;
|
||||||
|
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_15_R1.NBTTagInt;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
|
||||||
|
import net.minecraft.server.v1_15_R1.PlayerChunk;
|
||||||
|
import net.minecraft.server.v1_15_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_15_R1.World;
|
||||||
|
import net.minecraft.server.v1_15_R1.WorldData;
|
||||||
|
import net.minecraft.server.v1_15_R1.WorldNBTStorage;
|
||||||
|
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
@ -67,7 +100,6 @@ import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
@ -79,9 +111,9 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
|
|
||||||
public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
|
public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
|
||||||
private final Spigot_v1_15_R2 parent;
|
private final Spigot_v1_15_R2 parent;
|
||||||
@ -101,7 +133,9 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean init() {
|
private synchronized boolean init() {
|
||||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) return false;
|
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
||||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||||
BlockState state = BlockTypesCache.states[i];
|
BlockState state = BlockTypesCache.states[i];
|
||||||
@ -202,9 +236,13 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (existing == blockData) return true;
|
if (existing == blockData) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
if (blockData.isAir()) return true;
|
if (blockData.isAir()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
sections[y4] = section = new ChunkSection(y4 << 4);
|
sections[y4] = section = new ChunkSection(y4 << 4);
|
||||||
}
|
}
|
||||||
nmsChunk.setType(blockPos, blockData, false);
|
nmsChunk.setType(blockPos, blockData, false);
|
||||||
@ -421,10 +459,12 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
|||||||
IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
|
IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
|
||||||
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15_2(freshWorld, x, z) {
|
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15_2(freshWorld, x, z) {
|
||||||
@Override
|
@Override
|
||||||
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
public Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||||
Chunk cached = nmsWorld.getChunkIfLoaded(X, Z);
|
Chunk cached = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
|
||||||
if (cached != null) return cached;
|
if (cached != null) {
|
||||||
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(X, Z));
|
return cached;
|
||||||
|
}
|
||||||
|
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(chunkX, chunkZ));
|
||||||
while (!future.isDone()) {
|
while (!future.isDone()) {
|
||||||
// this feels so dirty
|
// this feels so dirty
|
||||||
freshWorld.getChunkProvider().runTasks();
|
freshWorld.getChunkProvider().runTasks();
|
||||||
|
@ -88,7 +88,9 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean init() {
|
private synchronized boolean init() {
|
||||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) return false;
|
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
||||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||||
BlockState state = BlockTypesCache.states[i];
|
BlockState state = BlockTypesCache.states[i];
|
||||||
@ -189,9 +191,13 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (existing == blockData) return true;
|
if (existing == blockData) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
if (blockData.isAir()) return true;
|
if (blockData.isAir()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
sections[y4] = section = new ChunkSection(y4 << 4);
|
sections[y4] = section = new ChunkSection(y4 << 4);
|
||||||
}
|
}
|
||||||
nmsChunk.setType(blockPos, blockData, false);
|
nmsChunk.setType(blockPos, blockData, false);
|
||||||
|
@ -23,9 +23,14 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.*;
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BlockMaterial_1_16_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BukkitAdapter_1_16_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BukkitGetBlocks_1_16_2;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.FAWEWorldNativeAccess_1_16;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.MapChunkUtil_1_16_2;
|
||||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
|
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -42,14 +47,38 @@ import com.sk89q.worldedit.registry.state.Property;
|
|||||||
import com.sk89q.worldedit.util.SideEffect;
|
import com.sk89q.worldedit.util.SideEffect;
|
||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.*;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_16_R2.*;
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.Block;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_16_R2.Entity;
|
||||||
|
import net.minecraft.server.v1_16_R2.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_16_R2.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||||
|
import net.minecraft.server.v1_16_R2.ItemStack;
|
||||||
|
import net.minecraft.server.v1_16_R2.MinecraftKey;
|
||||||
|
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||||
|
import net.minecraft.server.v1_16_R2.NBTBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_16_R2.NBTTagInt;
|
||||||
|
import net.minecraft.server.v1_16_R2.PacketPlayOutMapChunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.PlayerChunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.TileEntity;
|
||||||
|
import net.minecraft.server.v1_16_R2.World;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
@ -60,16 +89,15 @@ import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
|
|||||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
|
|
||||||
public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
|
public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
|
||||||
private final Spigot_v1_16_R2 parent;
|
private final Spigot_v1_16_R2 parent;
|
||||||
@ -89,7 +117,9 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean init() {
|
private synchronized boolean init() {
|
||||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) return false;
|
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
||||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||||
BlockState state = BlockTypesCache.states[i];
|
BlockState state = BlockTypesCache.states[i];
|
||||||
@ -188,9 +218,13 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (existing == blockData) return true;
|
if (existing == blockData) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
if (blockData.isAir()) return true;
|
if (blockData.isAir()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
sections[y4] = section = new ChunkSection(y4 << 4);
|
sections[y4] = section = new ChunkSection(y4 << 4);
|
||||||
}
|
}
|
||||||
nmsChunk.setType(blockPos, blockData, false);
|
nmsChunk.setType(blockPos, blockData, false);
|
||||||
|
@ -79,70 +79,57 @@ public class Fawe {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Fawe.class);
|
private static final Logger log = LoggerFactory.getLogger(Fawe.class);
|
||||||
|
|
||||||
/**
|
private static Fawe instance;
|
||||||
* The FAWE instance;
|
|
||||||
*/
|
|
||||||
private static Fawe INSTANCE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TPS timer
|
* The ticks-per-second timer.
|
||||||
*/
|
*/
|
||||||
private final FaweTimer timer;
|
private final FaweTimer timer;
|
||||||
private FaweVersion version;
|
private FaweVersion version;
|
||||||
private VisualQueue visualQueue;
|
private VisualQueue visualQueue;
|
||||||
private TextureUtil textures;
|
private TextureUtil textures;
|
||||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
|
||||||
// private DefaultTransformParser transformParser;
|
|
||||||
|
|
||||||
private QueueHandler queueHandler;
|
private QueueHandler queueHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the implementation specific class
|
* Get the implementation specific class.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T extends IFawe> T imp() {
|
public static <T extends IFawe> T imp() {
|
||||||
return INSTANCE != null ? (T) INSTANCE.IMP : null;
|
return instance != null ? (T) instance.implementation : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the implementation independent class
|
* Get the implementation independent class.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static Fawe get() {
|
public static Fawe get() {
|
||||||
return INSTANCE;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup Fawe
|
* This method is not for public use. If you have to ask what it does then you shouldn't be using it.
|
||||||
*
|
|
||||||
* @param implementation
|
|
||||||
* @throws InstanceAlreadyExistsException
|
|
||||||
*/
|
*/
|
||||||
public static void set(final IFawe implementation) throws InstanceAlreadyExistsException, IllegalArgumentException {
|
public static void set(final IFawe implementation) throws InstanceAlreadyExistsException, IllegalArgumentException {
|
||||||
if (INSTANCE != null) {
|
if (instance != null) {
|
||||||
throw new InstanceAlreadyExistsException("FAWE has already been initialized with: " + INSTANCE.IMP);
|
throw new InstanceAlreadyExistsException("FAWE has already been initialized with: " + instance.implementation);
|
||||||
}
|
}
|
||||||
if (implementation == null) {
|
if (implementation == null) {
|
||||||
throw new IllegalArgumentException("Implementation may not be null.");
|
throw new IllegalArgumentException("Implementation may not be null.");
|
||||||
}
|
}
|
||||||
INSTANCE = new Fawe(implementation);
|
instance = new Fawe(implementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugPlain(String s) {
|
public static void debugPlain(String s) {
|
||||||
if (INSTANCE != null) {
|
if (instance != null) {
|
||||||
INSTANCE.IMP.debug(s);
|
instance.implementation.debug(s);
|
||||||
} else {
|
} else {
|
||||||
System.out.println(s);
|
log.debug(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write something to the console
|
* Write something to the console.
|
||||||
*
|
|
||||||
* @param s
|
|
||||||
*/
|
*/
|
||||||
public static void debug(String s) {
|
public static void debug(String s) {
|
||||||
Actor actor = Request.request().getActor();
|
Actor actor = Request.request().getActor();
|
||||||
@ -154,7 +141,7 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write something to the console
|
* Write something to the console.
|
||||||
*
|
*
|
||||||
* @param c The Component to be printed
|
* @param c The Component to be printed
|
||||||
*/
|
*/
|
||||||
@ -168,24 +155,26 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The platform specific implementation
|
* The platform specific implementation.
|
||||||
*/
|
*/
|
||||||
private final IFawe IMP;
|
private final IFawe implementation;
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
private Fawe(final IFawe implementation) {
|
private Fawe(final IFawe implementation) {
|
||||||
INSTANCE = this;
|
instance = this;
|
||||||
this.IMP = implementation;
|
this.implementation = implementation;
|
||||||
this.thread = Thread.currentThread();
|
this.thread = Thread.currentThread();
|
||||||
/*
|
/*
|
||||||
* Implementation dependent stuff
|
* Implementation dependent stuff
|
||||||
*/
|
*/
|
||||||
this.setupConfigs();
|
this.setupConfigs();
|
||||||
TaskManager.IMP = this.IMP.getTaskManager();
|
TaskManager.IMP = this.implementation.getTaskManager();
|
||||||
|
|
||||||
TaskManager.IMP.async(() -> {
|
TaskManager.IMP.async(() -> {
|
||||||
MainUtil.deleteOlder(MainUtil.getFile(IMP.getDirectory(), Settings.IMP.PATHS.HISTORY), TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS), false);
|
MainUtil.deleteOlder(MainUtil.getFile(this.implementation
|
||||||
MainUtil.deleteOlder(MainUtil.getFile(IMP.getDirectory(), Settings.IMP.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS), false);
|
.getDirectory(), Settings.IMP.PATHS.HISTORY), TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS), false);
|
||||||
|
MainUtil.deleteOlder(MainUtil.getFile(this.implementation
|
||||||
|
.getDirectory(), Settings.IMP.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -197,11 +186,10 @@ public class Fawe {
|
|||||||
// Delayed worldedit setup
|
// Delayed worldedit setup
|
||||||
TaskManager.IMP.later(() -> {
|
TaskManager.IMP.later(() -> {
|
||||||
try {
|
try {
|
||||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
|
||||||
// transformParser = new DefaultTransformParser(getWorldEdit());
|
|
||||||
visualQueue = new VisualQueue(3);
|
visualQueue = new VisualQueue(3);
|
||||||
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
WEManager.IMP.managers.addAll(Fawe.this.implementation.getMaskManagers());
|
||||||
} catch (Throwable ignored) {}
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
TaskManager.IMP.repeat(timer, 1);
|
TaskManager.IMP.repeat(timer, 1);
|
||||||
@ -214,18 +202,13 @@ public class Fawe {
|
|||||||
if (queueHandler == null) {
|
if (queueHandler == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (queueHandler == null) {
|
if (queueHandler == null) {
|
||||||
queueHandler = IMP.getQueueHandler();
|
queueHandler = implementation.getQueueHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return queueHandler;
|
return queueHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
|
||||||
// public DefaultTransformParser getTransformParser() {
|
|
||||||
// return transformParser;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
||||||
// TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
|
// TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
|
||||||
TextureUtil tu = getTextureUtil();
|
TextureUtil tu = getTextureUtil();
|
||||||
@ -257,32 +240,27 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FaweTimer is a useful class for monitoring TPS
|
* Gets the TPS monitor.
|
||||||
*
|
|
||||||
* @return FaweTimer
|
|
||||||
*/
|
*/
|
||||||
public FaweTimer getTimer() {
|
public FaweTimer getTimer() {
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The visual queue is used to queue visualizations
|
* Get the visual queue.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public VisualQueue getVisualQueue() {
|
public VisualQueue getVisualQueue() {
|
||||||
return visualQueue;
|
return visualQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FAWE version
|
* The FAWE version.
|
||||||
* - Unofficial jars may be lacking version information
|
|
||||||
*
|
*
|
||||||
|
* @apiNote Unofficial jars may be lacking version information
|
||||||
* @return FaweVersion
|
* @return FaweVersion
|
||||||
*/
|
*/
|
||||||
public
|
|
||||||
@Nullable
|
@Nullable
|
||||||
FaweVersion getVersion() {
|
public FaweVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,8 +271,8 @@ public class Fawe {
|
|||||||
public void setupConfigs() {
|
public void setupConfigs() {
|
||||||
MainUtil.copyFile(MainUtil.getJarFile(), "lang/strings.json", null);
|
MainUtil.copyFile(MainUtil.getJarFile(), "lang/strings.json", null);
|
||||||
// Setting up config.yml
|
// Setting up config.yml
|
||||||
File file = new File(this.IMP.getDirectory(), "config.yml");
|
File file = new File(this.implementation.getDirectory(), "config.yml");
|
||||||
Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", "");
|
Settings.IMP.PLATFORM = implementation.getPlatform().replace("\"", "");
|
||||||
try (InputStream stream = getClass().getResourceAsStream(File.separator + "fawe.properties");
|
try (InputStream stream = getClass().getResourceAsStream(File.separator + "fawe.properties");
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
|
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
|
||||||
String versionString = br.readLine();
|
String versionString = br.readLine();
|
||||||
@ -305,14 +283,12 @@ public class Fawe {
|
|||||||
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||||
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-1.16/" + version.build;
|
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-1.16/" + version.build;
|
||||||
Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit/commit/" + Integer.toHexString(version.hash);
|
Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit/commit/" + Integer.toHexString(version.hash);
|
||||||
} catch (Throwable ignore) {}
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Settings.IMP.reload(file);
|
Settings.IMP.reload(file);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
debug("====== Failed to load config ======");
|
log.error("Failed to load config.", e);
|
||||||
debug("Please validate your yaml files:");
|
|
||||||
e.printStackTrace();
|
|
||||||
debug("====================================");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,22 +310,15 @@ public class Fawe {
|
|||||||
if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) {
|
if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) {
|
||||||
Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
|
Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
|
||||||
Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
|
Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
|
||||||
debug("====== ZSTD COMPRESSION BINDING NOT FOUND ======");
|
log.error("ZSTD Compression Binding Not Found.\n"
|
||||||
debug(e.getMessage());
|
+ "FAWE will still work but compression won't work as well.\n", e);
|
||||||
debug("FAWE will work but won't compress data as much");
|
|
||||||
debug("===============================================");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
net.jpountz.util.Native.load();
|
net.jpountz.util.Native.load();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
log.error("LZ4 Compression Binding Not Found.\n"
|
||||||
debug("====== LZ4 COMPRESSION BINDING NOT FOUND ======");
|
+ "FAWE will still work but compression will be slower.\n", e);
|
||||||
debug(e.getMessage());
|
|
||||||
debug("FAWE will work but compression will be slower");
|
|
||||||
debug(" - Try updating your JVM / OS");
|
|
||||||
debug(" - Report this issue if you cannot resolve it");
|
|
||||||
debug("===============================================");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,22 +371,18 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the main thread
|
* Get the main thread.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Thread getMainThread() {
|
public Thread getMainThread() {
|
||||||
return this.thread;
|
return this.thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMainThread() {
|
public static boolean isMainThread() {
|
||||||
return INSTANCE == null || INSTANCE.thread == Thread.currentThread();
|
return instance == null || instance.thread == Thread.currentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the main thread to the current thread
|
* Sets the main thread to the current thread.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Thread setMainThread() {
|
public Thread setMainThread() {
|
||||||
return this.thread = Thread.currentThread();
|
return this.thread = Thread.currentThread();
|
||||||
|
@ -55,19 +55,20 @@ import javax.annotation.Nullable;
|
|||||||
* FaweAPI.[some method]
|
* FaweAPI.[some method]
|
||||||
*/
|
*/
|
||||||
public class FaweAPI {
|
public class FaweAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offers a lot of options for building an EditSession
|
* Offers a lot of options for building an EditSession.
|
||||||
*
|
*
|
||||||
* @param world
|
|
||||||
* @return A new EditSessionBuilder
|
* @return A new EditSessionBuilder
|
||||||
* @see EditSessionBuilder
|
* @see EditSessionBuilder
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static EditSessionBuilder getEditSessionBuilder(World world) {
|
public static EditSessionBuilder getEditSessionBuilder(World world) {
|
||||||
return new EditSessionBuilder(world);
|
return new EditSessionBuilder(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TaskManager has some useful methods for doing things asynchronously
|
* The TaskManager has some useful methods for doing things asynchronously.
|
||||||
*
|
*
|
||||||
* @return TaskManager
|
* @return TaskManager
|
||||||
*/
|
*/
|
||||||
@ -75,24 +76,13 @@ public class FaweAPI {
|
|||||||
return TaskManager.IMP;
|
return TaskManager.IMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Add a custom transform for use in
|
|
||||||
// *
|
|
||||||
// * @param methods The class with a bunch of transform methods
|
|
||||||
// * @return true if the transform was registered
|
|
||||||
// * @see com.sk89q.worldedit.command.TransformCommands
|
|
||||||
// */
|
|
||||||
// public static boolean registerTransforms(Object methods) {
|
|
||||||
// DefaultTransformParser parser = Fawe.get().getTransformParser();
|
|
||||||
// if (parser != null) parser.register(methods);
|
|
||||||
// return parser != null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can either use a IQueueExtent or an EditSession to change blocks<br>
|
* You can either use a {@code IQueueExtent} or an {@code EditSession} to change blocks.
|
||||||
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
|
*
|
||||||
* - The WorldEdit EditSession can do a lot more<br>
|
* <p>
|
||||||
* Remember to commit when you're done!<br>
|
* The {@link IQueueExtent} skips a bit of overhead, so it is marginally faster. {@link
|
||||||
|
* EditSession} can do a lot more. Remember to commit when you are done!
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param world The name of the world
|
* @param world The name of the world
|
||||||
* @param autoQueue If it should start dispatching before you enqueue it.
|
* @param autoQueue If it should start dispatching before you enqueue it.
|
||||||
@ -118,7 +108,7 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload the clipboard to the configured web interface
|
* Upload the clipboard to the configured web interface.
|
||||||
*
|
*
|
||||||
* @param clipboard The clipboard (may not be null)
|
* @param clipboard The clipboard (may not be null)
|
||||||
* @param format The format to use (some formats may not be supported)
|
* @param format The format to use (some formats may not be supported)
|
||||||
@ -129,7 +119,7 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just forwards to ClipboardFormat.SCHEMATIC.load(file)
|
* Just forwards to ClipboardFormat.SCHEMATIC.load(file).
|
||||||
*
|
*
|
||||||
* @param file the file to load
|
* @param file the file to load
|
||||||
* @return a clipboard containing the schematic
|
* @return a clipboard containing the schematic
|
||||||
@ -149,7 +139,7 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the server has more than the configured low memory threshold
|
* Check if the server has more than the configured low memory threshold.
|
||||||
*
|
*
|
||||||
* @return True if the server has limited memory
|
* @return True if the server has limited memory
|
||||||
*/
|
*/
|
||||||
@ -158,28 +148,26 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player's allowed WorldEdit region
|
* Get a player's allowed WorldEdit region.
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static Region[] getRegions(Player player) {
|
public static Region[] getRegions(Player player) {
|
||||||
return WEManager.IMP.getMask(player);
|
return WEManager.IMP.getMask(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the edit with the following extent<br>
|
* Cancel the edit with the following extent.
|
||||||
* - The extent must be the one being used by an EditSession, otherwise an error may be thrown <br>
|
|
||||||
* - Insert an extent into the EditSession using the EditSessionEvent: http://wiki.sk89q.com/wiki/WorldEdit/API/Hooking_EditSession <br>
|
|
||||||
*
|
*
|
||||||
* @param extent
|
* <p>
|
||||||
* @param reason
|
* The extent must be the one being used by an EditSession, otherwise an error will be thrown.
|
||||||
* @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession
|
* Insert an extent into the EditSession using the EditSessionEvent.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @see EditSession#getRegionExtent() How to get the FaweExtent for an EditSession
|
||||||
*/
|
*/
|
||||||
public static void cancelEdit(AbstractDelegateExtent extent, Component reason) {
|
public static void cancelEdit(AbstractDelegateExtent extent, Component reason) {
|
||||||
try {
|
try {
|
||||||
WEManager.IMP.cancelEdit(extent, new FaweException(reason));
|
WEManager.IMP.cancelEdit(extent, new FaweException(reason));
|
||||||
} catch (WorldEditException ignore) {
|
} catch (WorldEditException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,10 +176,7 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the DiskStorageHistory object representing a File
|
* Get the DiskStorageHistory object representing a File.
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static DiskStorageHistory getChangeSetFromFile(File file) {
|
public static DiskStorageHistory getChangeSetFromFile(File file) {
|
||||||
if (!file.exists() || file.isDirectory()) {
|
if (!file.exists() || file.isDirectory()) {
|
||||||
@ -200,7 +185,7 @@ public class FaweAPI {
|
|||||||
if (Settings.IMP.HISTORY.USE_DISK) {
|
if (Settings.IMP.HISTORY.USE_DISK) {
|
||||||
throw new IllegalArgumentException("History on disk not enabled!");
|
throw new IllegalArgumentException("History on disk not enabled!");
|
||||||
}
|
}
|
||||||
if (!file.getName().toLowerCase().endsWith(".bd")) {
|
if (!file.getName().toLowerCase(Locale.ROOT).endsWith(".bd")) {
|
||||||
throw new IllegalArgumentException("Not a BD file!");
|
throw new IllegalArgumentException("Not a BD file!");
|
||||||
}
|
}
|
||||||
String[] path = file.getPath().split(File.separator);
|
String[] path = file.getPath().split(File.separator);
|
||||||
@ -223,16 +208,18 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in the RollBack to generate a list of DiskStorageHistory objects<br>
|
* Used in the rollback to generate a list of {@link DiskStorageHistory} objects.
|
||||||
* - Note: An edit outside the radius may be included if it overlaps with an edit inside that depends on it.
|
|
||||||
*
|
*
|
||||||
* @param origin - The origin location
|
* @param origin - The origin location
|
||||||
* @param user - The uuid (may be null)
|
* @param user - The uuid (may be null)
|
||||||
* @param radius - The radius from the origin of the edit
|
* @param radius - The radius from the origin of the edit
|
||||||
* @param timediff - The max age of the file in milliseconds
|
* @param timediff - The max age of the file in milliseconds
|
||||||
* @param shallow - If shallow is true, FAWE will only read the first Settings.IMP.BUFFER_SIZE bytes to obtain history info<br>
|
* @param shallow - If shallow is true, FAWE will only read the first {@link
|
||||||
* Reading only part of the file will result in unreliable bounds info for large edits
|
* Settings.HISTORY#BUFFER_SIZE} bytes to obtain history info
|
||||||
* @return a list of DiskStorageHistory Objects
|
* @return a list of DiskStorageHistory Objects
|
||||||
|
* @apiNote An edit outside the radius may be included if it overlaps with an edit inside
|
||||||
|
* that depends on it. Reading only part of the file will result in unreliable bounds info
|
||||||
|
* for large edits.
|
||||||
*/
|
*/
|
||||||
public static List<DiskStorageHistory> getBDFiles(Location origin, UUID user, int radius, long timediff, boolean shallow) {
|
public static List<DiskStorageHistory> getBDFiles(Location origin, UUID user, int radius, long timediff, boolean shallow) {
|
||||||
Extent extent = origin.getExtent();
|
Extent extent = origin.getExtent();
|
||||||
@ -312,35 +299,19 @@ public class FaweAPI {
|
|||||||
/**
|
/**
|
||||||
* The DiskStorageHistory class is what FAWE uses to represent the undo on disk.
|
* The DiskStorageHistory class is what FAWE uses to represent the undo on disk.
|
||||||
*
|
*
|
||||||
* @param world
|
|
||||||
* @param uuid
|
|
||||||
* @param index
|
|
||||||
* @return
|
|
||||||
* @see DiskStorageHistory#toEditSession(Player)
|
|
||||||
*/
|
*/
|
||||||
public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) {
|
public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) {
|
||||||
return new DiskStorageHistory(world, uuid, index);
|
return new DiskStorageHistory(world, uuid, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two versions
|
* Fix the lighting in a selection. This is a multi-step process as outlined below.
|
||||||
*
|
*
|
||||||
* @param version
|
* <ol>
|
||||||
* @param major
|
* <li>Removes all lighting, then relights.</li>
|
||||||
* @param minor
|
* <li>Relights in parallel (if enabled) for best performance.</li>
|
||||||
* @param minor2
|
* <li>Resends the chunks to the client.</li>
|
||||||
* @return true if version is >= major, minor, minor2
|
* </ol>
|
||||||
*/
|
|
||||||
public static boolean checkVersion(final int[] version, final int major, final int minor, final int minor2) {
|
|
||||||
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fix the lighting in a selection<br>
|
|
||||||
* - First removes all lighting, then relights
|
|
||||||
* - Relights in parallel (if enabled) for best performance<br>
|
|
||||||
* - Also resends chunks<br>
|
|
||||||
*
|
*
|
||||||
* @param world World to relight in
|
* @param world World to relight in
|
||||||
* @param selection Region to relight
|
* @param selection Region to relight
|
||||||
@ -395,26 +366,19 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Have a task run when the server is low on memory (configured threshold)
|
* Runs a task when the server is low on memory.
|
||||||
*
|
|
||||||
* @param run
|
|
||||||
*/
|
*/
|
||||||
public static void addMemoryLimitedTask(Runnable run) {
|
public static void addMemoryLimitedTask(Runnable run) {
|
||||||
MemUtil.addMemoryLimitedTask(run);
|
MemUtil.addMemoryLimitedTask(run);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Have a task run when the server is no longer low on memory (configured threshold)
|
* Runs a task when the server is no longer low on memory.
|
||||||
*
|
|
||||||
* @param run
|
|
||||||
*/
|
*/
|
||||||
public static void addMemoryPlentifulTask(Runnable run) {
|
public static void addMemoryPlentifulTask(Runnable run) {
|
||||||
MemUtil.addMemoryPlentifulTask(run);
|
MemUtil.addMemoryPlentifulTask(run);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Map of translation ket to value
|
|
||||||
*/
|
|
||||||
public static Map<String, String> getTranslations(Locale locale) {
|
public static Map<String, String> getTranslations(Locale locale) {
|
||||||
return WorldEdit.getInstance().getTranslationManager().getTranslationMap(locale);
|
return WorldEdit.getInstance().getTranslationManager().getTranslationMap(locale);
|
||||||
}
|
}
|
||||||
|
@ -312,8 +312,6 @@ public enum FaweCache implements Trimable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert raw int array to unstretched palette (1.16)
|
* Convert raw int array to unstretched palette (1.16)
|
||||||
* @param layerOffset
|
|
||||||
* @param blocks
|
|
||||||
* @return palette
|
* @return palette
|
||||||
*/
|
*/
|
||||||
public Palette toPaletteUnstretched(int layerOffset, int[] blocks) {
|
public Palette toPaletteUnstretched(int layerOffset, int[] blocks) {
|
||||||
@ -518,7 +516,9 @@ public enum FaweCache implements Trimable {
|
|||||||
}
|
}
|
||||||
list.add(tag);
|
list.add(tag);
|
||||||
}
|
}
|
||||||
if (clazz == null) clazz = EndTag.class;
|
if (clazz == null) {
|
||||||
|
clazz = EndTag.class;
|
||||||
|
}
|
||||||
return new ListTag(clazz, list);
|
return new ListTag(clazz, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +532,9 @@ public enum FaweCache implements Trimable {
|
|||||||
}
|
}
|
||||||
list.add(tag);
|
list.add(tag);
|
||||||
}
|
}
|
||||||
if (clazz == null) clazz = EndTag.class;
|
if (clazz == null) {
|
||||||
|
clazz = EndTag.class;
|
||||||
|
}
|
||||||
return new ListTag(clazz, list);
|
return new ListTag(clazz, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,8 +545,8 @@ public enum FaweCache implements Trimable {
|
|||||||
int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
|
int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
|
||||||
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads);
|
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads);
|
||||||
return new ThreadPoolExecutor(nThreads, nThreads,
|
return new ThreadPoolExecutor(nThreads, nThreads,
|
||||||
0L, TimeUnit.MILLISECONDS, queue
|
0L, TimeUnit.MILLISECONDS, queue,
|
||||||
, Executors.defaultThreadFactory(),
|
Executors.defaultThreadFactory(),
|
||||||
new ThreadPoolExecutor.CallerRunsPolicy()) {
|
new ThreadPoolExecutor.CallerRunsPolicy()) {
|
||||||
protected void afterExecute(Runnable r, Throwable t) {
|
protected void afterExecute(Runnable r, Throwable t) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package com.boydti.fawe;
|
package com.boydti.fawe;
|
||||||
|
|
||||||
public class FaweVersion {
|
public class FaweVersion {
|
||||||
public final int year, month, day, hash, build;
|
public final int year;
|
||||||
|
public final int month;
|
||||||
|
public final int day;
|
||||||
|
public final int hash;
|
||||||
|
public final int build;
|
||||||
|
|
||||||
public FaweVersion(int year, int month, int day, int hash, int build) {
|
public FaweVersion(int year, int month, int day, int hash, int build) {
|
||||||
this.year = year;
|
this.year = year;
|
||||||
|
@ -18,8 +18,8 @@ public class CombinedBlocks implements IBlocks {
|
|||||||
private final int addMask;
|
private final int addMask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param secondary
|
* TODO Add a constructor here to satisfy checkstyle.
|
||||||
* @param primary
|
*
|
||||||
* @param addMask - bitMask for force sending sections, else 0 to send the primary ones
|
* @param addMask - bitMask for force sending sections, else 0 to send the primary ones
|
||||||
*/
|
*/
|
||||||
public CombinedBlocks(IBlocks secondary, IBlocks primary, int addMask) {
|
public CombinedBlocks(IBlocks secondary, IBlocks primary, int addMask) {
|
||||||
@ -92,11 +92,15 @@ public class CombinedBlocks implements IBlocks {
|
|||||||
BlockVector3 pos = entry.getKey();
|
BlockVector3 pos = entry.getKey();
|
||||||
BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ());
|
BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||||
if (block.getBlockType() == BlockTypes.__RESERVED__) {
|
if (block.getBlockType() == BlockTypes.__RESERVED__) {
|
||||||
if (copy == null) copy = new HashMap<>(tiles);
|
if (copy == null) {
|
||||||
|
copy = new HashMap<>(tiles);
|
||||||
|
}
|
||||||
copy.put(pos, entry.getValue());
|
copy.put(pos, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (copy != null) return copy;
|
if (copy != null) {
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tiles;
|
return tiles;
|
||||||
@ -116,8 +120,12 @@ public class CombinedBlocks implements IBlocks {
|
|||||||
Set<CompoundTag> joined = primary.getEntities();
|
Set<CompoundTag> joined = primary.getEntities();
|
||||||
if (primary != secondary) {
|
if (primary != secondary) {
|
||||||
Set<CompoundTag> ents2 = secondary.getEntities();
|
Set<CompoundTag> ents2 = secondary.getEntities();
|
||||||
if (joined.isEmpty()) return ents2;
|
if (joined.isEmpty()) {
|
||||||
if (ents2.isEmpty()) return joined;
|
return ents2;
|
||||||
|
}
|
||||||
|
if (ents2.isEmpty()) {
|
||||||
|
return joined;
|
||||||
|
}
|
||||||
joined = new HashSet<>(joined);
|
joined = new HashSet<>(joined);
|
||||||
joined.addAll(ents2);
|
joined.addAll(ents2);
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,9 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public interface IBatchProcessor {
|
public interface IBatchProcessor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a chunk that has been set
|
* Process a chunk that has been set.
|
||||||
* @param chunk
|
|
||||||
* @param get
|
|
||||||
* @param set
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set);
|
IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set);
|
||||||
|
|
||||||
@ -31,18 +28,13 @@ public interface IBatchProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert this processor into an Extent based processor instead of a queue batch based on
|
* Convert this processor into an Extent based processor instead of a queue batch based on.
|
||||||
* @param child
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Extent construct(Extent child);
|
Extent construct(Extent child);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to trim a chunk based on min and max Y
|
* Utility method to trim a chunk based on min and max Y.
|
||||||
* @param set
|
|
||||||
* @param minY
|
|
||||||
* @param maxY
|
|
||||||
* @return false if chunk is empty of blocks
|
* @return false if chunk is empty of blocks
|
||||||
*/
|
*/
|
||||||
default boolean trimY(IChunkSet set, int minY, int maxY) {
|
default boolean trimY(IChunkSet set, int minY, int maxY) {
|
||||||
@ -52,7 +44,9 @@ public interface IBatchProcessor {
|
|||||||
if (layer == minLayer) {
|
if (layer == minLayer) {
|
||||||
char[] arr = set.load(layer);
|
char[] arr = set.load(layer);
|
||||||
int index = (minY & 15) << 8;
|
int index = (minY & 15) << 8;
|
||||||
for (int i = 0; i < index; i++) arr[i] = 0;
|
for (int i = 0; i < index; i++) {
|
||||||
|
arr[i] = 0;
|
||||||
|
}
|
||||||
set.setBlocks(layer, arr);
|
set.setBlocks(layer, arr);
|
||||||
} else {
|
} else {
|
||||||
set.setBlocks(layer, null);
|
set.setBlocks(layer, null);
|
||||||
@ -65,7 +59,9 @@ public interface IBatchProcessor {
|
|||||||
if (layer == minLayer) {
|
if (layer == minLayer) {
|
||||||
char[] arr = set.load(layer);
|
char[] arr = set.load(layer);
|
||||||
int index = ((maxY + 1) & 15) << 8;
|
int index = ((maxY + 1) & 15) << 8;
|
||||||
for (int i = index; i < arr.length; i++) arr[i] = 0;
|
for (int i = index; i < arr.length; i++) {
|
||||||
|
arr[i] = 0;
|
||||||
|
}
|
||||||
set.setBlocks(layer, arr);
|
set.setBlocks(layer, arr);
|
||||||
} else {
|
} else {
|
||||||
set.setBlocks(layer, null);
|
set.setBlocks(layer, null);
|
||||||
@ -91,9 +87,8 @@ public interface IBatchProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to trim entity and blocks with a provided contains function
|
* Utility method to trim entity and blocks with a provided contains function.
|
||||||
* @param set
|
*
|
||||||
* @param contains
|
|
||||||
* @return false if chunk is empty of NBT
|
* @return false if chunk is empty of NBT
|
||||||
*/
|
*/
|
||||||
default boolean trimNBT(IChunkSet set, Function<BlockVector3, Boolean> contains) {
|
default boolean trimNBT(IChunkSet set, Function<BlockVector3, Boolean> contains) {
|
||||||
@ -110,9 +105,7 @@ public interface IBatchProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join two processors and return the result
|
* Join two processors and return the result.
|
||||||
* @param other
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
default IBatchProcessor join(IBatchProcessor other) {
|
default IBatchProcessor join(IBatchProcessor other) {
|
||||||
return MultiBatchProcessor.of(this, other);
|
return MultiBatchProcessor.of(this, other);
|
||||||
@ -122,13 +115,11 @@ public interface IBatchProcessor {
|
|||||||
return MultiBatchProcessor.of(this, other);
|
return MultiBatchProcessor.of(this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void flush() {}
|
default void flush() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new processor after removing all are instances of a specified class
|
* Return a new processor after removing all are instances of a specified class.
|
||||||
* @param clazz
|
|
||||||
* @param <T>
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
default <T extends IBatchProcessor> IBatchProcessor remove(Class<T> clazz) {
|
default <T extends IBatchProcessor> IBatchProcessor remove(Class<T> clazz) {
|
||||||
if (clazz.isInstance(this)) {
|
if (clazz.isInstance(this)) {
|
||||||
|
@ -19,7 +19,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A shared interface for IGetBlocks and ISetBlocks
|
* A shared interface for IGetBlocks and ISetBlocks.
|
||||||
*/
|
*/
|
||||||
public interface IBlocks extends Trimable {
|
public interface IBlocks extends Trimable {
|
||||||
|
|
||||||
|
@ -49,16 +49,16 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
|||||||
void init(Extent extent, IChunkCache<IChunkGet> get, IChunkCache<IChunkSet> set);
|
void init(Extent extent, IChunkCache<IChunkGet> get, IChunkCache<IChunkSet> set);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cached get object
|
* Get the cached get object. This is faster than getting the object using NMS and allows for
|
||||||
* - Faster than getting it using NMS and allows for wrapping
|
* wrapping.
|
||||||
* @param x
|
* @param chunkX
|
||||||
* @param z
|
* @param chunkZ
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
IChunkGet getCachedGet(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z);
|
IChunkGet getCachedGet(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cached chunk set object
|
* Get the cached chunk set object.
|
||||||
* @param chunkX
|
* @param chunkX
|
||||||
* @param chunkZ
|
* @param chunkZ
|
||||||
* @return
|
* @return
|
||||||
@ -88,19 +88,18 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
|||||||
boolean isFastMode();
|
boolean isFastMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new root IChunk object<br> - Full chunks will be reused, so a more optimized chunk
|
* Create a new root IChunk object. Full chunks will be reused, so a more optimized chunk can be
|
||||||
* can be returned in that case<br> - Don't wrap the chunk, that should be done in {@link
|
* returned in that case.
|
||||||
* #wrap(T)}
|
|
||||||
*
|
*
|
||||||
|
* @apiNote Don't wrap the chunk, that should be done in {@link IQueueExtent#wrap(IChunk)}
|
||||||
* @param isFull true if a more optimized chunk should be returned
|
* @param isFull true if a more optimized chunk should be returned
|
||||||
* @return a more optimized chunk object
|
* @return a more optimized chunk object
|
||||||
*/
|
*/
|
||||||
T create(boolean isFull);
|
T create(boolean isFull);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the chunk object (i.e., for region restrictions / limits etc.)
|
* Wrap the chunk object (i.e., for region restrictions / limits etc.).
|
||||||
*
|
*
|
||||||
* @param root
|
|
||||||
* @return wrapped chunk
|
* @return wrapped chunk
|
||||||
*/
|
*/
|
||||||
default T wrap(T root) {
|
default T wrap(T root) {
|
||||||
@ -115,15 +114,15 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush all changes to the world - Best to call this async so it doesn't hang the server
|
* Flush all changes to the world.
|
||||||
|
* @apiNote Best to call this async, so it doesn't hang the server.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A filter block is used to iterate over blocks / positions
|
* A filter block is used to iterate over blocks / positions. Essentially combines BlockVector3,
|
||||||
* - Essentially combines BlockVector3, Extent and BlockState functions in a way that avoids lookups
|
* Extent and BlockState functions in a way that avoids lookups.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
ChunkFilterBlock initFilterBlock();
|
ChunkFilterBlock initFilterBlock();
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package com.boydti.fawe.beta;
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for objects that can be trimmed (memory related)<br> - Trimming will reduce its memory
|
* Interface for objects that can be trimmed (memory related). Trimming will reduce its memory
|
||||||
* footprint
|
* footprint.
|
||||||
*/
|
*/
|
||||||
public interface Trimable {
|
public interface Trimable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trims the object, reducing its memory footprint
|
* Trims the object, reducing its memory footprint.
|
||||||
*
|
*
|
||||||
* @param aggressive if trimming should be aggressive e.g., Not return early when the first
|
* @param aggressive if trimming should be aggressive e.g., Not returning early when the first
|
||||||
* element cannot be trimmed
|
* element cannot be trimmed
|
||||||
* @return if this object is empty at the end of the trim, and can therefore be deleted
|
* @return if this object is empty at the end of the trim, and can therefore be deleted
|
||||||
*/
|
*/
|
||||||
boolean trim(boolean aggressive);
|
boolean trim(boolean aggressive);
|
||||||
|
|
||||||
default void recycle() {}
|
default void recycle() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,19 +68,33 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setBlockLight(int x, int y, int z, int value) {}
|
@Override
|
||||||
|
public void setBlockLight(int x, int y, int z, int value) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void setSkyLight(int x, int y, int z, int value) {}
|
@Override
|
||||||
|
public void setSkyLight(int x, int y, int z, int value) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void setHeightMap(HeightMapType type, int[] heightMap) {}
|
@Override
|
||||||
|
public void setHeightMap(HeightMapType type, int[] heightMap) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void setLightLayer(int layer, char[] toSet) {}
|
@Override
|
||||||
|
public void setLightLayer(int layer, char[] toSet) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void setSkyLightLayer(int layer, char[] toSet) {}
|
@Override
|
||||||
|
public void setSkyLightLayer(int layer, char[] toSet) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void removeSectionLighting(int layer, boolean sky) {}
|
@Override
|
||||||
|
public void removeSectionLighting(int layer, boolean sky) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void setFullBright(int layer) {}
|
@Override
|
||||||
|
public void setFullBright(int layer) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEntity(CompoundTag tag) {
|
public void setEntity(CompoundTag tag) {
|
||||||
@ -134,11 +148,13 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public char[][] getLight() {
|
@Override
|
||||||
|
public char[][] getLight() {
|
||||||
return new char[0][];
|
return new char[0][];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public char[][] getSkyLight() {
|
@Override
|
||||||
|
public char[][] getSkyLight() {
|
||||||
return new char[0][];
|
return new char[0][];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
sections[layer].set(this, layer, index, value);
|
sections[layer].set(this, layer, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Section {
|
public abstract static class Section {
|
||||||
|
|
||||||
public abstract char[] get(CharBlocks blocks, @Range(from = 0, to = 15) int layer);
|
public abstract char[] get(CharBlocks blocks, @Range(from = 0, to = 15) int layer);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||||
private static final Pool<CharSetBlocks> POOL = FaweCache.IMP.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
private static final Pool<CharSetBlocks> POOL = FaweCache.IMP.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
||||||
|
|
||||||
public static CharSetBlocks newInstance() {
|
public static CharSetBlocks newInstance() {
|
||||||
return POOL.poll();
|
return POOL.poll();
|
||||||
}
|
}
|
||||||
@ -38,7 +39,8 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
|||||||
private boolean fastMode = false;
|
private boolean fastMode = false;
|
||||||
private int bitMask = -1;
|
private int bitMask = -1;
|
||||||
|
|
||||||
private CharSetBlocks() {}
|
private CharSetBlocks() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recycle() {
|
public void recycle() {
|
||||||
@ -52,7 +54,9 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiomeType(int x, int y, int z) {
|
public BiomeType getBiomeType(int x, int y, int z) {
|
||||||
if (biomes == null) return null;
|
if (biomes == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return biomes[(z << 4) | x];
|
return biomes[(z << 4) | x];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
public class FallbackChunkGet implements IChunkGet {
|
public class FallbackChunkGet implements IChunkGet {
|
||||||
private final int bx, bz;
|
private final int bx;
|
||||||
|
private final int bz;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
|
|
||||||
public FallbackChunkGet(Extent extent, int chunkX, int chunkZ) {
|
public FallbackChunkGet(Extent extent, int chunkX, int chunkZ) {
|
||||||
@ -32,6 +33,7 @@ public class FallbackChunkGet implements IChunkGet {
|
|||||||
this.bx = chunkX << 4;
|
this.bx = chunkX << 4;
|
||||||
this.bz = chunkZ << 4;
|
this.bz = chunkZ << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
return extent.getFullBlock(bx + x, y, bz + z);
|
return extent.getFullBlock(bx + x, y, bz + z);
|
||||||
|
@ -20,7 +20,7 @@ public class ChunkCache<T extends Trimable> implements IChunkCache<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or create the IGetBlocks
|
* Get or create the IGetBlocks.
|
||||||
*
|
*
|
||||||
* @return cached IGetBlocks
|
* @return cached IGetBlocks
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +45,9 @@ public class AsyncPreloader implements Preloader, Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player) {
|
||||||
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(player);
|
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(player);
|
||||||
if (session == null) return;
|
if (session == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
|
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
|
||||||
try {
|
try {
|
||||||
@ -67,7 +69,8 @@ public class AsyncPreloader implements Preloader, Runnable {
|
|||||||
update.notify();
|
update.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IncompleteRegionException ignore){}
|
} catch (IncompleteRegionException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +28,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract {@link IChunk} class that implements basic get/set blocks
|
* An abstract {@link IChunk} class that implements basic get/set blocks.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||||
@ -812,7 +812,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the extent this chunk is in
|
* Get the extent this chunk is in.
|
||||||
*/
|
*/
|
||||||
public IQueueExtent<? extends IChunk> getExtent() {
|
public IQueueExtent<? extends IChunk> getExtent() {
|
||||||
return extent;
|
return extent;
|
||||||
@ -911,6 +911,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
|||||||
|
|
||||||
public interface IBlockDelegate {
|
public interface IBlockDelegate {
|
||||||
<C extends Future<C>> IChunkGet get(ChunkHolder<C> chunk);
|
<C extends Future<C>> IChunkGet get(ChunkHolder<C> chunk);
|
||||||
|
|
||||||
IChunkSet set(ChunkHolder chunk);
|
IChunkSet set(ChunkHolder chunk);
|
||||||
|
|
||||||
boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome);
|
boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome);
|
||||||
|
@ -54,11 +54,6 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
|||||||
return getFullBlock().toBlockState();
|
return getFullBlock().toBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlock(BlockState state) {
|
|
||||||
setFullBlock(state.toBaseBlock(getBlock().getNbtData()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
return getFullBlock().getNbtData();
|
return getFullBlock().getNbtData();
|
||||||
@ -79,6 +74,11 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
|||||||
return BlockVector3.at(getX(), getY(), getZ());
|
return BlockVector3.at(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(BlockState state) {
|
||||||
|
setFullBlock(state.toBaseBlock(getBlock().getNbtData()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
@ -16,8 +16,11 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
|||||||
private final char[] blocks;
|
private final char[] blocks;
|
||||||
private final byte[] heights;
|
private final byte[] heights;
|
||||||
private final int yOffset;
|
private final int yOffset;
|
||||||
private final int width, length;
|
private final int width;
|
||||||
private int x, z, index;
|
private final int length;
|
||||||
|
private int x;
|
||||||
|
private int z;
|
||||||
|
private int index;
|
||||||
|
|
||||||
public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length,
|
public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length,
|
||||||
int yOffset) {
|
int yOffset) {
|
||||||
@ -51,11 +54,6 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
|||||||
return BlockTypesCache.states[getOrdinal()];
|
return BlockTypesCache.states[getOrdinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlock(BlockState state) {
|
|
||||||
blocks[index] = state.getOrdinalChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock() {
|
public BaseBlock getFullBlock() {
|
||||||
return getBlock().toBaseBlock();
|
return getBlock().toBaseBlock();
|
||||||
@ -90,6 +88,11 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
|||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(BlockState state) {
|
||||||
|
blocks[index] = state.getOrdinalChar();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
@ -34,10 +34,20 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
private CharGetBlocks get;
|
private CharGetBlocks get;
|
||||||
private IChunkSet set;
|
private IChunkSet set;
|
||||||
private char[] getArr;
|
private char[] getArr;
|
||||||
private @Nullable char[] setArr;
|
@Nullable
|
||||||
|
private char[] setArr;
|
||||||
private SetDelegate delegate;
|
private SetDelegate delegate;
|
||||||
// local
|
// local
|
||||||
private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ;
|
private int layer;
|
||||||
|
private int index;
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
private int xx;
|
||||||
|
private int yy;
|
||||||
|
private int zz;
|
||||||
|
private int chunkX;
|
||||||
|
private int chunkZ;
|
||||||
|
|
||||||
public CharFilterBlock(Extent extent) {
|
public CharFilterBlock(Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
@ -107,8 +117,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(Filter filter, int yStart, int yEnd) {
|
public void filter(Filter filter, int startY, int endY) {
|
||||||
for (y = yStart, index = yStart << 8; y <= yEnd; y++) {
|
for (y = startY, index = startY << 8; y <= endY; y++) {
|
||||||
for (z = 0; z < 16; z++) {
|
for (z = 0; z < 16; z++) {
|
||||||
for (x = 0; x < 16; x++, index++) {
|
for (x = 0; x < 16; x++, index++) {
|
||||||
filter.applyBlock(this);
|
filter.applyBlock(this);
|
||||||
|
@ -23,21 +23,12 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize with chunk coordinates
|
* Initialize with chunk coordinates. The layer must also be initialized.
|
||||||
* - The layer must also be initialized
|
|
||||||
* @param chunkX
|
|
||||||
* @param chunkZ
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public abstract ChunkFilterBlock initChunk(int chunkX, int chunkZ);
|
public abstract ChunkFilterBlock initChunk(int chunkX, int chunkZ);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a chunk layer
|
* Initialize a chunk layer. the Chunk coordinates need to be initialized first.
|
||||||
* - The chunk coordinates must also be initialized first
|
|
||||||
* @param iget
|
|
||||||
* @param iset
|
|
||||||
* @param layer
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public abstract ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer);
|
public abstract ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer);
|
||||||
|
|
||||||
@ -46,55 +37,33 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a single block
|
* Filter a single block.
|
||||||
* @param filter
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
* @param z
|
|
||||||
*/
|
*/
|
||||||
public abstract void filter(Filter filter, int x, int y, int z);
|
public abstract void filter(Filter filter, int x, int y, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a cuboid region
|
* Filter a cuboid region.
|
||||||
* @param filter
|
|
||||||
* @param minX
|
|
||||||
* @param minY
|
|
||||||
* @param minZ
|
|
||||||
* @param maxX
|
|
||||||
* @param maxY
|
|
||||||
* @param maxZ
|
|
||||||
*/
|
*/
|
||||||
public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY,
|
public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY,
|
||||||
int maxZ);
|
int maxZ);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter everything in the layer
|
* Filter everything in the layer.
|
||||||
* @param filter
|
|
||||||
*/
|
*/
|
||||||
public abstract void filter(Filter filter);
|
public abstract void filter(Filter filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter everything between y layers
|
* Filter everything between y layers.
|
||||||
* @param filter
|
|
||||||
* @param yStart
|
|
||||||
* @param yEnd
|
|
||||||
*/
|
*/
|
||||||
public abstract void filter(Filter filter, int yStart, int yEnd);
|
public abstract void filter(Filter filter, int startY, int endY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter with a region
|
* Filter with a region.
|
||||||
* @param filter
|
|
||||||
* @param region
|
|
||||||
*/
|
*/
|
||||||
public abstract void filter(Filter filter, Region region);
|
public abstract void filter(Filter filter, Region region);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter with a chunk object
|
* Filter with a chunk object.
|
||||||
* @param chunk
|
|
||||||
* @param get
|
|
||||||
* @param set
|
|
||||||
* @param filter
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter) {
|
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter) {
|
||||||
initChunk(chunk.getX(), chunk.getZ());
|
initChunk(chunk.getX(), chunk.getZ());
|
||||||
@ -108,14 +77,7 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a chunk with a region / filter
|
* Filter a chunk with a region / filter.
|
||||||
* @param chunk
|
|
||||||
* @param get
|
|
||||||
* @param set
|
|
||||||
* @param filter
|
|
||||||
* @param region
|
|
||||||
* @param full
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter, Region region, boolean full) {
|
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter, Region region, boolean full) {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
|
@ -4,7 +4,9 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
|
|
||||||
public class SingleFilterBlock extends AbstractSingleFilterBlock {
|
public class SingleFilterBlock extends AbstractSingleFilterBlock {
|
||||||
|
|
||||||
private int x, y, z;
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
|
||||||
public SingleFilterBlock init(int x, int y, int z, BaseBlock block) {
|
public SingleFilterBlock init(int x, int y, int z, BaseBlock block) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -281,7 +282,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
int lightLevel = iChunk.getEmmittedLight(node.getX() & 15, node.getY(), node.getZ() & 15);
|
int lightLevel = iChunk.getEmmittedLight(node.getX() & 15, node.getY(), node.getZ() & 15);
|
||||||
BlockState state = this.queue.getBlock(node.getX(), node.getY(), node.getZ());
|
BlockState state = this.queue.getBlock(node.getX(), node.getY(), node.getZ());
|
||||||
String id = state.getBlockType().getId().toLowerCase();
|
String id = state.getBlockType().getId().toLowerCase(Locale.ROOT);
|
||||||
if (lightLevel <= 1) {
|
if (lightLevel <= 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -319,7 +320,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break east;
|
break east;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited);
|
||||||
break east;
|
break east;
|
||||||
}
|
}
|
||||||
@ -370,7 +371,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break west;
|
break west;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited);
|
||||||
break west;
|
break west;
|
||||||
}
|
}
|
||||||
@ -421,7 +422,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break south;
|
break south;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited);
|
||||||
break south;
|
break south;
|
||||||
}
|
}
|
||||||
@ -472,7 +473,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break north;
|
break north;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited);
|
||||||
break north;
|
break north;
|
||||||
}
|
}
|
||||||
@ -611,7 +612,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairNorth(BlockState state) {
|
private boolean checkStairNorth(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -629,7 +630,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairSouth(BlockState state) {
|
private boolean checkStairSouth(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -647,7 +648,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairEast(BlockState state) {
|
private boolean checkStairEast(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -665,7 +666,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairWest(BlockState state) {
|
private boolean checkStairWest(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -687,7 +688,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getStairShape(BlockState state) {
|
private String getStairShape(BlockState state) {
|
||||||
return state.getState(stairShape).toLowerCase();
|
return state.getState(stairShape).toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStairOrTrueTop(BlockState state, boolean top) {
|
private boolean isStairOrTrueTop(BlockState state, boolean top) {
|
||||||
@ -784,8 +785,9 @@ public class NMSRelighter implements Relighter {
|
|||||||
|
|
||||||
public void fixBlockLighting() {
|
public void fixBlockLighting() {
|
||||||
synchronized (lightQueue) {
|
synchronized (lightQueue) {
|
||||||
while (!lightLock.compareAndSet(false, true))
|
while (!lightLock.compareAndSet(false, true)) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
updateBlockLight(this.lightQueue);
|
updateBlockLight(this.lightQueue);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.beta.implementation.lighting;
|
|||||||
public interface Relighter {
|
public interface Relighter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a chunk to be relit when {@link Relighter#removeLighting} etc are called
|
* Add a chunk to be relit when {@link Relighter#removeLighting} etc are called.
|
||||||
*
|
*
|
||||||
* @param cx chunk x
|
* @param cx chunk x
|
||||||
* @param cz chunk z
|
* @param cz chunk z
|
||||||
@ -14,7 +14,7 @@ public interface Relighter {
|
|||||||
boolean addChunk(int cx, int cz, byte[] skipReason, int bitmask);
|
boolean addChunk(int cx, int cz, byte[] skipReason, int bitmask);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a block to be relit
|
* Add a block to be relit.
|
||||||
*
|
*
|
||||||
* @param x block x
|
* @param x block x
|
||||||
* @param y block y
|
* @param y block y
|
||||||
@ -23,14 +23,14 @@ public interface Relighter {
|
|||||||
void addLightUpdate(int x, int y, int z);
|
void addLightUpdate(int x, int y, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safely? Fix block lighting
|
* Safely? Fix block lighting.
|
||||||
*
|
*
|
||||||
* @param sky whether to also relight sky light values
|
* @param sky whether to also relight sky light values
|
||||||
*/
|
*/
|
||||||
void fixLightingSafe(boolean sky);
|
void fixLightingSafe(boolean sky);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove lighting and then relight safely
|
* Remove lighting and then relight safely.
|
||||||
*
|
*
|
||||||
* @param sky whether to also relight sky light values
|
* @param sky whether to also relight sky light values
|
||||||
*/
|
*/
|
||||||
@ -40,33 +40,33 @@ public interface Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all chunks and blocks to be relit
|
* Clear all chunks and blocks to be relit.
|
||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all block and sky light values (set to 0 light) in all chunks added to relighter
|
* Remove all block and sky light values (set to 0 light) in all chunks added to relighter.
|
||||||
*/
|
*/
|
||||||
void removeLighting();
|
void removeLighting();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix block light values in all chunks added to relighter
|
* Fix block light values in all chunks added to relighter.
|
||||||
*/
|
*/
|
||||||
void fixBlockLighting();
|
void fixBlockLighting();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix sky light values in all chunks added to relighter
|
* Fix sky light values in all chunks added to relighter.
|
||||||
*/
|
*/
|
||||||
void fixSkyLighting();
|
void fixSkyLighting();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are there any block or chunk added to be relit
|
* Are there any block or chunk added to be relit.
|
||||||
*
|
*
|
||||||
* @return is the relight stuff to be relit empty
|
* @return is the relight stuff to be relit empty
|
||||||
*/
|
*/
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
|
|
||||||
public static class SkipReason {
|
class SkipReason {
|
||||||
public static final byte NONE = 0;
|
public static final byte NONE = 0;
|
||||||
public static final byte AIR = 1;
|
public static final byte AIR = 1;
|
||||||
public static final byte SOLID = 2;
|
public static final byte SOLID = 2;
|
||||||
|
@ -573,7 +573,9 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
if (block.hasNbtData()) limit.MAX_BLOCKSTATES();
|
if (block.hasNbtData()) {
|
||||||
|
limit.MAX_BLOCKSTATES();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return super.setBlock(position, block);
|
return super.setBlock(position, block);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -587,7 +589,9 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
if (block.hasNbtData()) limit.MAX_BLOCKSTATES();
|
if (block.hasNbtData()) {
|
||||||
|
limit.MAX_BLOCKSTATES();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return super.setBlock(x, y, z, block);
|
return super.setBlock(x, y, z, block);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
|
@ -154,7 +154,9 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
for (IBatchProcessor processor : this.processors) processor.flush();
|
for (IBatchProcessor processor : this.processors) {
|
||||||
|
processor.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,7 +44,9 @@ public class PersistentChunkSendProcessor extends ChunkSendProcessor {
|
|||||||
current.put(pair, (Character) bitMask);
|
current.put(pair, (Character) bitMask);
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
Character lastValue = previous.remove(pair);
|
Character lastValue = previous.remove(pair);
|
||||||
if (lastValue != null) bitMask |= lastValue;
|
if (lastValue != null) {
|
||||||
|
bitMask |= lastValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new CombinedBlocks(get, set, bitMask);
|
return new CombinedBlocks(get, set, bitMask);
|
||||||
@ -56,7 +58,9 @@ public class PersistentChunkSendProcessor extends ChunkSendProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if (queue == null) throw new IllegalStateException("Queue is not provided");
|
if (queue == null) {
|
||||||
|
throw new IllegalStateException("Queue is not provided");
|
||||||
|
}
|
||||||
clear(current);
|
clear(current);
|
||||||
current.clear();
|
current.clear();
|
||||||
queue = null;
|
queue = null;
|
||||||
|
@ -106,7 +106,8 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Get the next chunk posWeakChunk
|
// Get the next chunk posWeakChunk
|
||||||
final int chunkX, chunkZ;
|
final int chunkX;
|
||||||
|
final int chunkZ;
|
||||||
synchronized (chunksIter) {
|
synchronized (chunksIter) {
|
||||||
if (!chunksIter.hasNext()) {
|
if (!chunksIter.hasNext()) {
|
||||||
break;
|
break;
|
||||||
|
@ -21,7 +21,9 @@ public class QueuePool<T> extends ConcurrentLinkedQueue<T> implements Pool<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if (!isEmpty()) super.clear();
|
if (!isEmpty()) {
|
||||||
|
super.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
* Resets the queue.
|
* Resets the queue.
|
||||||
*/
|
*/
|
||||||
protected synchronized void reset() {
|
protected synchronized void reset() {
|
||||||
if (!this.initialized) return;
|
if (!this.initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.chunks.isEmpty()) {
|
if (!this.chunks.isEmpty()) {
|
||||||
for (IChunk chunk : this.chunks.values()) {
|
for (IChunk chunk : this.chunks.values()) {
|
||||||
chunk.recycle();
|
chunk.recycle();
|
||||||
@ -285,7 +287,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
while (!submissions.isEmpty()) {
|
while (!submissions.isEmpty()) {
|
||||||
Future future = submissions.poll();
|
Future future = submissions.poll();
|
||||||
try {
|
try {
|
||||||
while (future != null) future = (Future) future.get();
|
while (future != null) {
|
||||||
|
future = (Future) future.get();
|
||||||
|
}
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -294,7 +298,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
for (int i = 0; i < overflow; i++) {
|
for (int i = 0; i < overflow; i++) {
|
||||||
Future first = submissions.poll();
|
Future first = submissions.poll();
|
||||||
try {
|
try {
|
||||||
while (first != null) first = (Future) first.get();
|
while (first != null) {
|
||||||
|
first = (Future) first.get();
|
||||||
|
}
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -158,13 +158,15 @@ public class AnvilCommands {
|
|||||||
name = "deleteallunvisited",
|
name = "deleteallunvisited",
|
||||||
aliases = {"delunvisited" },
|
aliases = {"delunvisited" },
|
||||||
desc = "Delete all chunks which haven't been occupied",
|
desc = "Delete all chunks which haven't been occupied",
|
||||||
descFooter = "occupied for `age-ticks` (20t = 1s) and \n" +
|
descFooter = "occupied for `age-ticks` (20t = 1s) and \n"
|
||||||
"Have not been accessed since `file-duration` (ms) after creation and\n" +
|
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
|
||||||
"Have not been used in the past `chunk-inactivity` (ms)" +
|
+ "Have not been used in the past `chunk-inactivity` (ms)"
|
||||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.deleteallunvisited")
|
@CommandPermissions("worldedit.anvil.deleteallunvisited")
|
||||||
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Arg(desc = "int", def = "60000") int fileDurationMillis) throws WorldEditException {
|
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks,
|
||||||
|
@Arg(desc = "int", def = "60000")
|
||||||
|
int fileDurationMillis) throws WorldEditException {
|
||||||
// DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
|
// DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
|
||||||
// DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
|
// DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
|
||||||
// if (result != null) {
|
// if (result != null) {
|
||||||
@ -176,14 +178,18 @@ public class AnvilCommands {
|
|||||||
name = "deleteallunclaimed",
|
name = "deleteallunclaimed",
|
||||||
aliases = {"delallunclaimed" },
|
aliases = {"delallunclaimed" },
|
||||||
desc = "Delete all chunks which haven't been occupied",
|
desc = "Delete all chunks which haven't been occupied",
|
||||||
descFooter = "Supports: WG, P2, GP:\n" +
|
descFooter = "Supports: WorldGuard, PlotSquared, GriefPrevention:\n"
|
||||||
"Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" +
|
+ "Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n"
|
||||||
"Have not been accessed since `file-duration` (ms) after creation and\n" +
|
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
|
||||||
"Have not been used in the past `chunk-inactivity` (ms)" +
|
+ "Have not been used in the past `chunk-inactivity` (ms)"
|
||||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
|
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
|
||||||
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Arg(desc = "int", def = "60000") int fileDurationMillis, @Switch(name = 'd', desc = "TODO") boolean debug) throws WorldEditException {
|
public void deleteAllUnclaimed(Player player, int inhabitedTicks,
|
||||||
|
@Arg(desc = "int", def = "60000")
|
||||||
|
int fileDurationMillis,
|
||||||
|
@Switch(name = 'd', desc = "The flag will debug the task")
|
||||||
|
boolean debug) throws WorldEditException {
|
||||||
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
|
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
|
||||||
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
// if (debug) {
|
// if (debug) {
|
||||||
@ -198,15 +204,19 @@ public class AnvilCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
name = "deleteunclaimed",
|
name = "deleteunclaimed",
|
||||||
desc = "Delete all chunks which haven't been occupied",
|
desc = "Delete all chunks which haven't been occupied",
|
||||||
descFooter = "(Supports: WG, P2, GP):\n" +
|
descFooter = "(Supports: WorldGuard, PlotSquared, GriefPrevention):\n"
|
||||||
"Is not claimed\n" +
|
+ "Is not claimed\n"
|
||||||
"Has not been occupied for `age-ticks` (20t = 1s) and \n" +
|
+ "Has not been occupied for `age-ticks` (20t = 1s) and \n"
|
||||||
"Have not been accessed since `file-duration` (ms) after creation and\n" +
|
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
|
||||||
"Have not been used in the past `chunk-inactivity` (ms)" +
|
+ "Have not been used in the past `chunk-inactivity` (ms)"
|
||||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.deleteunclaimed")
|
@CommandPermissions("worldedit.anvil.deleteunclaimed")
|
||||||
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Arg(desc = "int", def = "60000") int fileDurationMillis, @Switch(name = 'd', desc = "TODO") boolean debug) throws WorldEditException {
|
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks,
|
||||||
|
@Arg(desc = "int", def = "60000")
|
||||||
|
int fileDurationMillis,
|
||||||
|
@Switch(name = 'd', desc = "The flag will debug the task")
|
||||||
|
boolean debug) throws WorldEditException {
|
||||||
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
|
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
|
||||||
// if (debug) {
|
// if (debug) {
|
||||||
// filter.enableDebug();
|
// filter.enableDebug();
|
||||||
@ -221,8 +231,8 @@ public class AnvilCommands {
|
|||||||
name = "deletealloldregions",
|
name = "deletealloldregions",
|
||||||
aliases = {"deloldreg" },
|
aliases = {"deloldreg" },
|
||||||
desc = "Delete regions which haven't been accessed in a certain amount of time",
|
desc = "Delete regions which haven't been accessed in a certain amount of time",
|
||||||
descFooter = "You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n" +
|
descFooter = "You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n"
|
||||||
"(months are not a unit of time) e.g., 8h5m12s\n"
|
+ "(months are not a unit of time) e.g., 8h5m12s\n"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.deletealloldregions")
|
@CommandPermissions("worldedit.anvil.deletealloldregions")
|
||||||
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
|
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
|
||||||
@ -236,12 +246,13 @@ public class AnvilCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "trimallplots",
|
name = "trimallplots",
|
||||||
|
|
||||||
desc = "Trim chunks in a Plot World",
|
desc = "Trim chunks in a Plot World",
|
||||||
descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n"
|
descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.trimallplots")
|
@CommandPermissions("worldedit.anvil.trimallplots")
|
||||||
public void trimAllPlots(Player player, @Switch(name = 'v', desc = "Delete unvisited chunks") boolean deleteUnvisited) throws WorldEditException {
|
public void trimAllPlots(Player player,
|
||||||
|
@Switch(name = 'v', desc = "Delete unvisited chunks")
|
||||||
|
boolean deleteUnvisited) throws WorldEditException {
|
||||||
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
|
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
|
||||||
// int visitTime = deleteUnvisited ? 1 : -1;
|
// int visitTime = deleteUnvisited ? 1 : -1;
|
||||||
// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
|
// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
|
||||||
@ -259,7 +270,9 @@ public class AnvilCommands {
|
|||||||
desc = "Delete chunks matching a specific biome"
|
desc = "Delete chunks matching a specific biome"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.trimallair")
|
@CommandPermissions("worldedit.anvil.trimallair")
|
||||||
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch(name = 'u', desc = "TODO") boolean unsafe) {
|
public void deleteBiome(Player player, String folder, BiomeType biome,
|
||||||
|
@Switch(name = 'u', desc = "The flag will run the task unsafe")
|
||||||
|
boolean unsafe) {
|
||||||
// DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED
|
// DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED
|
||||||
// DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
// DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
||||||
// if (result != null) {
|
// if (result != null) {
|
||||||
@ -272,7 +285,9 @@ public class AnvilCommands {
|
|||||||
desc = "Trim all air in the world"
|
desc = "Trim all air in the world"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.trimallair")
|
@CommandPermissions("worldedit.anvil.trimallair")
|
||||||
public void trimAllAir(Player player, String folder, @Switch(name = 'u', desc = "TODO") boolean unsafe) throws WorldEditException {
|
public void trimAllAir(Player player, String folder,
|
||||||
|
@Switch(name = 'u', desc = "The flag will run the task unsafe")
|
||||||
|
boolean unsafe) throws WorldEditException {
|
||||||
// TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED
|
// TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED
|
||||||
// TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
// TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
||||||
// if (result != null) {
|
// if (result != null) {
|
||||||
@ -282,7 +297,6 @@ public class AnvilCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "debugfixroads",
|
name = "debugfixroads",
|
||||||
|
|
||||||
desc = "debug - do not use"
|
desc = "debug - do not use"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.debugfixroads")
|
@CommandPermissions("worldedit.anvil.debugfixroads")
|
||||||
@ -300,7 +314,13 @@ public class AnvilCommands {
|
|||||||
desc = "Replace all blocks in the selection with another"
|
desc = "Replace all blocks in the selection with another"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replaceall")
|
@CommandPermissions("worldedit.anvil.replaceall")
|
||||||
public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException {
|
public void replaceAllPattern(Player player, String folder,
|
||||||
|
@Arg(desc = "String", def = "")
|
||||||
|
String from, Pattern toPattern,
|
||||||
|
@Switch(name = 'd', desc = "The flag specifies the data to use")
|
||||||
|
boolean useData,
|
||||||
|
@Switch(name = 'm', desc = "The flag specifies the map to use")
|
||||||
|
boolean useMap) throws WorldEditException {
|
||||||
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
|
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
|
||||||
// if (useMap) {
|
// if (useMap) {
|
||||||
// if (to instanceof RandomPattern) {
|
// if (to instanceof RandomPattern) {
|
||||||
@ -329,7 +349,9 @@ public class AnvilCommands {
|
|||||||
desc = "Count all blocks in a world"
|
desc = "Count all blocks in a world"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.countall")
|
@CommandPermissions("worldedit.anvil.countall")
|
||||||
public void countAll(Player player, EditSession editSession, String folder, String argStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException {
|
public void countAll(Player player, EditSession editSession, String folder, String argStr,
|
||||||
|
@Switch(name = 'd', desc = "The flag specifies the data to use")
|
||||||
|
boolean useData) throws WorldEditException {
|
||||||
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true);
|
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true);
|
||||||
// MCAFilterCounter filter;
|
// MCAFilterCounter filter;
|
||||||
// if (useData || arg.contains(":")) { // Optimize for both cases
|
// if (useData || arg.contains(":")) { // Optimize for both cases
|
||||||
@ -403,7 +425,9 @@ public class AnvilCommands {
|
|||||||
desc = "Count blocks in a selection"
|
desc = "Count blocks in a selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.count")
|
@CommandPermissions("worldedit.anvil.count")
|
||||||
public void count(Player player, EditSession editSession, @Selection Region selection, String argStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException {
|
public void count(Player player, EditSession editSession, @Selection Region selection, String argStr,
|
||||||
|
@Switch(name = 'd', desc = "The flag specifies the data to use")
|
||||||
|
boolean useData) throws WorldEditException {
|
||||||
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED
|
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED
|
||||||
// MCAFilterCounter filter;
|
// MCAFilterCounter filter;
|
||||||
// if (useData || arg.contains(":")) { // Optimize for both cases
|
// if (useData || arg.contains(":")) { // Optimize for both cases
|
||||||
@ -425,7 +449,9 @@ public class AnvilCommands {
|
|||||||
desc = "Replace all blocks in the selection with another"
|
desc = "Replace all blocks in the selection with another"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.distr")
|
@CommandPermissions("worldedit.anvil.distr")
|
||||||
public void distr(Player player, EditSession editSession, @Selection Region selection, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException {
|
public void distr(Player player, EditSession editSession, @Selection Region selection,
|
||||||
|
@Switch(name = 'd', desc = "The flag specifies the data to use")
|
||||||
|
boolean useData) throws WorldEditException {
|
||||||
// long total = 0; TODO NOT IMPLEMENTED
|
// long total = 0; TODO NOT IMPLEMENTED
|
||||||
// long[] count;
|
// long[] count;
|
||||||
// MCAFilter<long[]> counts;
|
// MCAFilter<long[]> counts;
|
||||||
@ -504,7 +530,11 @@ public class AnvilCommands {
|
|||||||
desc = "Replace all blocks in the selection with another"
|
desc = "Replace all blocks in the selection with another"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replace")
|
@CommandPermissions("worldedit.anvil.replace")
|
||||||
public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String toStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException {
|
public void replace(Player player, EditSession editSession, @Selection Region selection,
|
||||||
|
@Arg(desc = "String", def = "")
|
||||||
|
String from, String toStr,
|
||||||
|
@Switch(name = 'd', desc = "The flag specifies the data to use")
|
||||||
|
boolean useData) throws WorldEditException {
|
||||||
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
|
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
|
||||||
// if (from == null) {
|
// if (from == null) {
|
||||||
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
||||||
@ -526,7 +556,13 @@ public class AnvilCommands {
|
|||||||
desc = "Replace all blocks in the selection with a pattern"
|
desc = "Replace all blocks in the selection with a pattern"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replace")
|
@CommandPermissions("worldedit.anvil.replace")
|
||||||
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException {
|
public void replacePattern(Player player, EditSession editSession, @Selection Region selection,
|
||||||
|
@Arg(desc = "String", def = "")
|
||||||
|
String from, final Pattern toPattern,
|
||||||
|
@Switch(name = 'd', desc = "The flag specifies the data to use")
|
||||||
|
boolean useData,
|
||||||
|
@Switch(name = 'm', desc = "The flag specifies the map to use")
|
||||||
|
boolean useMap) throws WorldEditException {
|
||||||
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
|
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
|
||||||
// if (useMap) {
|
// if (useMap) {
|
||||||
// if (to instanceof RandomPattern) {
|
// if (to instanceof RandomPattern) {
|
||||||
@ -556,7 +592,7 @@ public class AnvilCommands {
|
|||||||
desc = "Set all blocks in the selection with a pattern"
|
desc = "Set all blocks in the selection with a pattern"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.set")
|
@CommandPermissions("worldedit.anvil.set")
|
||||||
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap
|
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "The flag specifies the data to use") boolean useData, @Switch(name = 'm', desc = "The flag specifies the map to use") boolean useMap
|
||||||
public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws WorldEditException {
|
public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws WorldEditException {
|
||||||
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
|
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
|
||||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||||
@ -608,11 +644,12 @@ public class AnvilCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
name = "paste",
|
name = "paste",
|
||||||
desc = "Paste chunks from your anvil clipboard",
|
desc = "Paste chunks from your anvil clipboard",
|
||||||
descFooter = "Paste the chunks from your anvil clipboard.\n" +
|
descFooter = "Paste the chunks from your anvil clipboard."
|
||||||
"The -c flag will align the paste to the chunks."
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.pastechunks")
|
@CommandPermissions("worldedit.anvil.pastechunks")
|
||||||
public void paste(Player player, LocalSession session, EditSession editSession, @Switch(name = 'c', desc = "TODO") boolean alignChunk) throws WorldEditException, IOException {
|
public void paste(Player player, LocalSession session, EditSession editSession,
|
||||||
|
@Switch(name = 'c', desc = "Align to chunks")
|
||||||
|
boolean alignChunk) throws WorldEditException, IOException {
|
||||||
// FawePlayer fp = FawePlayer.wrap(player); TODO NOT IMPLEMENTED
|
// FawePlayer fp = FawePlayer.wrap(player); TODO NOT IMPLEMENTED
|
||||||
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
||||||
// if (clipboard == null) {
|
// if (clipboard == null) {
|
||||||
|
@ -422,7 +422,7 @@
|
|||||||
// Request.request().setExtent(generator);
|
// Request.request().setExtent(generator);
|
||||||
//
|
//
|
||||||
// Set<BlockType> blocks;
|
// Set<BlockType> blocks;
|
||||||
// switch (argOpt.toLowerCase()) {
|
// switch (argOpt.toLowerCase(Locale.ROOT)) {
|
||||||
// case "true":
|
// case "true":
|
||||||
// case "*": {
|
// case "*": {
|
||||||
// generator.setTextureUtil(Fawe.get().getTextureUtil());
|
// generator.setTextureUtil(Fawe.get().getTextureUtil());
|
||||||
@ -819,7 +819,7 @@
|
|||||||
// TextComponent.of("/cfi randomization " + !rand)));
|
// TextComponent.of("/cfi randomization " + !rand)));
|
||||||
// @NotNull Builder builder = TextComponent.builder(">> Current Settings <<");
|
// @NotNull Builder builder = TextComponent.builder(">> Current Settings <<");
|
||||||
// builder.append(newline());
|
// builder.append(newline());
|
||||||
// builder.append(TextComponent.of("Randomization [" + Boolean.toString(rand).toUpperCase() + "]")
|
// builder.append(TextComponent.of("Randomization [" + Boolean.toString(rand).toUpperCase(Locale.ROOT) + "]")
|
||||||
// .clickEvent(ClickEvent.runCommand(
|
// .clickEvent(ClickEvent.runCommand(
|
||||||
// "/cfi randomization " + !rand)).hoverEvent(HoverEvent.showText(
|
// "/cfi randomization " + !rand)).hoverEvent(HoverEvent.showText(
|
||||||
// TextComponent.of("/cfi randomization " + !rand))));
|
// TextComponent.of("/cfi randomization " + !rand))));
|
||||||
|
@ -20,12 +20,16 @@ public class SuggestInputParseException extends InputParseException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SuggestInputParseException of(Throwable other, String prefix, Supplier<List<String>> getSuggestions) {
|
public static SuggestInputParseException of(Throwable other, String prefix, Supplier<List<String>> getSuggestions) {
|
||||||
if (other instanceof InputParseException) return of((InputParseException) other, prefix, getSuggestions);
|
if (other instanceof InputParseException) {
|
||||||
|
return of((InputParseException) other, prefix, getSuggestions);
|
||||||
|
}
|
||||||
return of(new InputParseException(other.getMessage()), prefix, getSuggestions);
|
return of(new InputParseException(other.getMessage()), prefix, getSuggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SuggestInputParseException of(InputParseException other, String prefix, Supplier<List<String>> getSuggestions) {
|
public static SuggestInputParseException of(InputParseException other, String prefix, Supplier<List<String>> getSuggestions) {
|
||||||
if (other instanceof SuggestInputParseException) return (SuggestInputParseException) other;
|
if (other instanceof SuggestInputParseException) {
|
||||||
|
return (SuggestInputParseException) other;
|
||||||
|
}
|
||||||
return new SuggestInputParseException(other, prefix, getSuggestions);
|
return new SuggestInputParseException(other, prefix, getSuggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +46,9 @@ public class SuggestInputParseException extends InputParseException {
|
|||||||
Throwable t = e;
|
Throwable t = e;
|
||||||
while (t.getCause() != null) {
|
while (t.getCause() != null) {
|
||||||
t = t.getCause();
|
t = t.getCause();
|
||||||
if (t instanceof SuggestInputParseException) return (SuggestInputParseException) t;
|
if (t instanceof SuggestInputParseException) {
|
||||||
|
return (SuggestInputParseException) t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,7 @@ public class Caption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colorize a component with legacy color codes
|
* Colorize a component with legacy color codes.
|
||||||
* @param component
|
|
||||||
* @param locale
|
|
||||||
* @return Component
|
|
||||||
*/
|
*/
|
||||||
public static Component color(Component component, Locale locale) {
|
public static Component color(Component component, Locale locale) {
|
||||||
return color(WorldEditText.format(component, locale));
|
return color(WorldEditText.format(component, locale));
|
||||||
|
@ -21,6 +21,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
@ -32,12 +33,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for a node<br>
|
* Get the value for a node. Probably throws some error if you try to get a non-existent key.
|
||||||
* Probably throws some error if you try to get a non existent key
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param <T>
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private <T> T get(String key, Class root) {
|
private <T> T get(String key, Class root) {
|
||||||
String[] split = key.split("\\.");
|
String[] split = key.split("\\.");
|
||||||
@ -57,8 +53,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of a specific node<br>
|
* Set the value of a specific node. Probably throws some error if you supply non existing keys or invalid values.
|
||||||
* Probably throws some error if you supply non existing keys or invalid values
|
|
||||||
*
|
*
|
||||||
* @param key config node
|
* @param key config node
|
||||||
* @param value value
|
* @param value value
|
||||||
@ -103,9 +98,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all values in the file (load first to avoid overwriting)
|
* Set all values in the file (load first to avoid overwriting).
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
*/
|
*/
|
||||||
public void save(File file) {
|
public void save(File file) {
|
||||||
Class<? extends Config> root = getClass();
|
Class<? extends Config> root = getClass();
|
||||||
@ -127,7 +120,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that a field should be instantiated / created
|
* Indicates that a field should be instantiated / created.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.FIELD})
|
@Target({ElementType.FIELD})
|
||||||
@ -135,7 +128,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that a field cannot be modified
|
* Indicates that a field cannot be modified.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.FIELD})
|
@Target({ElementType.FIELD})
|
||||||
@ -143,7 +136,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a comment
|
* Creates a comment.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||||
@ -152,7 +145,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The names of any default blocks
|
* The names of any default blocks.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||||
@ -161,7 +154,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any field or class with is not part of the config
|
* Any field or class with is not part of the config.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||||
@ -199,10 +192,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the static fields in a section
|
* Get the static fields in a section.
|
||||||
*
|
|
||||||
* @param clazz
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> getFields(Class clazz) {
|
private Map<String, Object> getFields(Class clazz) {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
@ -317,10 +307,9 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the field for a specific config node
|
* Get the field for a specific config node.
|
||||||
*
|
*
|
||||||
* @param split the node (split by period)
|
* @param split the node (split by period)
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private Field getField(String[] split, Class root) {
|
private Field getField(String[] split, Class root) {
|
||||||
Object instance = getInstance(split, root);
|
Object instance = getInstance(split, root);
|
||||||
@ -331,12 +320,12 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the field for a specific config node and instance<br>
|
* Get the field for a specific config node and instance.
|
||||||
* Note: As expiry can have multiple blocks there will be multiple instances
|
*
|
||||||
|
* @apiNote As expiry can have multiple blocks there will be multiple instances
|
||||||
*
|
*
|
||||||
* @param split the node (split by period)
|
* @param split the node (split by period)
|
||||||
* @param instance the instance
|
* @param instance the instance
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private Field getField(String[] split, Object instance) {
|
private Field getField(String[] split, Object instance) {
|
||||||
try {
|
try {
|
||||||
@ -352,13 +341,13 @@ public class Config {
|
|||||||
private Object getInstance(Object instance, Class clazz) throws IllegalAccessException, InstantiationException {
|
private Object getInstance(Object instance, Class clazz) throws IllegalAccessException, InstantiationException {
|
||||||
try {
|
try {
|
||||||
Field instanceField = clazz.getDeclaredField(clazz.getSimpleName());
|
Field instanceField = clazz.getDeclaredField(clazz.getSimpleName());
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
return clazz.newInstance();
|
return clazz.newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the instance for a specific config node
|
* Get the instance for a specific config node.
|
||||||
*
|
*
|
||||||
* @param split the node (split by period)
|
* @param split the node (split by period)
|
||||||
* @return The instance or null
|
* @return The instance or null
|
||||||
@ -407,7 +396,7 @@ public class Config {
|
|||||||
clazz = found;
|
clazz = found;
|
||||||
split = Arrays.copyOfRange(split, 2, split.length);
|
split = Arrays.copyOfRange(split, 2, split.length);
|
||||||
continue;
|
continue;
|
||||||
} catch (NoSuchFieldException ignore) {
|
} catch (NoSuchFieldException ignored) {
|
||||||
}
|
}
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
split = Arrays.copyOfRange(split, 1, split.length);
|
split = Arrays.copyOfRange(split, 1, split.length);
|
||||||
@ -425,31 +414,21 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a node to a java field name
|
* Translate a node to a java field name.
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private String toFieldName(String node) {
|
private String toFieldName(String node) {
|
||||||
return node.toUpperCase().replaceAll("-", "_");
|
return node.toUpperCase(Locale.ROOT).replaceAll("-", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a field to a config node
|
* Translate a field to a config node.
|
||||||
*
|
|
||||||
* @param field
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private String toNodeName(String field) {
|
private String toNodeName(String field) {
|
||||||
return field.toLowerCase().replace("_", "-");
|
return field.toLowerCase(Locale.ROOT).replace("_", "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set some field to be accessible
|
* Set some field to be accessible.
|
||||||
*
|
|
||||||
* @param field
|
|
||||||
* @throws NoSuchFieldException
|
|
||||||
* @throws IllegalAccessException
|
|
||||||
*/
|
*/
|
||||||
private void setAccessible(Field field) throws NoSuchFieldException, IllegalAccessException {
|
private void setAccessible(Field field) throws NoSuchFieldException, IllegalAccessException {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
@ -504,7 +504,9 @@ public class Settings extends Config {
|
|||||||
limit = new FaweLimit();
|
limit = new FaweLimit();
|
||||||
}
|
}
|
||||||
ArrayList<String> keys = new ArrayList<>(LIMITS.getSections());
|
ArrayList<String> keys = new ArrayList<>(LIMITS.getSections());
|
||||||
if (keys.remove("default")) keys.add("default");
|
if (keys.remove("default")) {
|
||||||
|
keys.add("default");
|
||||||
|
}
|
||||||
|
|
||||||
boolean limitFound = false;
|
boolean limitFound = false;
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
@ -524,13 +526,16 @@ public class Settings extends Config {
|
|||||||
limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
|
limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
|
||||||
limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;
|
limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;
|
||||||
limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE;
|
limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE;
|
||||||
if (limit.STRIP_NBT == null) limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT);
|
if (limit.STRIP_NBT == null) {
|
||||||
else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) {
|
limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT);
|
||||||
|
} else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) {
|
||||||
limit.STRIP_NBT = Collections.emptySet();
|
limit.STRIP_NBT = Collections.emptySet();
|
||||||
} else {
|
} else {
|
||||||
limit.STRIP_NBT = new HashSet<>(limit.STRIP_NBT);
|
limit.STRIP_NBT = new HashSet<>(limit.STRIP_NBT);
|
||||||
limit.STRIP_NBT.retainAll(newLimit.STRIP_NBT);
|
limit.STRIP_NBT.retainAll(newLimit.STRIP_NBT);
|
||||||
if (limit.STRIP_NBT.isEmpty()) limit.STRIP_NBT = Collections.emptySet();
|
if (limit.STRIP_NBT.isEmpty()) {
|
||||||
|
limit.STRIP_NBT = Collections.emptySet();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,21 @@ package com.boydti.fawe.configuration;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a source of configurable options and settings
|
* Represents a source of configurable options and settings.
|
||||||
*/
|
*/
|
||||||
public interface Configuration extends ConfigurationSection {
|
public interface Configuration extends ConfigurationSection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default value of the given path as provided.
|
* Sets the default value of the given path as provided.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If no source {@link Configuration} was provided as a default
|
* If no source {@link Configuration} was provided as a default collection, then a new {@link
|
||||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
* MemoryConfiguration} will be created to hold the new default value.
|
||||||
* hold the new default value.
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If value is null, the value will be removed from the default
|
* If value is null, the value will be removed from the default Configuration source.
|
||||||
* Configuration source.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the value to set.
|
* @param path Path of the value to set.
|
||||||
* @param value Value to set the default to.
|
* @param value Value to set the default to.
|
||||||
@ -25,10 +28,11 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default values of the given paths as provided.
|
* Sets the default values of the given paths as provided.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If no source {@link Configuration} was provided as a default
|
* If no source {@link Configuration} was provided as a default collection, then a new {@link
|
||||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
* MemoryConfiguration} will be created to hold the new default values.
|
||||||
* hold the new default values.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param defaults A map of Path->Values to add to defaults.
|
* @param defaults A map of Path->Values to add to defaults.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null.
|
* @throws IllegalArgumentException Thrown if defaults is null.
|
||||||
@ -37,15 +41,17 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default values of the given paths as provided.
|
* Sets the default values of the given paths as provided.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If no source {@link Configuration} was provided as a default
|
* If no source {@link Configuration} was provided as a default collection, then a new {@link
|
||||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
* MemoryConfiguration} will be created to hold the new default value.
|
||||||
* hold the new default value.
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will not hold a reference to the specified Configuration,
|
* This method will not hold a reference to the specified Configuration, nor will it
|
||||||
* nor will it automatically update if that Configuration ever changes. If
|
* automatically update if that Configuration ever changes. If you require this, you should set
|
||||||
* you require this, you should set the default source with {@link
|
* the default source with {@link #setDefaults(Configuration)}.
|
||||||
* #setDefaults(Configuration)}.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param defaults A configuration holding a list of defaults to copy.
|
* @param defaults A configuration holding a list of defaults to copy.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||||
@ -54,9 +60,11 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the source of all default values for this {@link Configuration}.
|
* Sets the source of all default values for this {@link Configuration}.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If a previous source was set, or previous default values were defined,
|
* If a previous source was set, or previous default values were defined, then they will not be
|
||||||
* then they will not be copied to the new source.
|
* copied to the new source.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param defaults New source of default values for this configuration.
|
* @param defaults New source of default values for this configuration.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||||
@ -65,10 +73,12 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the source {@link Configuration} for this configuration.
|
* Gets the source {@link Configuration} for this configuration.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If no configuration source was set, but default values were added, then
|
* If no configuration source was set, but default values were added, then a {@link
|
||||||
* a {@link MemoryConfiguration} will be returned. If no source was set
|
* MemoryConfiguration} will be returned. If no source was set and no defaults were set, then
|
||||||
* and no defaults were set, then this method will return null.
|
* this method will return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Configuration source for default values, or null if none exist.
|
* @return Configuration source for default values, or null if none exist.
|
||||||
*/
|
*/
|
||||||
@ -76,8 +86,10 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* All setters through this method are chainable.
|
* All setters through this method are chainable.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Options for this configuration
|
* @return Options for this configuration
|
||||||
*/
|
*/
|
||||||
|
@ -5,130 +5,149 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a section of a {@link com.boydti.fawe.configuration.Configuration}
|
* Represents a section of a {@link Configuration}.
|
||||||
*/
|
*/
|
||||||
public interface ConfigurationSection {
|
public interface ConfigurationSection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set containing all keys in this section.
|
* Gets a set containing all keys in this section.
|
||||||
* <p>
|
|
||||||
* If deep is set to true, then this will contain all the keys within any
|
|
||||||
* child {@link com.boydti.fawe.configuration.ConfigurationSection}s (and their children, etc). These
|
|
||||||
* will be in a valid path notation for you to use.
|
|
||||||
* <p>
|
|
||||||
* If deep is set to false, then this will contain only the keys of any
|
|
||||||
* direct children, and not their own children.
|
|
||||||
*
|
*
|
||||||
* @param deep Whether or not to get a deep list, as opposed to a shallow
|
* <p>
|
||||||
* list.
|
* If deep is set to true, then this will contain all the keys within any child {@link
|
||||||
|
* ConfigurationSection}s (and their children, etc). These will be in a valid path notation for
|
||||||
|
* you to use.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* If deep is set to false, then this will contain only the keys of any direct children, and not
|
||||||
|
* their own children.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param deep Whether or not to get a deep list, as opposed to a shallow list.
|
||||||
* @return Set of keys contained within this ConfigurationSection.
|
* @return Set of keys contained within this ConfigurationSection.
|
||||||
*/
|
*/
|
||||||
Set<String> getKeys(boolean deep);
|
Set<String> getKeys(boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a Map containing all keys and their values for this section.
|
* Gets a Map containing all keys, and their values for this section.
|
||||||
* <p>
|
|
||||||
* If deep is set to true, then this will contain all the keys and values
|
|
||||||
* within any child {@link com.boydti.fawe.configuration.ConfigurationSection}s (and their children,
|
|
||||||
* etc). These keys will be in a valid path notation for you to use.
|
|
||||||
* <p>
|
|
||||||
* If deep is set to false, then this will contain only the keys and
|
|
||||||
* values of any direct children, and not their own children.
|
|
||||||
*
|
*
|
||||||
* @param deep Whether or not to get a deep list, as opposed to a shallow
|
* <p>
|
||||||
* list.
|
* If deep is set to true, then this will contain all the keys and values within any child
|
||||||
|
* {@link ConfigurationSection}s (and their children, etc). These keys will be in a valid path
|
||||||
|
* notation for you to use.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* If deep is set to false, then this will contain only the keys and values of any direct
|
||||||
|
* children, and not their own children.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param deep Whether or not to get a deep list, as opposed to a shallow list.
|
||||||
* @return Map of keys and values of this section.
|
* @return Map of keys and values of this section.
|
||||||
*/
|
*/
|
||||||
Map<String, Object> getValues(boolean deep);
|
Map<String, Object> getValues(boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this {@link com.boydti.fawe.configuration.ConfigurationSection} contains the given path.
|
* Checks if this {@link ConfigurationSection} contains the given path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the value for the requested path does not exist but a default value
|
* If the value for the requested path does not exist, but a default value has been specified,
|
||||||
* has been specified, this will return true.
|
* this will return true.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path to check for existence.
|
* @param path Path to check for existence.
|
||||||
* @return True if this section contains the requested path, either via
|
* @return True if this section contains the requested path, either via default or being set.
|
||||||
* default or being set.
|
|
||||||
* @throws IllegalArgumentException Thrown when path is null.
|
* @throws IllegalArgumentException Thrown when path is null.
|
||||||
*/
|
*/
|
||||||
boolean contains(String path);
|
boolean contains(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this {@link com.boydti.fawe.configuration.ConfigurationSection} has a value set for the
|
* Checks if this {@link ConfigurationSection} has a value set for the given path.
|
||||||
* given path.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the value for the requested path does not exist but a default value
|
* If the value for the requested path does not exist, but a default value has been specified,
|
||||||
* has been specified, this will still return false.
|
* this will still return false.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path to check for existence.
|
* @param path Path to check for existence.
|
||||||
* @return True if this section contains the requested path, regardless of
|
* @return True if this section contains the requested path, regardless of having a default.
|
||||||
* having a default.
|
|
||||||
* @throws IllegalArgumentException Thrown when path is null.
|
* @throws IllegalArgumentException Thrown when path is null.
|
||||||
*/
|
*/
|
||||||
boolean isSet(String path);
|
boolean isSet(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the path of this {@link com.boydti.fawe.configuration.ConfigurationSection} from its root {@link
|
* Gets the path of this {@link ConfigurationSection} from its root {@link Configuration}.
|
||||||
* com.boydti.fawe.configuration.Configuration}
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* For any {@link com.boydti.fawe.configuration.Configuration} themselves, this will return an empty
|
* For any {@link Configuration} themselves, this will return an empty string.
|
||||||
* string.
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the section is no longer contained within its root for any reason,
|
* If the section is no longer contained within its root for any reason, such as being replaced
|
||||||
* such as being replaced with a different value, this may return null.
|
* with a different value, this may return null.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* To retrieve the single name of this section, that is, the final part of
|
* To retrieve the single name of this section, that is, the final part of the path returned by
|
||||||
* the path returned by this method, you may use {@link #getName()}.
|
* this method, you may use {@link #getName()}.
|
||||||
|
*</p>
|
||||||
*
|
*
|
||||||
* @return Path of this section relative to its root
|
* @return Path of this section relative to its root
|
||||||
*/
|
*/
|
||||||
String getCurrentPath();
|
String getCurrentPath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of this individual {@link com.boydti.fawe.configuration.ConfigurationSection}, in the
|
* Gets the name of this individual {@link ConfigurationSection}, in the path.
|
||||||
* path.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This will always be the final part of {@link #getCurrentPath()}, unless
|
* This will always be the final part of {@link #getCurrentPath()}, unless the section is
|
||||||
* the section is orphaned.
|
* orphaned.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Name of this section
|
* @return Name of this section
|
||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the root {@link com.boydti.fawe.configuration.Configuration} that contains this {@link
|
* Gets the root {@link Configuration} that contains this {@link ConfigurationSection}.
|
||||||
* com.boydti.fawe.configuration.ConfigurationSection}
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* For any {@link com.boydti.fawe.configuration.Configuration} themselves, this will return its own
|
* For any {@link Configuration} themselves, this will return its own object.
|
||||||
* object.
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the section is no longer contained within its root for any reason,
|
* If the section is no longer contained within its root for any reason, such as being replaced
|
||||||
* such as being replaced with a different value, this may return null.
|
* with a different value, this may return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Root configuration containing this section.
|
* @return Root configuration containing this section.
|
||||||
*/
|
*/
|
||||||
Configuration getRoot();
|
Configuration getRoot();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the parent {@link com.boydti.fawe.configuration.ConfigurationSection} that directly contains
|
* Gets the parent {@link ConfigurationSection} that directly contains this {@link
|
||||||
* this {@link com.boydti.fawe.configuration.ConfigurationSection}.
|
* ConfigurationSection}.
|
||||||
* <p>
|
* <p>
|
||||||
* For any {@link com.boydti.fawe.configuration.Configuration} themselves, this will return null.
|
* For any {@link Configuration} themselves, this will return null.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the section is no longer contained within its parent for any reason,
|
* If the section is no longer contained within its parent for any reason, such as being
|
||||||
* such as being replaced with a different value, this may return null.
|
* replaced with a different value, this may return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Parent section containing this section.
|
* @return Parent section containing this section.
|
||||||
*/
|
*/
|
||||||
com.boydti.fawe.configuration.ConfigurationSection getParent();
|
ConfigurationSection getParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested Object by path.
|
* Gets the requested Object by path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the Object does not exist but a default value has been specified,
|
* If the Object does not exist, but a default value has been specified, this will return the
|
||||||
* this will return the default value. If the Object does not exist and no
|
* default value. If the Object does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return null.
|
* return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the Object to get.
|
* @param path Path of the Object to get.
|
||||||
* @return Requested Object.
|
* @return Requested Object.
|
||||||
@ -136,12 +155,12 @@ public interface ConfigurationSection {
|
|||||||
Object get(String path);
|
Object get(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested Object by path, returning a default value if not
|
* Gets the requested Object by a path, returning a default value if not found.
|
||||||
* found.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the Object does not exist then the specified default value will
|
* If the Object does not exist then the specified default value will return regardless of if a
|
||||||
* returned regardless of if a default has been identified in the root
|
* default has been identified in the root {@link Configuration}.
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the Object to get.
|
* @param path Path of the Object to get.
|
||||||
* @param def The default value to return if the path is not found.
|
* @param def The default value to return if the path is not found.
|
||||||
@ -151,14 +170,17 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the specified path to the given value.
|
* Sets the specified path to the given value.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If value is null, the entry will be removed. Any existing entry will be
|
* If value is null, the entry will be removed. Any existing entry will be replaced, regardless
|
||||||
* replaced, regardless of what the new value is.
|
* of what the new value is.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Some implementations may have limitations on what you may store. See
|
* Some implementations may have limitations on what you may store. See their individual javadoc
|
||||||
* their individual javadoc for details. No implementations should allow
|
* for details. No implementations should allow you to store {@link Configuration}s or {@link
|
||||||
* you to store {@link com.boydti.fawe.configuration.Configuration}s or {@link com.boydti.fawe.configuration.ConfigurationSection}s,
|
* ConfigurationSection}s, please use {@link #createSection(String)} for that.
|
||||||
* please use {@link #createSection(String)} for that.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the object to set.
|
* @param path Path of the object to set.
|
||||||
* @param value New value to set the path to.
|
* @param value New value to set the path to.
|
||||||
@ -166,39 +188,42 @@ public interface ConfigurationSection {
|
|||||||
void set(String path, Object value);
|
void set(String path, Object value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link com.boydti.fawe.configuration.ConfigurationSection} at the specified path.
|
* Creates an empty {@link ConfigurationSection} at the specified path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Any value that was previously set at this path will be overwritten. If
|
* Any value that was previously set at this path will be overwritten. If the previous value was
|
||||||
* the previous value was itself a {@link com.boydti.fawe.configuration.ConfigurationSection}, it will
|
* itself a {@link ConfigurationSection}, it will be orphaned.
|
||||||
* be orphaned.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path to create the section at.
|
* @param path Path to create the section at.
|
||||||
* @return Newly created section
|
* @return Newly created section
|
||||||
*/
|
*/
|
||||||
com.boydti.fawe.configuration.ConfigurationSection createSection(String path);
|
ConfigurationSection createSection(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link com.boydti.fawe.configuration.ConfigurationSection} at the specified path, with
|
* Creates a {@link ConfigurationSection} at the specified path, with specified values.
|
||||||
* specified values.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Any value that was previously set at this path will be overwritten. If
|
* Any value that was previously set at this path will be overwritten. If the previous value was
|
||||||
* the previous value was itself a {@link com.boydti.fawe.configuration.ConfigurationSection}, it will
|
* itself a {@link ConfigurationSection}, it will be orphaned.
|
||||||
* be orphaned.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path to create the section at.
|
* @param path Path to create the section at.
|
||||||
* @param map The values to used.
|
* @param map The values to used.
|
||||||
* @return Newly created section
|
* @return Newly created section
|
||||||
*/
|
*/
|
||||||
com.boydti.fawe.configuration.ConfigurationSection createSection(String path, Map<?, ?> map);
|
ConfigurationSection createSection(String path, Map<?, ?> map);
|
||||||
|
|
||||||
// Primitives
|
// Primitives
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested String by path.
|
* Gets the requested String by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the String does not exist but a default value has been specified,
|
* If the String does not exist, but a default value has been specified, this will return the
|
||||||
* this will return the default value. If the String does not exist and no
|
* default value. If the String does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return null.
|
* return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the String to get.
|
* @param path Path of the String to get.
|
||||||
* @return Requested String.
|
* @return Requested String.
|
||||||
@ -206,12 +231,14 @@ public interface ConfigurationSection {
|
|||||||
String getString(String path);
|
String getString(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested String by path, returning a default value if not
|
* Gets the requested String by a path, returning a default value if not
|
||||||
* found.
|
* found.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the String does not exist then the specified default value will
|
* If the String does not exist then the specified default value will
|
||||||
* returned regardless of if a default has been identified in the root
|
* return regardless of if a default has been identified in the root
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.
|
* {@link Configuration}.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the String to get.
|
* @param path Path of the String to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @param def The default value to return if the path is not found or is
|
||||||
@ -222,11 +249,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a String.
|
* Checks if the specified path is a String.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <p> If the path exists but is not a String, this will return false. If the
|
* If the path exists but is not a String, this will return false. If the path does not exist,
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* this will return false. If the path does not exist, but a default value has been specified,
|
||||||
* but a default value has been specified, this will check if that default
|
* this will check if that default value is a String and return appropriately.
|
||||||
* value is a String and return appropriately.</p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the String to check.
|
* @param path Path of the String to check.
|
||||||
* @return Whether or not the specified path is a String.
|
* @return Whether or not the specified path is a String.
|
||||||
@ -234,11 +262,13 @@ public interface ConfigurationSection {
|
|||||||
boolean isString(String path);
|
boolean isString(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested int by path.
|
* Gets the requested int by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <p>If the int does not exist but a default value has been specified, this
|
* If the int does not exist, but a default value has been specified, this
|
||||||
* will return the default value. If the int does not exist and no default
|
* will return the default value. If the int does not exist and no default
|
||||||
* value was specified, this will return 0.</p>
|
* value was specified, this will return 0.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the int to get.
|
* @param path Path of the int to get.
|
||||||
* @return Requested int.
|
* @return Requested int.
|
||||||
@ -246,26 +276,27 @@ public interface ConfigurationSection {
|
|||||||
int getInt(String path);
|
int getInt(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested int by path, returning a default value if not found.
|
* Gets the requested int by a path, returning a default value if not found.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <p>If the int does not exist then the specified default value will
|
* If the int does not exist then the specified default value will return regardless of if a
|
||||||
* returned regardless of if a default has been identified in the root
|
* default has been identified in the root {@link Configuration}.
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.</p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the int to get.
|
* @param path Path of the int to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @param def The default value to return if the path is not found or is not an int.
|
||||||
* not an int.
|
|
||||||
* @return Requested int.
|
* @return Requested int.
|
||||||
*/
|
*/
|
||||||
int getInt(String path, int def);
|
int getInt(String path, int def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is an int.
|
* Checks if the specified path is an int.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <p>If the path exists but is not a int, this will return false. If the
|
* If the path exists but is not an int, this will return false. If the path does not exist,
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* this will return false. If the path does not exist, but a default value has been specified,
|
||||||
* but a default value has been specified, this will check if that default
|
* this will check if that default value is an int and return appropriately
|
||||||
* value is a int and return appropriately.</p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the int to check.
|
* @param path Path of the int to check.
|
||||||
* @return Whether or not the specified path is an int.
|
* @return Whether or not the specified path is an int.
|
||||||
@ -273,11 +304,13 @@ public interface ConfigurationSection {
|
|||||||
boolean isInt(String path);
|
boolean isInt(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested boolean by path.
|
* Gets the requested boolean by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the boolean does not exist but a default value has been specified,
|
* If the boolean does not exist, but a default value has been specified, this will return the
|
||||||
* this will return the default value. If the boolean does not exist and
|
* default value. If the boolean does not exist and no default value was specified, this will
|
||||||
* no default value was specified, this will return false.
|
* return false.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the boolean to get.
|
* @param path Path of the boolean to get.
|
||||||
* @return Requested boolean.
|
* @return Requested boolean.
|
||||||
@ -285,27 +318,27 @@ public interface ConfigurationSection {
|
|||||||
boolean getBoolean(String path);
|
boolean getBoolean(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested boolean by path, returning a default value if not
|
* Gets the requested boolean by a path, returning a default value if not found.
|
||||||
* found.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the boolean does not exist then the specified default value will
|
* If the boolean does not exist then the specified default value will return regardless of if a
|
||||||
* returned regardless of if a default has been identified in the root
|
* default has been identified in the root {@link Configuration}.
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the boolean to get.
|
* @param path Path of the boolean to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @param def The default value to return if the path is not found or is not a boolean.
|
||||||
* not a boolean.
|
|
||||||
* @return Requested boolean.
|
* @return Requested boolean.
|
||||||
*/
|
*/
|
||||||
boolean getBoolean(String path, boolean def);
|
boolean getBoolean(String path, boolean def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a boolean.
|
* Checks if the specified path is a boolean.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the path exists but is not a boolean, this will return false. If the
|
* If the path exists but is not a boolean, this will return false. If the path does not exist,
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* this will return false. If the path does not exist, but a default value has been specified,
|
||||||
* but a default value has been specified, this will check if that default
|
* this will check if that default value is a boolean and return appropriately.
|
||||||
* value is a boolean and return appropriately.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the boolean to check.
|
* @param path Path of the boolean to check.
|
||||||
* @return Whether or not the specified path is a boolean.
|
* @return Whether or not the specified path is a boolean.
|
||||||
@ -313,11 +346,13 @@ public interface ConfigurationSection {
|
|||||||
boolean isBoolean(String path);
|
boolean isBoolean(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested double by path.
|
* Gets the requested double by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the double does not exist but a default value has been specified,
|
* If the double does not exist, but a default value has been specified, this will return the
|
||||||
* this will return the default value. If the double does not exist and no
|
* default value. If the double does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return 0.
|
* return 0.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the double to get.
|
* @param path Path of the double to get.
|
||||||
* @return Requested double.
|
* @return Requested double.
|
||||||
@ -325,27 +360,27 @@ public interface ConfigurationSection {
|
|||||||
double getDouble(String path);
|
double getDouble(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested double by path, returning a default value if not
|
* Gets the requested double by a path, returning a default value if not found.
|
||||||
* found.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the double does not exist then the specified default value will
|
* If the double does not exist then the specified default value will return regardless of if a
|
||||||
* returned regardless of if a default has been identified in the root
|
* default has been identified in the root {@link Configuration}.
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the double to get.
|
* @param path Path of the double to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @param def The default value to return if the path is not found or is not a double.
|
||||||
* not a double.
|
|
||||||
* @return Requested double.
|
* @return Requested double.
|
||||||
*/
|
*/
|
||||||
double getDouble(String path, double def);
|
double getDouble(String path, double def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a double.
|
* Checks if the specified path is a double.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the path exists but is not a double, this will return false. If the
|
* If the path exists but is not a double, this will return false. If the path does not exist,
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* this will return false. If the path does not exist, but a default value has been specified,
|
||||||
* but a default value has been specified, this will check if that default
|
* this will check if that default value is a double and return appropriately.
|
||||||
* value is a double and return appropriately.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the double to check.
|
* @param path Path of the double to check.
|
||||||
* @return Whether or not the specified path is a double.
|
* @return Whether or not the specified path is a double.
|
||||||
@ -353,11 +388,13 @@ public interface ConfigurationSection {
|
|||||||
boolean isDouble(String path);
|
boolean isDouble(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested long by path.
|
* Gets the requested long by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the long does not exist but a default value has been specified, this
|
* If the long does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the long does not exist and no
|
* default value. If the long does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return 0.
|
* return 0.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the long to get.
|
* @param path Path of the long to get.
|
||||||
* @return Requested long.
|
* @return Requested long.
|
||||||
@ -365,27 +402,27 @@ public interface ConfigurationSection {
|
|||||||
long getLong(String path);
|
long getLong(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested long by path, returning a default value if not
|
* Gets the requested long by a path, returning a default value if not found.
|
||||||
* found.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the long does not exist then the specified default value will
|
* If the long does not exist then the specified default value will return regardless of if a
|
||||||
* returned regardless of if a default has been identified in the root
|
* default has been identified in the root {@link Configuration}.
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the long to get.
|
* @param path Path of the long to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @param def The default value to return if the path is not found or is not a long.
|
||||||
* not a long.
|
|
||||||
* @return Requested long.
|
* @return Requested long.
|
||||||
*/
|
*/
|
||||||
long getLong(String path, long def);
|
long getLong(String path, long def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a long.
|
* Checks if the specified path is a long.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the path exists but is not a long, this will return false. If the
|
* If the path exists but is not a long, this will return false. If the path does not exist,
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* this will return false. If the path does not exist, but a default value has been specified,
|
||||||
* but a default value has been specified, this will check if that default
|
* this will check if that default value is a long and return appropriately.
|
||||||
* value is a long and return appropriately.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the long to check.
|
* @param path Path of the long to check.
|
||||||
* @return Whether or not the specified path is a long.
|
* @return Whether or not the specified path is a long.
|
||||||
@ -395,11 +432,13 @@ public interface ConfigurationSection {
|
|||||||
// Java
|
// Java
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List by path.
|
* Gets the requested List by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return null.
|
* return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List.
|
* @return Requested List.
|
||||||
@ -407,27 +446,28 @@ public interface ConfigurationSection {
|
|||||||
List<?> getList(String path);
|
List<?> getList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List by path, returning a default value if not
|
* Gets the requested List by a path, returning a default value if not found.
|
||||||
* found.
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist then the specified default value will
|
* If the List does not exist then the specified default value will return regardless of if a
|
||||||
* returned regardless of if a default has been identified in the root
|
* default has been identified in the root {@link Configuration}.
|
||||||
* {@link com.boydti.fawe.configuration.Configuration}.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @param def The default value to return if the path is not found or is not a List.
|
||||||
* not a List.
|
|
||||||
* @return Requested List.
|
* @return Requested List.
|
||||||
*/
|
*/
|
||||||
List<?> getList(String path, List<?> def);
|
List<?> getList(String path, List<?> def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a List.
|
* Checks if the specified path is a List.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the path exists but is not a List, this will return false. If the
|
* If the path exists but is not a List, this will return false. If the
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* path does not exist, this will return false. If the path does not exist, but
|
||||||
* but a default value has been specified, this will check if that default
|
* a default value has been specified, this will check if that default
|
||||||
* value is a List and return appropriately.
|
* value is a List and return appropriately.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to check.
|
* @param path Path of the List to check.
|
||||||
* @return Whether or not the specified path is a List.
|
* @return Whether or not the specified path is a List.
|
||||||
@ -436,13 +476,17 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of String by path.
|
* Gets the requested List of String by path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this
|
||||||
* will return the default value. If the List does not exist and no
|
* will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* default value was specified, this will return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a String if possible,
|
* This method will attempt to cast any values into a String if possible,
|
||||||
* but may miss any values out if they are not compatible.
|
* but may miss any values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of String.
|
* @return Requested List of String.
|
||||||
@ -450,14 +494,18 @@ public interface ConfigurationSection {
|
|||||||
List<String> getStringList(String path);
|
List<String> getStringList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Integer by path.
|
* Gets the requested List of an Integer by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Integer if possible,
|
* This method will attempt to cast any values into an Integer if possible, but may miss any
|
||||||
* but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Integer.
|
* @return Requested List of Integer.
|
||||||
@ -465,14 +513,18 @@ public interface ConfigurationSection {
|
|||||||
List<Integer> getIntegerList(String path);
|
List<Integer> getIntegerList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Boolean by path.
|
* Gets the requested List of Boolean by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Boolean if possible,
|
* This method will attempt to cast any values into a Boolean if possible, but may miss any
|
||||||
* but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Boolean.
|
* @return Requested List of Boolean.
|
||||||
@ -480,14 +532,18 @@ public interface ConfigurationSection {
|
|||||||
List<Boolean> getBooleanList(String path);
|
List<Boolean> getBooleanList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Double by path.
|
* Gets the requested List of Double by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Double if possible,
|
* This method will attempt to cast any values into a Double if possible, but may miss any
|
||||||
* but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Double.
|
* @return Requested List of Double.
|
||||||
@ -495,14 +551,18 @@ public interface ConfigurationSection {
|
|||||||
List<Double> getDoubleList(String path);
|
List<Double> getDoubleList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Float by path.
|
* Gets the requested List of Float by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Float if possible,
|
* This method will attempt to cast any values into a Float if possible, but may miss any
|
||||||
* but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Float.
|
* @return Requested List of Float.
|
||||||
@ -510,14 +570,18 @@ public interface ConfigurationSection {
|
|||||||
List<Float> getFloatList(String path);
|
List<Float> getFloatList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Long by path.
|
* Gets the requested List of Long by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Long if possible,
|
* This method will attempt to cast any values into a Long if possible, but may miss any
|
||||||
* but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Long.
|
* @return Requested List of Long.
|
||||||
@ -525,14 +589,18 @@ public interface ConfigurationSection {
|
|||||||
List<Long> getLongList(String path);
|
List<Long> getLongList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Byte by path.
|
* Gets the requested List of Byte by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Byte if possible,
|
* This method will attempt to cast any values into a Byte if possible, but may miss any
|
||||||
* but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Byte.
|
* @return Requested List of Byte.
|
||||||
@ -540,14 +608,18 @@ public interface ConfigurationSection {
|
|||||||
List<Byte> getByteList(String path);
|
List<Byte> getByteList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Character by path.
|
* Gets the requested List of Character by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Character if
|
* This method will attempt to cast any values into a Character if possible, but may miss any
|
||||||
* possible, but may miss any values out if they are not compatible.
|
* values out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Character.
|
* @return Requested List of Character.
|
||||||
@ -555,14 +627,18 @@ public interface ConfigurationSection {
|
|||||||
List<Character> getCharacterList(String path);
|
List<Character> getCharacterList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Short by path.
|
* Gets the requested List of Short by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Short if possible,
|
* This method will attempt to cast any values into a Short if possible, but may miss any values
|
||||||
* but may miss any values out if they are not compatible.
|
* out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Short.
|
* @return Requested List of Short.
|
||||||
@ -570,14 +646,18 @@ public interface ConfigurationSection {
|
|||||||
List<Short> getShortList(String path);
|
List<Short> getShortList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Maps by path.
|
* Gets the requested List of Maps by a path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the List does not exist but a default value has been specified, this
|
* If the List does not exist, but a default value has been specified, this will return the
|
||||||
* will return the default value. If the List does not exist and no
|
* default value. If the List does not exist and no default value was specified, this will
|
||||||
* default value was specified, this will return an empty List.
|
* return an empty List.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method will attempt to cast any values into a Map if possible, but
|
* This method will attempt to cast any values into a Map if possible, but may miss any values
|
||||||
* may miss any values out if they are not compatible.
|
* out if they are not compatible.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Maps.
|
* @return Requested List of Maps.
|
||||||
@ -586,25 +666,27 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested ConfigurationSection by path.
|
* Gets the requested ConfigurationSection by path.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the ConfigurationSection does not exist but a default value has been
|
* If the ConfigurationSection does not exist, but a default value has been specified, this will
|
||||||
* specified, this will return the default value. If the
|
* return the default value. If the ConfigurationSection does not exist and no default value was
|
||||||
* ConfigurationSection does not exist and no default value was specified,
|
* specified, this will return null.
|
||||||
* this will return null.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the ConfigurationSection to get.
|
* @param path Path of the ConfigurationSection to get.
|
||||||
* @return Requested ConfigurationSection.
|
* @return Requested ConfigurationSection.
|
||||||
*/
|
*/
|
||||||
com.boydti.fawe.configuration.ConfigurationSection getConfigurationSection(String path);
|
ConfigurationSection getConfigurationSection(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a ConfigurationSection.
|
* Checks if the specified path is a {@link ConfigurationSection}.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the path exists but is not a ConfigurationSection, this will return
|
* If the path exists but is not a {@code ConfigurationSection}, this will return false. If the
|
||||||
* false. If the path does not exist, this will return false. If the path
|
* path does not exist, this will return false. If the path does not exist, but a default value
|
||||||
* does not exist but a default value has been specified, this will check
|
* has been specified, this will check if that default value is a ConfigurationSection and
|
||||||
* if that default value is a ConfigurationSection and return
|
* return appropriately.
|
||||||
* appropriately.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the ConfigurationSection to check.
|
* @param path Path of the ConfigurationSection to check.
|
||||||
* @return Whether or not the specified path is a ConfigurationSection.
|
* @return Whether or not the specified path is a ConfigurationSection.
|
||||||
@ -612,30 +694,35 @@ public interface ConfigurationSection {
|
|||||||
boolean isConfigurationSection(String path);
|
boolean isConfigurationSection(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the equivalent {@link com.boydti.fawe.configuration.ConfigurationSection} from the default
|
* Gets the equivalent {@link ConfigurationSection} from the default
|
||||||
* {@link com.boydti.fawe.configuration.Configuration} defined in {@link #getRoot()}.
|
* {@link Configuration} defined in {@link #getRoot()}.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the root contains no defaults, or the defaults doesn't contain a
|
* If the root contains no defaults, or the defaults doesn't contain a
|
||||||
* value for this path, or the value at this path is not a {@link
|
* value for this path, or the value at this path is not a {@link
|
||||||
* com.boydti.fawe.configuration.ConfigurationSection} then this will return null.
|
* ConfigurationSection} then this will return null.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Equivalent section in root configuration
|
* @return Equivalent section in root configuration
|
||||||
*/
|
*/
|
||||||
com.boydti.fawe.configuration.ConfigurationSection getDefaultSection();
|
ConfigurationSection getDefaultSection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default value in the root at the given path as provided.
|
* Sets the default value in the root at the given path as provided.
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If no source {@link com.boydti.fawe.configuration.Configuration} was provided as a default
|
* If no source {@link Configuration} was provided as a default collection, then a new {@link
|
||||||
* collection, then a new {@link com.boydti.fawe.configuration.MemoryConfiguration} will be created to
|
* MemoryConfiguration} will be created to hold the new default value.
|
||||||
* hold the new default value.
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If value is null, the value will be removed from the default
|
* If value is null, the value will be removed from the default Configuration source.
|
||||||
* Configuration source.
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the value as returned by {@link #getDefaultSection()} is null, then
|
* If the value as returned by {@link #getDefaultSection()} is null, then this will create a new
|
||||||
* this will create a new section at the path, replacing anything that may
|
* section at the path, replacing anything that may have existed there previously.
|
||||||
* have existed there previously.
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path Path of the value to set.
|
* @param path Path of the value to set.
|
||||||
* @param value Value to set the default to.
|
* @param value Value to set the default to.
|
||||||
|
@ -295,7 +295,8 @@ public class MemorySection implements com.boydti.fawe.configuration.Configuratio
|
|||||||
char separator = root.options().pathSeparator();
|
char separator = root.options().pathSeparator();
|
||||||
// i1 is the leading (higher) index
|
// i1 is the leading (higher) index
|
||||||
// i2 is the trailing (lower) index
|
// i2 is the trailing (lower) index
|
||||||
int i1 = -1, i2;
|
int i1 = -1;
|
||||||
|
int i2;
|
||||||
com.boydti.fawe.configuration.ConfigurationSection section = this;
|
com.boydti.fawe.configuration.ConfigurationSection section = this;
|
||||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||||
String node = path.substring(i2, i1);
|
String node = path.substring(i2, i1);
|
||||||
@ -377,7 +378,8 @@ public class MemorySection implements com.boydti.fawe.configuration.Configuratio
|
|||||||
char separator = root.options().pathSeparator();
|
char separator = root.options().pathSeparator();
|
||||||
// i1 is the leading (higher) index
|
// i1 is the leading (higher) index
|
||||||
// i2 is the trailing (lower) index
|
// i2 is the trailing (lower) index
|
||||||
int i1 = -1, i2;
|
int i1 = -1;
|
||||||
|
int i2;
|
||||||
com.boydti.fawe.configuration.ConfigurationSection section = this;
|
com.boydti.fawe.configuration.ConfigurationSection section = this;
|
||||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||||
String node = path.substring(i2, i1);
|
String node = path.substring(i2, i1);
|
||||||
|
@ -1,18 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2008, http://www.snakeyaml.org
|
|
||||||
* <p>
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* <p>
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* <p>
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.yaml.snakeyaml;
|
package org.yaml.snakeyaml;
|
||||||
|
|
||||||
import org.yaml.snakeyaml.nodes.Tag;
|
import org.yaml.snakeyaml.nodes.Tag;
|
||||||
@ -60,8 +45,7 @@ public final class TypeDescription {
|
|||||||
/**
|
/**
|
||||||
* Set tag to be used to load or dump the type (class).
|
* Set tag to be used to load or dump the type (class).
|
||||||
*
|
*
|
||||||
* @param tag
|
* @param tag local or global tag
|
||||||
* local or global tag
|
|
||||||
*/
|
*/
|
||||||
public void setTag(Tag tag) {
|
public void setTag(Tag tag) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
@ -72,7 +56,7 @@ public final class TypeDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get represented type (class)
|
* Get the represented type (class).
|
||||||
*
|
*
|
||||||
* @return type (class) to be described.
|
* @return type (class) to be described.
|
||||||
*/
|
*/
|
||||||
@ -81,12 +65,10 @@ public final class TypeDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify that the property is a type-safe <code>List</code>.
|
* Specify that the property is a type-safe {@code List}.
|
||||||
*
|
*
|
||||||
* @param property
|
* @param property name of the JavaBean property
|
||||||
* name of the JavaBean property
|
* @param type class of List values
|
||||||
* @param type
|
|
||||||
* class of List values
|
|
||||||
*/
|
*/
|
||||||
public void putListPropertyType(String property, Class<? extends Object> type) {
|
public void putListPropertyType(String property, Class<? extends Object> type) {
|
||||||
listProperties.put(property, type);
|
listProperties.put(property, type);
|
||||||
@ -95,8 +77,7 @@ public final class TypeDescription {
|
|||||||
/**
|
/**
|
||||||
* Get class of List values for provided JavaBean property.
|
* Get class of List values for provided JavaBean property.
|
||||||
*
|
*
|
||||||
* @param property
|
* @param property property name
|
||||||
* property name
|
|
||||||
* @return class of List values
|
* @return class of List values
|
||||||
*/
|
*/
|
||||||
public Class<? extends Object> getListPropertyType(String property) {
|
public Class<? extends Object> getListPropertyType(String property) {
|
||||||
@ -104,14 +85,11 @@ public final class TypeDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify that the property is a type-safe <code>Map</code>.
|
* Specify that the property is a type-safe {@code Map}.
|
||||||
*
|
*
|
||||||
* @param property
|
* @param property property name of this JavaBean
|
||||||
* property name of this JavaBean
|
* @param key class of keys in Map
|
||||||
* @param key
|
* @param value class of values in Map
|
||||||
* class of keys in Map
|
|
||||||
* @param value
|
|
||||||
* class of values in Map
|
|
||||||
*/
|
*/
|
||||||
public void putMapPropertyType(String property, Class<? extends Object> key,
|
public void putMapPropertyType(String property, Class<? extends Object> key,
|
||||||
Class<? extends Object> value) {
|
Class<? extends Object> value) {
|
||||||
@ -120,10 +98,9 @@ public final class TypeDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get keys type info for this JavaBean
|
* Get keys type info for this JavaBean.
|
||||||
*
|
*
|
||||||
* @param property
|
* @param property property name of this JavaBean
|
||||||
* property name of this JavaBean
|
|
||||||
* @return class of keys in the Map
|
* @return class of keys in the Map
|
||||||
*/
|
*/
|
||||||
public Class<? extends Object> getMapKeyType(String property) {
|
public Class<? extends Object> getMapKeyType(String property) {
|
||||||
@ -131,10 +108,9 @@ public final class TypeDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get values type info for this JavaBean
|
* Get values type info for this JavaBean.
|
||||||
*
|
*
|
||||||
* @param property
|
* @param property property name of this JavaBean
|
||||||
* property name of this JavaBean
|
|
||||||
* @return class of values in the Map
|
* @return class of values in the Map
|
||||||
*/
|
*/
|
||||||
public Class<? extends Object> getMapValueType(String property) {
|
public Class<? extends Object> getMapValueType(String property) {
|
||||||
|
@ -35,10 +35,10 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class Yaml {
|
public class Yaml {
|
||||||
protected final Resolver resolver;
|
protected final Resolver resolver;
|
||||||
private String name;
|
|
||||||
protected BaseConstructor constructor;
|
protected BaseConstructor constructor;
|
||||||
protected Representer representer;
|
protected Representer representer;
|
||||||
protected DumperOptions dumperOptions;
|
protected DumperOptions dumperOptions;
|
||||||
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Yaml instance. It is safe to create a few instances and use them
|
* Create Yaml instance. It is safe to create a few instances and use them
|
||||||
@ -212,19 +212,19 @@ public class Yaml {
|
|||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Serialize a Java object into a YAML string. Override the default root tag
|
* Serialize a Java object into a YAML string. Override the default root tag
|
||||||
* with <code>rootTag</code>.
|
* with {@code rootTag}.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This method is similar to <code>Yaml.dump(data)</code> except that the
|
* This method is similar to {@code Yaml.dump(data)} except that the
|
||||||
* root tag for the whole document is replaced with the given tag. This has
|
* root tag for the whole document is replaced with the given tag. This has
|
||||||
* two main uses.
|
* two main uses.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* First, if the root tag is replaced with a standard YAML tag, such as
|
* First, if the root tag is replaced with a standard YAML tag, such as
|
||||||
* <code>Tag.MAP</code>, then the object will be dumped as a map. The root
|
* {@code Tag.MAP}, then the object will be dumped as a map. The root
|
||||||
* tag will appear as <code>!!map</code>, or blank (implicit !!map).
|
* tag will appear as {@code !!map}, or blank (implicit !!map).
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
@ -237,11 +237,11 @@ public class Yaml {
|
|||||||
* @param data Java object to be serialized to YAML
|
* @param data Java object to be serialized to YAML
|
||||||
* @param rootTag the tag for the whole YAML document. The tag should be Tag.MAP
|
* @param rootTag the tag for the whole YAML document. The tag should be Tag.MAP
|
||||||
* for a JavaBean to make the tag disappear (to use implicit tag
|
* for a JavaBean to make the tag disappear (to use implicit tag
|
||||||
* !!map). If <code>null</code> is provided then the standard tag
|
* !!map). If {@code null} is provided then the standard tag
|
||||||
* with the full class name is used.
|
* with the full class name is used.
|
||||||
* @param flowStyle flow style for the whole document. See Chapter 10. Collection
|
* @param flowStyle flow style for the whole document. See Chapter 10. Collection
|
||||||
* Styles http://yaml.org/spec/1.1/#id930798. If
|
* Styles http://yaml.org/spec/1.1/#id930798. If
|
||||||
* <code>null</code> is provided then the flow style from
|
* {@code null} is provided then the flow style from
|
||||||
* DumperOptions is used.
|
* DumperOptions is used.
|
||||||
* @return YAML String
|
* @return YAML String
|
||||||
*/
|
*/
|
||||||
@ -261,11 +261,11 @@ public class Yaml {
|
|||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Serialize a Java object into a YAML string. Override the default root tag
|
* Serialize a Java object into a YAML string. Override the default root tag
|
||||||
* with <code>Tag.MAP</code>.
|
* with {@code Tag.MAP}.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* This method is similar to <code>Yaml.dump(data)</code> except that the
|
* This method is similar to {@code Yaml.dump(data)} except that the
|
||||||
* root tag for the whole document is replaced with <code>Tag.MAP</code> tag
|
* root tag for the whole document is replaced with {@code Tag.MAP} tag
|
||||||
* (implicit !!map).
|
* (implicit !!map).
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
@ -300,18 +300,6 @@ public class Yaml {
|
|||||||
return emitter.getEvents();
|
return emitter.getEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SilentEmitter implements Emitable {
|
|
||||||
private List<Event> events = new ArrayList<>(100);
|
|
||||||
|
|
||||||
public List<Event> getEvents() {
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void emit(Event event) throws IOException {
|
|
||||||
events.add(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the only YAML document in a String and produce the corresponding
|
* Parse the only YAML document in a String and produce the corresponding
|
||||||
* Java object. (Because the encoding in known BOM is not respected.)
|
* Java object. (Because the encoding in known BOM is not respected.)
|
||||||
@ -420,18 +408,6 @@ public class Yaml {
|
|||||||
return new YamlIterable(result);
|
return new YamlIterable(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class YamlIterable implements Iterable<Object> {
|
|
||||||
private Iterator<Object> iterator;
|
|
||||||
|
|
||||||
public YamlIterable(Iterator<Object> iterator) {
|
|
||||||
this.iterator = iterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator<Object> iterator() {
|
|
||||||
return iterator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse all YAML documents in a String and produce corresponding Java
|
* Parse all YAML documents in a String and produce corresponding Java
|
||||||
* objects. (Because the encoding in known BOM is not respected.) The
|
* objects. (Because the encoding in known BOM is not respected.) The
|
||||||
@ -499,26 +475,13 @@ public class Yaml {
|
|||||||
return new NodeIterable(result);
|
return new NodeIterable(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NodeIterable implements Iterable<Node> {
|
|
||||||
private Iterator<Node> iterator;
|
|
||||||
|
|
||||||
public NodeIterable(Iterator<Node> iterator) {
|
|
||||||
this.iterator = iterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator<Node> iterator() {
|
|
||||||
return iterator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an implicit scalar detector. If an implicit scalar value matches the
|
* Add an implicit scalar detector. If an implicit scalar value matches the
|
||||||
* given regexp, the corresponding tag is assigned to the scalar.
|
* given regexp, the corresponding tag is assigned to the scalar.
|
||||||
*
|
*
|
||||||
* @param tag tag to assign to the node
|
* @param tag tag to assign to the node
|
||||||
* @param regexp regular expression to match against
|
* @param regexp regular expression to match against
|
||||||
* @param first a sequence of possible initial characters or null (which means
|
* @param first a sequence of possible initial characters or null (which means any).
|
||||||
* any).
|
|
||||||
*/
|
*/
|
||||||
public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
|
public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
|
||||||
resolver.addImplicitResolver(tag, regexp, first);
|
resolver.addImplicitResolver(tag, regexp, first);
|
||||||
@ -541,7 +504,7 @@ public class Yaml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a meaningful name to be shown in toString()
|
* Set a meaningful name to be shown in {@code toString()}.
|
||||||
*
|
*
|
||||||
* @param name human readable name
|
* @param name human readable name
|
||||||
*/
|
*/
|
||||||
@ -574,6 +537,51 @@ public class Yaml {
|
|||||||
return new EventIterable(result);
|
return new EventIterable(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBeanAccess(BeanAccess beanAccess) {
|
||||||
|
constructor.getPropertyUtils().setBeanAccess(beanAccess);
|
||||||
|
representer.getPropertyUtils().setBeanAccess(beanAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class SilentEmitter implements Emitable {
|
||||||
|
private List<Event> events = new ArrayList<>(100);
|
||||||
|
|
||||||
|
public List<Event> getEvents() {
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void emit(Event event) throws IOException {
|
||||||
|
events.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class YamlIterable implements Iterable<Object> {
|
||||||
|
private Iterator<Object> iterator;
|
||||||
|
|
||||||
|
public YamlIterable(Iterator<Object> iterator) {
|
||||||
|
this.iterator = iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<Object> iterator() {
|
||||||
|
return iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class NodeIterable implements Iterable<Node> {
|
||||||
|
private Iterator<Node> iterator;
|
||||||
|
|
||||||
|
public NodeIterable(Iterator<Node> iterator) {
|
||||||
|
this.iterator = iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<Node> iterator() {
|
||||||
|
return iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class EventIterable implements Iterable<Event> {
|
private static class EventIterable implements Iterable<Event> {
|
||||||
private Iterator<Event> iterator;
|
private Iterator<Event> iterator;
|
||||||
|
|
||||||
@ -586,9 +594,4 @@ public class Yaml {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBeanAccess(BeanAccess beanAccess) {
|
|
||||||
constructor.getPropertyUtils().setBeanAccess(beanAccess);
|
|
||||||
representer.getPropertyUtils().setBeanAccess(beanAccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren