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
|
||||
### 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/)
|
||||
|
||||
Looking builds for older versions? Download them [here](https://intellectualsites.github.io/download/).
|
||||
|
||||
|
||||
## Building
|
||||
FAWE uses gradle to build
|
||||
|
@ -19,6 +19,7 @@ import org.gradle.kotlin.dsl.withType
|
||||
fun Project.applyPlatformAndCoreConfiguration() {
|
||||
applyCommonConfiguration()
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "eclipse")
|
||||
apply(plugin = "idea")
|
||||
apply(plugin = "maven")
|
||||
// apply(plugin = "checkstyle")
|
||||
|
@ -10,4 +10,13 @@
|
||||
<suppress files=".*[\\/]TracedEditSession.java" checks="NoFinalizer"/>
|
||||
<!-- None of the old command stuff really matters -->
|
||||
<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>
|
||||
|
@ -96,6 +96,7 @@ Checks based on Google Checks, modified for EngineHub.
|
||||
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="format" value="^([a-z][a-z0-9][_a-zA-Z0-9]*|[a-z])$"/>
|
||||
<message key="name.invalidPattern"
|
||||
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}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|(^[A-Z][a-zA-Z0-9]*$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
@ -186,6 +188,7 @@ Checks based on Google Checks, modified for EngineHub.
|
||||
<module name="CommentsIndentation"/>
|
||||
<!-- Validate String.to(Lower|Upper)Case() calls include Locale argument -->
|
||||
<module name="Regexp">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="message" value="Case-conversion calls must include an explicit Locale"/>
|
||||
<property name="format" value="(?!Character)\.to(Lower|Upper)Case\(\)"/>
|
||||
<property name="illegalPattern" value="true"/>
|
||||
|
@ -116,10 +116,10 @@ function findClosestWoolColor(col, clothColors) {
|
||||
var closestId = 0;
|
||||
var closestDistance = colorDistance(col, clothColors[0]);
|
||||
|
||||
for(var i = 1; i < clothColors.length; i++) {
|
||||
for (var i = 1; i < clothColors.length; i++) {
|
||||
var dist = colorDistance(col, clothColors[i]);
|
||||
|
||||
if(dist < closestDistance) {
|
||||
if (dist < closestDistance) {
|
||||
closestId = i;
|
||||
closestDistance = dist;
|
||||
}
|
||||
@ -135,10 +135,10 @@ var f = context.getSafeOpenFile("drawings", argv[1], "png", ["png", "jpg", "jpeg
|
||||
var sess = context.remember();
|
||||
var upright = argv[2] == "v";
|
||||
var colors = clothColors;
|
||||
if(argv[3] == "opt") {
|
||||
if (argv[3] == "opt") {
|
||||
colors = clothColorsOpt;
|
||||
player.print("Using optimized palette");
|
||||
} else if(argv[3] == "optHD") {
|
||||
} else if (argv[3] == "optHD") {
|
||||
colors = clothColorsOptHD;
|
||||
player.print("Using optimized HD palette");
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ var blocktype = context.getBlock(argv[1]);
|
||||
|
||||
var cycles = region.getLength();
|
||||
|
||||
if (region.getWidth() > cycles){
|
||||
if (region.getWidth() > cycles) {
|
||||
cycles = region.getWidth();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler;
|
||||
import com.boydti.fawe.bukkit.listener.BrushListener;
|
||||
import com.boydti.fawe.bukkit.listener.BukkitImageListener;
|
||||
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.regions.FreeBuildRegion;
|
||||
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);
|
||||
|
||||
// The tick limiter
|
||||
new ChunkListener_9();
|
||||
new ChunkListener9();
|
||||
});
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
this.imageListener = new BukkitImageListener(plugin);
|
||||
}
|
||||
return viewer;
|
||||
} catch (Throwable ignore) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -252,7 +252,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
|
||||
private volatile boolean keepUnloaded;
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR) public void onWorldLoad(WorldLoadEvent event) {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
if (keepUnloaded) {
|
||||
org.bukkit.World world = event.getWorld();
|
||||
world.setKeepSpawnInMemory(false);
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.boydti.fawe.bukkit.adapter;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import co.aikar.timings.Timings;
|
||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||
import com.boydti.fawe.bukkit.listener.ChunkListener;
|
||||
import java.lang.reflect.Method;
|
||||
import org.spigotmc.AsyncCatcher;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public class BukkitQueueHandler extends QueueHandler {
|
||||
private volatile boolean timingsEnabled;
|
||||
private static boolean alertTimingsChange = true;
|
||||
@ -17,7 +18,8 @@ public class BukkitQueueHandler extends QueueHandler {
|
||||
try {
|
||||
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
|
||||
methodCheck.setAccessible(true);
|
||||
} catch (Throwable ignore){}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,13 @@ package com.boydti.fawe.bukkit.adapter.mc1_15_2;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
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;
|
||||
|
||||
public class BlockMaterial_1_15_2 implements BlockMaterial {
|
||||
|
@ -52,22 +52,22 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
||||
/*
|
||||
NMS fields
|
||||
*/
|
||||
public final static Field fieldBits;
|
||||
public final static Field fieldPalette;
|
||||
public final static Field fieldSize;
|
||||
public static final Field fieldBits;
|
||||
public static final Field fieldPalette;
|
||||
public static final Field fieldSize;
|
||||
|
||||
public final static Field fieldFluidCount;
|
||||
public final static Field fieldTickingBlockCount;
|
||||
public final static Field fieldNonEmptyBlockCount;
|
||||
public static final Field fieldFluidCount;
|
||||
public static final Field fieldTickingBlockCount;
|
||||
public static final Field fieldNonEmptyBlockCount;
|
||||
|
||||
private final static Field fieldDirtyCount;
|
||||
private final static Field fieldDirtyBits;
|
||||
private static final Field fieldDirtyCount;
|
||||
private static final Field fieldDirtyBits;
|
||||
|
||||
private static final Field fieldBiomeArray;
|
||||
|
||||
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_SHIFT;
|
||||
@ -114,8 +114,9 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
||||
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
||||
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(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");
|
||||
}
|
||||
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
} catch (RuntimeException 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) {
|
||||
Chunk nmsChunk = nmsWorld.getChunkIfLoaded(X, Z);
|
||||
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||
Chunk nmsChunk = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
|
||||
if (nmsChunk != null) {
|
||||
return nmsChunk;
|
||||
}
|
||||
if (Fawe.isMainThread()) {
|
||||
return nmsWorld.getChunkAt(X, Z);
|
||||
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||
}
|
||||
if (PaperLib.isPaper()) {
|
||||
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 {
|
||||
CraftChunk chunk = (CraftChunk) future.get();
|
||||
return chunk.getHandle();
|
||||
@ -171,20 +172,20 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
|
||||
try {
|
||||
return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
|
||||
return (PlayerChunk) methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
|
||||
} catch (Throwable thr) {
|
||||
throw new RuntimeException(thr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask, boolean lighting) {
|
||||
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, X, Z);
|
||||
public static void sendChunk(WorldServer nmsWorld, int chunkX, int chunkZ, int mask, boolean lighting) {
|
||||
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, chunkX, chunkZ);
|
||||
if (playerChunk == null) {
|
||||
return;
|
||||
}
|
||||
@ -205,7 +206,7 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
||||
fieldDirtyCount.set(playerChunk, 64);
|
||||
|
||||
if (lighting) {
|
||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(X, Z);
|
||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine());
|
||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||
p.playerConnection.sendPacket(packet);
|
||||
@ -259,7 +260,9 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
|
||||
|
||||
final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
|
||||
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 {
|
||||
final BitArray bitArray = new BitArray(bitsPerEntry, 4096, blockStates);
|
||||
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 DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||
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);
|
||||
|
||||
// set palette
|
||||
|
@ -58,7 +58,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -72,6 +71,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 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 Chunk nmsChunk;
|
||||
public WorldServer world;
|
||||
public int X, Z;
|
||||
public int chunkX;
|
||||
public int chunkZ;
|
||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||
private boolean createCopy = false;
|
||||
private BukkitGetBlocks_1_15_2_Copy copy = null;
|
||||
|
||||
public BukkitGetBlocks_1_15_2(World world, int X, int Z) {
|
||||
this(((CraftWorld) world).getHandle(), X, Z);
|
||||
public BukkitGetBlocks_1_15_2(World world, int chunkX, int chunkZ) {
|
||||
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.X = X;
|
||||
this.Z = Z;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
public int getChunkX() {
|
||||
return chunkX;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,12 +120,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return X;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return Z;
|
||||
public int getChunkZ() {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,7 +131,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
if (y == -1) {
|
||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||
if (base != null) break;
|
||||
if (base != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||
@ -140,7 +143,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@ -164,11 +168,11 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
byte[] a = new byte[2048];
|
||||
// Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway.
|
||||
Arrays.fill(a, (byte) 15);
|
||||
nibbleArray = new NibbleArray(a);
|
||||
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibbleArray);
|
||||
byte[] a = new byte[2048];
|
||||
// Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway.
|
||||
Arrays.fill(a, (byte) 15);
|
||||
nibbleArray = new NibbleArray(a);
|
||||
((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibbleArray);
|
||||
}
|
||||
skyLight[layer] = nibbleArray;
|
||||
}
|
||||
@ -227,7 +231,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||
int size = 0;
|
||||
for (List<Entity> slice : slices) {
|
||||
if (slice != null) size += slice.size();
|
||||
if (slice != null) {
|
||||
size += slice.size();
|
||||
}
|
||||
}
|
||||
if (slices.length == 0) {
|
||||
return Collections.emptySet();
|
||||
@ -304,16 +310,16 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
entity.die();
|
||||
}
|
||||
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_15_R1.World nmsWorld, int X, int Z) {
|
||||
return BukkitAdapter_1_15_2.ensureLoaded(nmsWorld, X, Z);
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_15_R1.World nmsWorld, int chunkX, int chunkZ) {
|
||||
return BukkitAdapter_1_15_2.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
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;
|
||||
|
||||
// Remove existing tiles
|
||||
@ -348,7 +354,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
if (!set.hasSection(layer)){
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
@ -368,7 +374,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
} else {
|
||||
existingSection = sections[layer];
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -395,7 +402,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
}
|
||||
newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
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;
|
||||
} else {
|
||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||
@ -458,12 +465,14 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
|
||||
Runnable[] syncTasks = null;
|
||||
|
||||
int bx = X << 4;
|
||||
int bz = Z << 4;
|
||||
int bx = chunkX << 4;
|
||||
int bz = chunkZ << 4;
|
||||
|
||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[3];
|
||||
}
|
||||
|
||||
syncTasks[2] = () -> {
|
||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||
@ -488,7 +497,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
|
||||
Set<CompoundTag> entities = set.getEntities();
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[2];
|
||||
}
|
||||
|
||||
syncTasks[1] = () -> {
|
||||
for (final CompoundTag nativeTag : entities) {
|
||||
@ -530,7 +541,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
// set tiles
|
||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||
if (tiles != null && !tiles.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[1];
|
||||
}
|
||||
|
||||
syncTasks[0] = () -> {
|
||||
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.markDirty();
|
||||
// send to player
|
||||
BukkitAdapter_1_15_2.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) finalizer.run();
|
||||
BukkitAdapter_1_15_2.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (syncTasks != null) {
|
||||
@ -590,7 +605,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
}
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return queueHandler.async(callback, null);
|
||||
@ -603,7 +620,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
return (T) (Future) queueHandler.sync(chain);
|
||||
} else {
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
} else {
|
||||
callback.run();
|
||||
}
|
||||
@ -753,7 +772,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
synchronized (this) {
|
||||
tmp = nmsChunk;
|
||||
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.event.block.BlockPhysicsEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 WeakReference<World> world;
|
||||
|
@ -2,7 +2,14 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_1;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
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;
|
||||
|
||||
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 io.papermc.lib.PaperLib;
|
||||
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.CraftWorld;
|
||||
import sun.misc.Unsafe;
|
||||
@ -34,18 +50,18 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
||||
/*
|
||||
NMS fields
|
||||
*/
|
||||
public final static Field fieldBits;
|
||||
public final static Field fieldPalette;
|
||||
public final static Field fieldSize;
|
||||
public static final Field fieldBits;
|
||||
public static final Field fieldPalette;
|
||||
public static final Field fieldSize;
|
||||
|
||||
public final static Field fieldBitsPerEntry;
|
||||
public static final Field fieldBitsPerEntry;
|
||||
|
||||
public final static Field fieldFluidCount;
|
||||
public final static Field fieldTickingBlockCount;
|
||||
public final static Field fieldNonEmptyBlockCount;
|
||||
public static final Field fieldFluidCount;
|
||||
public static final Field fieldTickingBlockCount;
|
||||
public static final Field fieldNonEmptyBlockCount;
|
||||
|
||||
private final static Field fieldDirtyCount;
|
||||
private final static Field fieldDirtyBits;
|
||||
private static final Field fieldDirtyCount;
|
||||
private static final Field fieldDirtyBits;
|
||||
|
||||
private static final Field fieldBiomeArray;
|
||||
|
||||
@ -95,8 +111,9 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
||||
Unsafe unsafe = UnsafeUtils.getUNSAFE();
|
||||
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(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");
|
||||
}
|
||||
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
} catch (RuntimeException 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) {
|
||||
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(X, Z, false);
|
||||
public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||
Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false);
|
||||
if (nmsChunk != null) {
|
||||
return nmsChunk;
|
||||
}
|
||||
if (Fawe.isMainThread()) {
|
||||
return nmsWorld.getChunkAt(X, Z);
|
||||
return nmsWorld.getChunkAt(chunkX, chunkZ);
|
||||
}
|
||||
if (PaperLib.isPaper()) {
|
||||
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 {
|
||||
CraftChunk chunk = (CraftChunk) future.get();
|
||||
return chunk.getHandle();
|
||||
@ -152,20 +169,20 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
|
||||
try {
|
||||
return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
|
||||
return (PlayerChunk) methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
|
||||
} catch (Throwable thr) {
|
||||
throw new RuntimeException(thr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask, boolean lighting) {
|
||||
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, X, Z);
|
||||
public static void sendChunk(WorldServer nmsWorld, int chunkX, int chunkZ, int mask, boolean lighting) {
|
||||
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, chunkX, chunkZ);
|
||||
if (playerChunk == null) {
|
||||
return;
|
||||
}
|
||||
@ -186,7 +203,7 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
|
||||
fieldDirtyCount.set(playerChunk, 64);
|
||||
|
||||
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.
|
||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||
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);
|
||||
|
||||
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 {
|
||||
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
|
||||
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 DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||
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);
|
||||
|
||||
// set palette
|
||||
|
@ -15,8 +15,10 @@ import com.boydti.fawe.object.collection.AdaptedMap;
|
||||
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
||||
import com.google.common.base.Suppliers;
|
||||
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.*;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
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.world.biome.BiomeType;
|
||||
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.block.Biome;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||
@ -35,11 +58,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.AbstractSet;
|
||||
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.Future;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 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 Chunk nmsChunk;
|
||||
public WorldServer world;
|
||||
public int X, Z;
|
||||
public int chunkX;
|
||||
public int chunkZ;
|
||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||
private boolean createCopy = false;
|
||||
private BukkitGetBlocks_1_16_1_Copy copy = null;
|
||||
|
||||
public BukkitGetBlocks_1_16_1(World world, int X, int Z) {
|
||||
this(((CraftWorld) world).getHandle(), X, Z);
|
||||
public BukkitGetBlocks_1_16_1(World world, int chunkX, int chunkZ) {
|
||||
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.X = X;
|
||||
this.Z = Z;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
|
||||
public int getChunkX() {
|
||||
return chunkX;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,12 +121,8 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return X;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return Z;
|
||||
public int getChunkZ() {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,7 +132,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
if (y == -1) {
|
||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||
if (base != null) break;
|
||||
if (base != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||
@ -108,7 +144,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@ -193,7 +231,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||
int size = 0;
|
||||
for (List<Entity> slice : slices) {
|
||||
if (slice != null) size += slice.size();
|
||||
if (slice != null) {
|
||||
size += slice.size();
|
||||
}
|
||||
}
|
||||
if (slices.length == 0) {
|
||||
return Collections.emptySet();
|
||||
@ -270,16 +310,16 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
entity.die();
|
||||
}
|
||||
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R1.World nmsWorld, int X, int Z) {
|
||||
return BukkitAdapter_1_16_1.ensureLoaded(nmsWorld, X, Z);
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R1.World nmsWorld, int chunkX, int chunkZ) {
|
||||
return BukkitAdapter_1_16_1.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
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;
|
||||
|
||||
// Remove existing tiles
|
||||
@ -314,7 +354,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
if (!set.hasSection(layer)){
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
@ -334,7 +374,8 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
} else {
|
||||
existingSection = sections[layer];
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -363,7 +404,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_16_1
|
||||
.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;
|
||||
} else {
|
||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||
@ -426,12 +467,14 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
|
||||
Runnable[] syncTasks = null;
|
||||
|
||||
int bx = X << 4;
|
||||
int bz = Z << 4;
|
||||
int bx = chunkX << 4;
|
||||
int bz = chunkZ << 4;
|
||||
|
||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[3];
|
||||
}
|
||||
|
||||
syncTasks[2] = () -> {
|
||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||
@ -456,7 +499,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
|
||||
Set<CompoundTag> entities = set.getEntities();
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[2];
|
||||
}
|
||||
|
||||
syncTasks[1] = () -> {
|
||||
for (final CompoundTag nativeTag : entities) {
|
||||
@ -498,7 +543,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
// set tiles
|
||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||
if (tiles != null && !tiles.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[1];
|
||||
}
|
||||
|
||||
syncTasks[0] = () -> {
|
||||
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.markDirty();
|
||||
// send to player
|
||||
BukkitAdapter_1_16_1.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) finalizer.run();
|
||||
BukkitAdapter_1_16_1.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (syncTasks != null) {
|
||||
@ -558,7 +607,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
}
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return queueHandler.async(callback, null);
|
||||
@ -571,7 +622,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
return (T) (Future) queueHandler.sync(chain);
|
||||
} else {
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
} else {
|
||||
callback.run();
|
||||
}
|
||||
@ -721,7 +774,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
synchronized (this) {
|
||||
tmp = nmsChunk;
|
||||
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.event.block.BlockPhysicsEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 WeakReference<World> world;
|
||||
|
@ -2,7 +2,14 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_2;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
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;
|
||||
|
||||
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();
|
||||
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(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");
|
||||
}
|
||||
CHUNKSECTION_SHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
|
||||
Class clsShortArraySet;
|
||||
Class<?> clsShortArraySet;
|
||||
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'}));
|
||||
} 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'}));
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
@ -184,7 +185,7 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
||||
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) {
|
||||
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
|
||||
try {
|
||||
return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
return (PlayerChunk) methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
} catch (Throwable thr) {
|
||||
throw new RuntimeException(thr);
|
||||
}
|
||||
@ -207,7 +208,6 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
|
||||
}
|
||||
|
||||
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)
|
||||
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
|
||||
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);
|
||||
|
||||
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 {
|
||||
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
|
||||
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 DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||
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);
|
||||
|
||||
// set palette
|
||||
|
@ -15,8 +15,10 @@ import com.boydti.fawe.object.collection.AdaptedMap;
|
||||
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
||||
import com.google.common.base.Suppliers;
|
||||
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.*;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
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.world.biome.BiomeType;
|
||||
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.block.Biome;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||
@ -35,11 +59,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.AbstractSet;
|
||||
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.Future;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 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 Chunk nmsChunk;
|
||||
public WorldServer world;
|
||||
public int X, Z;
|
||||
public int chunkX;
|
||||
public int chunkZ;
|
||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||
private boolean createCopy = false;
|
||||
private BukkitGetBlocks_1_16_2_Copy copy = null;
|
||||
|
||||
public BukkitGetBlocks_1_16_2(World world, int X, int Z) {
|
||||
this(((CraftWorld) world).getHandle(), X, Z);
|
||||
public BukkitGetBlocks_1_16_2(World world, int chunkX, int chunkZ) {
|
||||
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.X = X;
|
||||
this.Z = Z;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
public int getChunkX() {
|
||||
return chunkX;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,12 +121,8 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return X;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return Z;
|
||||
public int getChunkZ() {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,7 +132,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
if (y == -1) {
|
||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||
if (base != null) break;
|
||||
if (base != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
base = index.getBiome(x >> 2, y >> 2, z >> 2);
|
||||
@ -108,7 +144,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@ -196,7 +234,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||
int size = 0;
|
||||
for (List<Entity> slice : slices) {
|
||||
if (slice != null) size += slice.size();
|
||||
if (slice != null) {
|
||||
size += slice.size();
|
||||
}
|
||||
}
|
||||
if (slices.length == 0) {
|
||||
return Collections.emptySet();
|
||||
@ -273,16 +313,16 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
entity.die();
|
||||
}
|
||||
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R2.World nmsWorld, int X, int Z) {
|
||||
return BukkitAdapter_1_16_2.ensureLoaded(nmsWorld, X, Z);
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R2.World nmsWorld, int chunkX, int chunkZ) {
|
||||
return BukkitAdapter_1_16_2.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
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;
|
||||
|
||||
// Remove existing tiles
|
||||
@ -317,7 +357,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
if (!set.hasSection(layer)){
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
@ -337,7 +377,8 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
} else {
|
||||
existingSection = sections[layer];
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -366,7 +407,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_16_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;
|
||||
} else {
|
||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||
@ -429,12 +470,14 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
|
||||
Runnable[] syncTasks = null;
|
||||
|
||||
int bx = X << 4;
|
||||
int bz = Z << 4;
|
||||
int bx = chunkX << 4;
|
||||
int bz = chunkZ << 4;
|
||||
|
||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[3];
|
||||
}
|
||||
|
||||
syncTasks[2] = () -> {
|
||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||
@ -459,7 +502,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
|
||||
Set<CompoundTag> entities = set.getEntities();
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[2];
|
||||
}
|
||||
|
||||
syncTasks[1] = () -> {
|
||||
for (final CompoundTag nativeTag : entities) {
|
||||
@ -501,7 +546,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
// set tiles
|
||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||
if (tiles != null && !tiles.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[1];
|
||||
}
|
||||
|
||||
syncTasks[0] = () -> {
|
||||
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.markDirty();
|
||||
// send to player
|
||||
BukkitAdapter_1_16_2.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) finalizer.run();
|
||||
BukkitAdapter_1_16_2.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (syncTasks != null) {
|
||||
@ -561,7 +610,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
}
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return queueHandler.async(callback, null);
|
||||
@ -574,7 +625,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
return (T) (Future) queueHandler.sync(chain);
|
||||
} else {
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
} else {
|
||||
callback.run();
|
||||
}
|
||||
@ -724,7 +777,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
synchronized (this) {
|
||||
tmp = nmsChunk;
|
||||
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.event.block.BlockPhysicsEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 WeakReference<World> world;
|
||||
|
@ -1,8 +1,5 @@
|
||||
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.regions.general.CuboidRegionFilter;
|
||||
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 org.bukkit.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
private final World world;
|
||||
private boolean large;
|
||||
@ -23,6 +23,7 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
Fawe.get().getQueueHandler().sync(() -> {
|
||||
@ -43,7 +44,9 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
|
||||
@Override
|
||||
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 pos2 = BlockVector3.at(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
@ -53,7 +56,9 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
|
||||
@Override
|
||||
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 pos2 = BlockVector3.at(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
|
@ -1,39 +1,17 @@
|
||||
package com.boydti.fawe.bukkit.listener;
|
||||
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
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.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
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.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.Location;
|
||||
import org.bukkit.Rotation;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -41,13 +19,15 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitImageListener implements Listener {
|
||||
|
||||
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
|
||||
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
// public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
||||
// Set<Player> recipients = event.getRecipients();
|
||||
// Iterator<Player> iter = recipients.iterator();
|
||||
// while (iter.hasNext()) {
|
||||
// Player player = iter.next();
|
||||
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
// if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// String name = player.getName().toLowerCase();
|
||||
// if (!event.getMessage().toLowerCase().contains(name)) {
|
||||
// ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
||||
// if (buffered == null) {
|
||||
// bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||
// }
|
||||
// String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
||||
// event.getMessage());
|
||||
// buffered.add(full);
|
||||
// iter.remove();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
Iterator<Player> iter = recipients.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Player player = iter.next();
|
||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = player.getName().toLowerCase(Locale.ROOT);
|
||||
if (!event.getMessage().toLowerCase(Locale.ROOT).contains(name)) {
|
||||
ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
||||
if (buffered == null) {
|
||||
bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||
}
|
||||
String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
||||
event.getMessage());
|
||||
buffered.add(full);
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
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) {
|
||||
//todo fix with cfi code 2020-02-04
|
||||
// if (!(entity instanceof ItemFrame)) {
|
||||
// return;
|
||||
// }
|
||||
// ItemFrame itemFrame = (ItemFrame) entity;
|
||||
//
|
||||
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
// HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
||||
// BukkitImageViewer viewer = get(generator);
|
||||
// if (viewer == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (itemFrame.getRotation() != Rotation.NONE) {
|
||||
// itemFrame.setRotation(Rotation.NONE);
|
||||
// }
|
||||
//
|
||||
// LocalSession session = bukkitPlayer.getSession();
|
||||
// BrushTool tool;
|
||||
// try {
|
||||
// tool = session.getBrushTool(bukkitPlayer, false);
|
||||
// } catch (InvalidToolBindException e) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ItemFrame[][] frames = viewer.getItemFrames();
|
||||
// if (frames == null || tool == null) {
|
||||
// viewer.selectFrame(itemFrame);
|
||||
// player.updateInventory();
|
||||
// TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||
// Brush brush = context.getBrush();
|
||||
// if (brush == null) {
|
||||
// return;
|
||||
// }
|
||||
// tool.setContext(context);
|
||||
//
|
||||
// if (event instanceof Cancellable) {
|
||||
// ((Cancellable) event).setCancelled(true);
|
||||
// }
|
||||
//
|
||||
// Location target = itemFrame.getLocation();
|
||||
// Location source = player.getLocation();
|
||||
//
|
||||
// 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 zRat = Math.sin(yawRad) * a;
|
||||
//
|
||||
// BlockFace facing = itemFrame.getFacing();
|
||||
// double thickness = 1 / 32D + 1 / 128D;
|
||||
// double modX = facing.getModX();
|
||||
// double modZ = facing.getModZ();
|
||||
// double dx = source.getX() - target.getX() - modX * thickness;
|
||||
// double dy = source.getY() + player.getEyeHeight() - target.getY();
|
||||
// double dz = source.getZ() - target.getZ() - modZ * thickness;
|
||||
//
|
||||
// double offset;
|
||||
// double localX;
|
||||
// if (modX != 0) {
|
||||
// offset = dx / xRat;
|
||||
// localX = (-modX) * (dz - offset * zRat);
|
||||
// } else {
|
||||
// offset = dz / zRat;
|
||||
// localX = (modZ) * (dx - offset * xRat);
|
||||
// }
|
||||
// double localY = dy - offset * Math.sin(pitchRad);
|
||||
// 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++) {
|
||||
// for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
||||
// if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
||||
// int pixelX = localPixelX + blockX * 128;
|
||||
// int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
||||
//
|
||||
// int width = generator.getWidth();
|
||||
// int length = generator.getLength();
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
// bukkitPlayer.runAction(() -> {
|
||||
// BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
// viewer.refresh();
|
||||
// int topY = generator
|
||||
// .getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
||||
// 0, 255);
|
||||
// wPos = wPos.withY(topY);
|
||||
//
|
||||
// EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
||||
// .combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
||||
// .build();
|
||||
// ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
// Extent extent = last.get();
|
||||
// if (extent instanceof IQueueExtent) {
|
||||
// last = last.previous();
|
||||
// }
|
||||
// last.setNext(generator);
|
||||
// try {
|
||||
// brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||
// } catch (WorldEditException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// es.flushQueue();
|
||||
// viewer.view(generator);
|
||||
// }, true, true);
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
if (!(entity instanceof ItemFrame)) {
|
||||
return;
|
||||
}
|
||||
ItemFrame itemFrame = (ItemFrame) entity;
|
||||
|
||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
||||
BukkitImageViewer viewer = get(generator);
|
||||
if (viewer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemFrame.getRotation() != Rotation.NONE) {
|
||||
itemFrame.setRotation(Rotation.NONE);
|
||||
}
|
||||
|
||||
LocalSession session = bukkitPlayer.getSession();
|
||||
BrushTool tool;
|
||||
try {
|
||||
tool = session.getBrushTool(bukkitPlayer, false);
|
||||
} catch (InvalidToolBindException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemFrame[][] frames = viewer.getItemFrames();
|
||||
if (frames == null || tool == null) {
|
||||
viewer.selectFrame(itemFrame);
|
||||
player.updateInventory();
|
||||
TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||
Brush brush = context.getBrush();
|
||||
if (brush == null) {
|
||||
return;
|
||||
}
|
||||
tool.setContext(context);
|
||||
|
||||
if (event instanceof Cancellable) {
|
||||
((Cancellable) event).setCancelled(true);
|
||||
}
|
||||
|
||||
Location target = itemFrame.getLocation();
|
||||
Location source = player.getLocation();
|
||||
|
||||
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 zRat = Math.sin(yawRad) * a;
|
||||
|
||||
BlockFace facing = itemFrame.getFacing();
|
||||
double thickness = 1 / 32D + 1 / 128D;
|
||||
double modX = facing.getModX();
|
||||
double modZ = facing.getModZ();
|
||||
double dx = source.getX() - target.getX() - modX * thickness;
|
||||
double dy = source.getY() + player.getEyeHeight() - target.getY();
|
||||
double dz = source.getZ() - target.getZ() - modZ * thickness;
|
||||
|
||||
double offset;
|
||||
double localX;
|
||||
if (modX != 0) {
|
||||
offset = dx / xRat;
|
||||
localX = (-modX) * (dz - offset * zRat);
|
||||
} else {
|
||||
offset = dz / zRat;
|
||||
localX = (modZ) * (dx - offset * xRat);
|
||||
}
|
||||
double localY = dy - offset * Math.sin(pitchRad);
|
||||
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++) {
|
||||
for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
||||
if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
||||
int pixelX = localPixelX + blockX * 128;
|
||||
int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
||||
|
||||
int width = generator.getWidth();
|
||||
int length = generator.getLength();
|
||||
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;
|
||||
}
|
||||
|
||||
bukkitPlayer.runAction(() -> {
|
||||
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
viewer.refresh();
|
||||
int topY = generator
|
||||
.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
||||
0, 255);
|
||||
wPos = wPos.withY(topY);
|
||||
|
||||
EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
||||
.combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
||||
.build();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
Extent extent = last.get();
|
||||
if (extent instanceof IQueueExtent) {
|
||||
last = last.previous();
|
||||
}
|
||||
last.setNext(generator);
|
||||
try {
|
||||
brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
es.flushQueue();
|
||||
viewer.view(generator);
|
||||
}, true, true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
@ -22,17 +22,10 @@ import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
import com.sk89q.worldedit.event.platform.Interaction;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
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 org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -40,13 +33,17 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
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 generator is a virtual world which only the creator can see
|
||||
* - The virtual world is displayed inside the current world
|
||||
* - Block/Chunk/Movement packets need to be handled properly
|
||||
* The CFIPacketListener handles packets for editing the {@link VirtualWorld}.
|
||||
*
|
||||
* <p>
|
||||
* 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 {
|
||||
|
||||
@ -122,7 +119,9 @@ public class CFIPacketListener implements Listener {
|
||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
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);
|
||||
if (gen != null) {
|
||||
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) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (!event.isServerPacket()) return;
|
||||
if (!event.isServerPacket()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Location pos = player.getLocation();
|
||||
@ -172,7 +173,9 @@ public class CFIPacketListener implements Listener {
|
||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.POSITION) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (!event.isServerPacket()) return;
|
||||
if (!event.isServerPacket()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
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) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (!event.isServerPacket()) return;
|
||||
if (!event.isServerPacket()) {
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
@ -260,11 +265,13 @@ public class CFIPacketListener implements Listener {
|
||||
private VirtualWorld getGenerator(Player player) {
|
||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
|
||||
if (vw != null) return vw;
|
||||
if (vw != null) {
|
||||
return vw;
|
||||
}
|
||||
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||
// if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
||||
// return settings.getGenerator();
|
||||
// }
|
||||
// if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
||||
// return settings.getGenerator();
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -272,7 +279,9 @@ public class CFIPacketListener implements Listener {
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<BlockPosition> position = packet.getBlockPositionModifier();
|
||||
BlockPosition loc = position.readSafely(0);
|
||||
if (loc == null) return null;
|
||||
if (loc == null) {
|
||||
return null;
|
||||
}
|
||||
BlockVector3 origin = generator.getOrigin().toBlockPoint();
|
||||
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) {
|
||||
BlockVector3 pt = getRelPos(event, gen);
|
||||
if (pt != null) {
|
||||
if (relative) pt = getRelative(event, pt);
|
||||
if (relative) {
|
||||
pt = getRelative(event, pt);
|
||||
}
|
||||
if (gen.contains(pt)) {
|
||||
event.setCancelled(true);
|
||||
task.run(event, gen, pt);
|
||||
@ -295,7 +306,9 @@ public class CFIPacketListener implements Listener {
|
||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, type) {
|
||||
@Override
|
||||
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
|
||||
@ -309,7 +322,9 @@ public class CFIPacketListener implements Listener {
|
||||
PacketContainer packet = container.getPacket();
|
||||
StructureModifier<EnumWrappers.Direction> dirs = packet.getDirections();
|
||||
EnumWrappers.Direction dir = dirs.readSafely(0);
|
||||
if (dir == null) return pt;
|
||||
if (dir == null) {
|
||||
return pt;
|
||||
}
|
||||
switch (dir.ordinal()) {
|
||||
case 0: return pt.add(0, -1, 0);
|
||||
case 1: return pt.add(0, 1, 0);
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.listener;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
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.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockExpEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
@ -45,6 +44,8 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public abstract class ChunkListener implements Listener {
|
||||
|
||||
private final Logger logger = getLogger(ChunkListener.class);
|
||||
@ -58,10 +59,6 @@ public abstract class ChunkListener implements Listener {
|
||||
PluginManager plm = Bukkit.getPluginManager();
|
||||
Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin();
|
||||
plm.registerEvents(this, plugin);
|
||||
try {
|
||||
plm.registerEvents(new ChunkListener_8Plus(this), plugin);
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
TaskManager.IMP.repeat(() -> {
|
||||
Location tmpLoc = lastCancelPos;
|
||||
if (tmpLoc != null) {
|
||||
@ -98,7 +95,8 @@ public abstract class ChunkListener implements Listener {
|
||||
|
||||
protected final Long2ObjectOpenHashMap<Boolean> badChunks = 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;
|
||||
|
||||
public int[] getCount(int cx, int cz) {
|
||||
@ -138,6 +136,11 @@ public abstract class ChunkListener implements Listener {
|
||||
physCancel = false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockExplodeEvent event) {
|
||||
reset();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockBurnEvent event) {
|
||||
reset();
|
||||
@ -250,14 +253,6 @@ public abstract class ChunkListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// switch (event.getChangedType()) {
|
||||
// case AIR:
|
||||
// case CAVE_AIR:
|
||||
// case VOID_AIR:
|
||||
// break;
|
||||
// case REDSTONE_WIRE::
|
||||
// return;
|
||||
// }
|
||||
Exception e = new Exception();
|
||||
int depth = getDepth(e);
|
||||
if (depth >= 256) {
|
||||
@ -354,9 +349,7 @@ public abstract class ChunkListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent FireWorks from loading chunks
|
||||
*
|
||||
* @param event
|
||||
* Prevent firework from loading chunks.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
|
@ -9,12 +9,12 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
public class ChunkListener_9 extends ChunkListener {
|
||||
public class ChunkListener9 extends ChunkListener {
|
||||
|
||||
private Exception exception;
|
||||
private StackTraceElement[] elements;
|
||||
|
||||
public ChunkListener_9() {
|
||||
public ChunkListener9() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -64,7 +64,6 @@ public class ChunkListener_9 extends ChunkListener {
|
||||
cancelNearby(cx, cz);
|
||||
event.setCancelled(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.config.Settings;
|
||||
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.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,6 +15,11 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
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 {
|
||||
|
||||
private final Map<UUID, int[]> views = new ConcurrentHashMap<>();
|
||||
@ -32,7 +33,9 @@ public class RenderListener implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (views.isEmpty()) return;
|
||||
if (views.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
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));
|
||||
long spent = System.currentTimeMillis() - now;
|
||||
if (spent > 5) {
|
||||
if (spent > 10)
|
||||
if (spent > 10) {
|
||||
value[1] = nowTick + 20;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,9 @@ public class PluginPreloader extends PluginBase {
|
||||
loaded = region.getChunks();
|
||||
Iterator<BlockVector2> iter = loaded.iterator();
|
||||
|
||||
if (!invalidator.get()) return;
|
||||
if (!invalidator.get()) {
|
||||
return;
|
||||
}
|
||||
Fawe.get().getQueueHandler().syncWhenFree(() -> {
|
||||
for (; iter.hasNext() && invalidator.get();index++) {
|
||||
BlockVector2 chunk = iter.next();
|
||||
@ -95,22 +97,26 @@ public class PluginPreloader extends PluginBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull File getDataFolder() {
|
||||
@NotNull
|
||||
public File getDataFolder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PluginDescriptionFile getDescription() {
|
||||
@NotNull
|
||||
public PluginDescriptionFile getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FileConfiguration getConfig() {
|
||||
@NotNull
|
||||
public FileConfiguration getConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable InputStream getResource(@NotNull String filename) {
|
||||
@Nullable
|
||||
public InputStream getResource(@NotNull String filename) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -135,12 +141,14 @@ public class PluginPreloader extends PluginBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PluginLoader getPluginLoader() {
|
||||
@NotNull
|
||||
public PluginLoader getPluginLoader() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Server getServer() {
|
||||
@NotNull
|
||||
public Server getServer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -175,12 +183,14 @@ public class PluginPreloader extends PluginBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
|
||||
@Nullable
|
||||
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Logger getLogger() {
|
||||
@NotNull
|
||||
public Logger getLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -190,7 +200,8 @@ public class PluginPreloader extends PluginBase {
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventException;
|
||||
@ -17,6 +16,9 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FreeBuildRegion extends BukkitMaskManager {
|
||||
private final ArrayList<RegisteredListener> listeners;
|
||||
|
||||
@ -25,8 +27,12 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
||||
this.listeners = new ArrayList<>();
|
||||
RegisteredListener[] listeners = BlockBreakEvent.getHandlerList().getRegisteredListeners();
|
||||
for (RegisteredListener listener : listeners) {
|
||||
if (listener.getPriority() == EventPriority.MONITOR) continue;
|
||||
if (!listener.isIgnoringCancelled()) continue;
|
||||
if (listener.getPriority() == EventPriority.MONITOR) {
|
||||
continue;
|
||||
}
|
||||
if (!listener.isIgnoringCancelled()) {
|
||||
continue;
|
||||
}
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
}
|
||||
@ -38,14 +44,20 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(Player player, MaskType type) {
|
||||
if (type != MaskType.MEMBER) return null;
|
||||
if (type != MaskType.MEMBER) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<RegisteredListener> currRegList = new ArrayList<>();
|
||||
for (RegisteredListener listener : this.listeners) {
|
||||
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);
|
||||
}
|
||||
if (currRegList.isEmpty()) return null;
|
||||
if (currRegList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]);
|
||||
|
||||
World bukkitWorld = BukkitAdapter.adapt(player.getWorld());
|
||||
@ -73,12 +85,15 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
||||
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;
|
||||
|
||||
@Override
|
||||
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;
|
||||
lastZ = z;
|
||||
event.setCancelled(false);
|
||||
|
@ -43,7 +43,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
final Location pos2 = area.getHighLoc();
|
||||
final ClaimedResidence finalResidence = residence;
|
||||
return new FaweMask(new CuboidRegion(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2))) {
|
||||
@Override
|
||||
@Override
|
||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||
return isAllowed(BukkitAdapter.adapt(player), finalResidence, type);
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
if (block.getResident().equals(resident)) {
|
||||
return true;
|
||||
}
|
||||
} catch (NotRegisteredException ignore) {}
|
||||
} catch (NotRegisteredException ignored) {
|
||||
}
|
||||
Town town = block.getTown();
|
||||
if (town.isMayor(resident)) {
|
||||
return true;
|
||||
@ -54,7 +55,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (NotRegisteredException ignore) {}
|
||||
} catch (NotRegisteredException ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -87,7 +89,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
private final WorldGuardPlugin worldguard;
|
||||
|
||||
@ -63,7 +65,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ()));
|
||||
//Merge WorldGuardFlag
|
||||
if(player.hasPermission("fawe.worldguardflag") && !regions.testState(player, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK)){
|
||||
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(player, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK)) {
|
||||
return null;
|
||||
}
|
||||
for (ProtectedRegion region : regions) {
|
||||
@ -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 "*".
|
||||
if (region.isOwner(localplayer) || region.isOwner(localplayer.getName())) {
|
||||
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;
|
||||
} else if (region.getId().toLowerCase().contains(localplayer.getName().toLowerCase() + "//")) {
|
||||
} else if (region.getId().toLowerCase(Locale.ROOT).contains(localplayer.getName().toLowerCase(Locale.ROOT) + "//")) {
|
||||
return true;
|
||||
} else if (region.isOwner("*")) {
|
||||
return true;
|
||||
@ -90,8 +92,9 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
if (localplayer.hasPermission("fawe.worldguard.member")) {
|
||||
if (region.isMember(localplayer) || region.isMember(localplayer.getName())) {
|
||||
return true;
|
||||
} else
|
||||
} else {
|
||||
return region.isMember("*");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -122,8 +125,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
}
|
||||
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ public class FaweRegionManager extends RegionManager {
|
||||
clipboard.setBlocks(fillingRegion, filling);
|
||||
clipboard.setBlocks(floorRegion, plotfloor);
|
||||
clipboard.setBlocks(airRegion, air);
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x ++) {
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z ++) {
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||
clipboard.setBiome(BlockVector2.at(x, z), biome);
|
||||
}
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class FaweRegionManager extends RegionManager {
|
||||
//todo because of the following code this should proably be in the Bukkit module
|
||||
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
|
||||
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
|
||||
WorldEdit.getInstance().getEditSessionFactory().getEditSession(pos1World,-1);
|
||||
WorldEdit.getInstance().getEditSessionFactory().getEditSession(pos1World, -1);
|
||||
EditSession sessionA = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession sessionB = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.regions.plotsquared;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
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.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -39,7 +39,8 @@ import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
|
||||
public class FaweSchematicHandler extends SchematicHandler {
|
||||
@Override
|
||||
|
@ -62,7 +62,7 @@ public class MoveTo512 /*extends Command*/ {
|
||||
// if (yMax != 15) {
|
||||
// Arrays.fill(ids, yMax158 + 256, 4096, (byte) 0);
|
||||
// }
|
||||
// } else if (layer == 0){
|
||||
// } else if (layer == 0) {
|
||||
// Arrays.fill(ids, 256, 4096, (byte) 3);
|
||||
// Arrays.fill(ids, 0, 256, (byte) 7);
|
||||
// } else {
|
||||
@ -113,7 +113,7 @@ public class MoveTo512 /*extends Command*/ {
|
||||
// int yMax158 = yMax15 << 8;
|
||||
// Arrays.fill(ids, yMax158 + 256, 4096, (byte) 0);
|
||||
// }
|
||||
// } else if (layer == 0){
|
||||
// } else if (layer == 0) {
|
||||
// Arrays.fill(ids, 256, 4096, (byte) hpw.ROAD_BLOCK.id);
|
||||
// Arrays.fill(ids, 0, 256, (byte) 7);
|
||||
// } else {
|
||||
|
@ -1,14 +1,15 @@
|
||||
package com.boydti.fawe.bukkit.regions.plotsquared;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
private final PlotArea area;
|
||||
|
||||
@ -16,6 +17,7 @@ public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
checkNotNull(area);
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
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.Biomes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "generatebiome",
|
||||
|
@ -23,13 +23,15 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
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.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 {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PlotSquaredFeature.class);
|
||||
@ -46,15 +48,15 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
} catch (Throwable ignored) {
|
||||
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();
|
||||
}
|
||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||
new PlotSetBiome();
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: revisit this later on
|
||||
/*
|
||||
// TODO: revisit this later on
|
||||
/*
|
||||
try {
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
new ReplaceAll();
|
||||
@ -62,7 +64,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
} catch (Throwable e) {
|
||||
log.debug("You need to update PlotSquared to access the CFI and REPLACEALL commands");
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
@ -93,12 +95,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
return false;
|
||||
}
|
||||
UUID uid = player.getUniqueId();
|
||||
return !plot.getFlag(NoWorldeditFlag.class) && (plot.isOwner(uid)
|
||||
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
|
||||
.contains(DBFunc.EVERYONE)
|
||||
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
|
||||
&& player.hasPermission("fawe.plotsquared.member")) || player
|
||||
.hasPermission("fawe.plotsquared.admin"));
|
||||
return !plot.getFlag(NoWorldeditFlag.class) && (plot.isOwner(uid) || type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot
|
||||
.getTrusted().contains(DBFunc.EVERYONE) || (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player
|
||||
.hasPermission("fawe.plotsquared.member")) || player.hasPermission("fawe.plotsquared.admin"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -141,7 +140,10 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
maskedRegion = new CuboidRegion(pos1, pos2);
|
||||
} else {
|
||||
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) {
|
||||
@ -158,7 +160,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||
if (area != null) return new PlotRegionFilter(area);
|
||||
if (area != null) {
|
||||
return new PlotRegionFilter(area);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
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.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
|
||||
public class FaweChunkManager extends ChunkManager {
|
||||
|
||||
private ChunkManager parent;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
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.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -39,7 +39,8 @@ import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
|
||||
public class FaweSchematicHandler extends SchematicHandler {
|
||||
@Override
|
||||
|
@ -1,14 +1,15 @@
|
||||
package com.boydti.fawe.bukkit.regions.plotsquaredv4;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
private final PlotArea area;
|
||||
|
||||
@ -16,6 +17,7 @@ public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
checkNotNull(area);
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
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.database.DBFunc;
|
||||
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.object.Plot;
|
||||
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.SchematicHandler;
|
||||
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.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PlotSquaredFeature extends FaweMaskManager {
|
||||
|
||||
@ -48,17 +47,17 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
setupSchematicHandler();
|
||||
setupChunkManager();
|
||||
} 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();
|
||||
}
|
||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||
new PlotSetBiome();
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: revisit this later on
|
||||
/*
|
||||
// TODO: revisit this later on
|
||||
/*
|
||||
try {
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
new ReplaceAll();
|
||||
@ -66,7 +65,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
} catch (Throwable e) {
|
||||
log.debug("You need to update PlotSquared to access the CFI and REPLACEALL commands");
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
@ -149,8 +148,8 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
} else {
|
||||
World world = FaweAPI.getWorld(area.worldname);
|
||||
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());
|
||||
.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);
|
||||
}
|
||||
|
||||
@ -168,7 +167,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||
if (area != null) return new PlotRegionFilter(area);
|
||||
if (area != null) {
|
||||
return new PlotRegionFilter(area);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,9 @@ public class ItemUtil {
|
||||
public Object getNMSItem(ItemStack item) {
|
||||
try {
|
||||
Object nmsItem = fieldHandle.get(item);
|
||||
if (nmsItem == null) nmsItem = methodAsNMSCopy.invoke(null, item);
|
||||
if (nmsItem == null) {
|
||||
nmsItem = methodAsNMSCopy.invoke(null, item);
|
||||
}
|
||||
return nmsItem;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -57,12 +59,18 @@ public class ItemUtil {
|
||||
|
||||
public CompoundTag getNBT(ItemStack item) {
|
||||
try {
|
||||
if (!item.hasItemMeta()) return null;
|
||||
if (!item.hasItemMeta()) {
|
||||
return null;
|
||||
}
|
||||
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)) {
|
||||
Object nmsTag = methodGetTag.invoke(nmsItem);
|
||||
if (nmsTag == null) return null;
|
||||
if (nmsTag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Int2ObjectOpenHashMap<WeakReference<Tag>> map = hashToNMSTag.get();
|
||||
if (map == null) {
|
||||
@ -72,7 +80,9 @@ public class ItemUtil {
|
||||
WeakReference<Tag> nativeTagRef = map.get(nmsTag.hashCode());
|
||||
if (nativeTagRef != null) {
|
||||
Tag nativeTag = nativeTagRef.get();
|
||||
if (nativeTag != null) return (CompoundTag) nativeTag;
|
||||
if (nativeTag != null) {
|
||||
return (CompoundTag) nativeTag;
|
||||
}
|
||||
}
|
||||
Tag nativeTag = adapter.toNative(nmsTag);
|
||||
map.put(nmsTag.hashCode(), new WeakReference<>(nativeTag));
|
||||
@ -94,7 +104,9 @@ public class ItemUtil {
|
||||
}
|
||||
Object nmsTag = adapter.fromNative(tag);
|
||||
methodSetTag.invoke(nmsItem, nmsTag);
|
||||
if (copy) return (ItemStack) methodAsBukkitCopy.invoke(null, nmsItem);
|
||||
if (copy) {
|
||||
return (ItemStack) methodAsBukkitCopy.invoke(null, nmsItem);
|
||||
}
|
||||
return item;
|
||||
} catch (Throwable e) {
|
||||
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.ImageUtil;
|
||||
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.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -25,6 +20,12 @@ import org.inventivetalent.mapmanager.controller.MultiMapController;
|
||||
import org.inventivetalent.mapmanager.manager.MapManager;
|
||||
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 {
|
||||
private final MapManager mapManager;
|
||||
private final Player player;
|
||||
@ -116,7 +117,9 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
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) {
|
||||
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;
|
||||
|
||||
if (this.frames != null) {
|
||||
if (image == null && drawable != null) image = drawable.draw();
|
||||
if (image == null && drawable != null) {
|
||||
image = drawable.draw();
|
||||
}
|
||||
last = image;
|
||||
int width = frames.length;
|
||||
int height = frames[0].length;
|
||||
@ -158,7 +165,9 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
} else if (player.getInventory().getHeldItemSlot() != slot) {
|
||||
player.getInventory().setHeldItemSlot(slot);
|
||||
}
|
||||
if (image == null && drawable != null) image = drawable.draw();
|
||||
if (image == null && drawable != null) {
|
||||
image = drawable.draw();
|
||||
}
|
||||
last = image;
|
||||
BufferedImage scaled = ImageUtil.getScaledInstance(image, 128, 128, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||
MapWrapper mapWrapper = mapManager.wrapImage(scaled);
|
||||
@ -181,7 +190,9 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
if (last != null) view(last, null);
|
||||
if (last != null) {
|
||||
view(last, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,13 +107,13 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setCombinedId(int combinedId) {
|
||||
return world.setBlock(x, y, z, BlockState.getFromInternalId(combinedId));
|
||||
public boolean setTypeIdAndPropertyId(int id, int propertyId) {
|
||||
return setCombinedId(id + (propertyId << BlockTypesCache.BIT_OFFSET));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setTypeIdAndPropertyId(int id, int propertyId) {
|
||||
return setCombinedId(id + (propertyId << BlockTypesCache.BIT_OFFSET));
|
||||
public boolean setCombinedId(int combinedId) {
|
||||
return world.setBlock(x, y, z, BlockState.getFromInternalId(combinedId));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -361,6 +361,10 @@ public class AsyncBlock implements Block {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool));
|
||||
}
|
||||
|
||||
public Collection<ItemStack> getDrops(ItemStack tool, Entity entity) {
|
||||
return Collections.emptyList(); //todo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) {
|
||||
this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue);
|
||||
@ -409,12 +413,9 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockSoundGroup getSoundGroup() {
|
||||
@NotNull
|
||||
public BlockSoundGroup 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
|
||||
public @NotNull BlockState[] getTileEntities(boolean useSnapshot) {
|
||||
@NotNull
|
||||
public BlockState[] getTileEntities(boolean useSnapshot) {
|
||||
if (!isLoaded()) {
|
||||
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.TaskManager;
|
||||
import com.destroystokyo.paper.HeightmapType;
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
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.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import io.papermc.paper.world.MoonPhase;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -60,7 +62,6 @@ import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import io.papermc.paper.world.MoonPhase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
@ -81,6 +82,7 @@ import java.util.function.Predicate;
|
||||
* @see #wrap(World)
|
||||
* @see #create(WorldCreator)
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
private World parent;
|
||||
@ -93,9 +95,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent Parent world
|
||||
* @param autoQueue
|
||||
* @deprecated use {@link #wrap(World)} instead
|
||||
* An internal constructor for using a world asynchronously in FAWE. Do not use!
|
||||
*/
|
||||
@Deprecated
|
||||
public AsyncWorld(World parent, boolean autoQueue) {
|
||||
@ -107,9 +107,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param extent
|
||||
* @deprecated use {@link #wrap(World)} instead
|
||||
* An internal constructor for using a world asynchronously in FAWE. Do not use!
|
||||
*/
|
||||
@Deprecated
|
||||
public AsyncWorld(World parent, Extent extent) {
|
||||
@ -120,9 +118,6 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
/**
|
||||
* Wrap a world for async usage.
|
||||
*
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
public static AsyncWorld wrap(World world) {
|
||||
if (world instanceof AsyncWorld) {
|
||||
@ -141,13 +136,11 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a world async (untested)
|
||||
* - Only optimized for 1.10
|
||||
*
|
||||
* @param creator
|
||||
* @return
|
||||
* Create a world async. This is not tested and may be removed in the future due to
|
||||
* synchronization problems.
|
||||
*/
|
||||
public synchronized static AsyncWorld create(final WorldCreator creator) {
|
||||
@Beta
|
||||
public static synchronized AsyncWorld create(final WorldCreator creator) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
@Nullable World world = adapter.createWorld(creator);
|
||||
return wrap(world);
|
||||
@ -164,7 +157,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull WorldBorder getWorldBorder() {
|
||||
@NotNull
|
||||
public WorldBorder getWorldBorder() {
|
||||
return TaskManager.IMP.sync(() -> parent.getWorldBorder());
|
||||
}
|
||||
|
||||
@ -238,12 +232,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AsyncBlock getBlockAt(Location loc) {
|
||||
@NotNull
|
||||
public AsyncBlock getBlockAt(Location loc) {
|
||||
return getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
@ -264,13 +260,15 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AsyncBlock getHighestBlockAt(int x, int z) {
|
||||
@NotNull
|
||||
public AsyncBlock getHighestBlockAt(int x, int z) {
|
||||
int y = getHighestBlockYAt(x, z);
|
||||
return getBlockAt(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AsyncBlock getHighestBlockAt(Location loc) {
|
||||
@NotNull
|
||||
public AsyncBlock getHighestBlockAt(Location loc) {
|
||||
return getHighestBlockAt(loc.getBlockX(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
@ -285,28 +283,33 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Block getHighestBlockAt(@NotNull Location location,
|
||||
@NotNull HeightMap heightMap) {
|
||||
@NotNull
|
||||
public Block getHighestBlockAt(@NotNull Location location,
|
||||
@NotNull HeightMap heightMap) {
|
||||
return parent.getHighestBlockAt(location, heightMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AsyncChunk getChunkAt(int x, int z) {
|
||||
@NotNull
|
||||
public AsyncChunk getChunkAt(int x, int z) {
|
||||
return new AsyncChunk(this, x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AsyncChunk getChunkAt(Location location) {
|
||||
@NotNull
|
||||
public AsyncChunk getChunkAt(Location location) {
|
||||
return getChunkAt(location.getBlockX(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AsyncChunk getChunkAt(Block block) {
|
||||
@NotNull
|
||||
public AsyncChunk getChunkAt(Block block) {
|
||||
return getChunkAt(block.getX(), block.getZ());
|
||||
}
|
||||
|
||||
@ -320,6 +323,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
return chunk.isLoaded();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Chunk[] getLoadedChunks() {
|
||||
return parent.getLoadedChunks();
|
||||
@ -357,6 +361,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isChunkInUse(int x, int z) {
|
||||
return parent.isChunkInUse(x, z);
|
||||
}
|
||||
@ -411,6 +416,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean regenerateChunk(final int x, final int z) {
|
||||
return TaskManager.IMP.sync(() -> parent.regenerateChunk(x, z));
|
||||
}
|
||||
@ -422,104 +428,148 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Item dropItemNaturally(final @NotNull Location location,
|
||||
final @NotNull ItemStack item) {
|
||||
@NotNull
|
||||
public Item dropItemNaturally(
|
||||
@NotNull
|
||||
final Location location,
|
||||
@NotNull
|
||||
final ItemStack item) {
|
||||
return TaskManager.IMP.sync(() -> parent.dropItemNaturally(location, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Arrow spawnArrow(final @NotNull Location location,
|
||||
final @NotNull Vector direction, final float speed, final float spread) {
|
||||
@NotNull
|
||||
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));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@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) {
|
||||
return parent.spawnArrow(location, direction, speed, spread, clazz);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(final @NotNull Location loc, final @NotNull TreeType type,
|
||||
final @NotNull BlockChangeDelegate delegate) {
|
||||
public boolean generateTree(
|
||||
@NotNull
|
||||
final Location loc, @NotNull
|
||||
final TreeType type,
|
||||
@NotNull
|
||||
final BlockChangeDelegate delegate) {
|
||||
return TaskManager.IMP.sync(() -> parent.generateTree(loc, type, delegate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Entity spawnEntity(@NotNull Location loc, EntityType type) {
|
||||
@NotNull
|
||||
public Entity spawnEntity(@NotNull Location loc, EntityType type) {
|
||||
return spawn(loc, type.getEntityClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull LightningStrike strikeLightning(final @NotNull Location loc) {
|
||||
@NotNull
|
||||
public LightningStrike strikeLightning(
|
||||
@NotNull
|
||||
final Location loc) {
|
||||
return TaskManager.IMP.sync(() -> parent.strikeLightning(loc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull LightningStrike strikeLightningEffect(final @NotNull Location loc) {
|
||||
@NotNull
|
||||
public LightningStrike strikeLightningEffect(
|
||||
@NotNull
|
||||
final Location loc) {
|
||||
return TaskManager.IMP.sync(() -> parent.strikeLightningEffect(loc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List getEntities() {
|
||||
@NotNull
|
||||
public List getEntities() {
|
||||
return TaskManager.IMP.sync(() -> parent.getEntities());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<LivingEntity> getLivingEntities() {
|
||||
@NotNull
|
||||
public List<LivingEntity> getLivingEntities() {
|
||||
return TaskManager.IMP.sync(() -> parent.getLivingEntities());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@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));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends Entity> @NotNull Collection<T> getEntitiesByClass(
|
||||
final @NotNull Class<T> cls) {
|
||||
public <T extends Entity> Collection<T> getEntitiesByClass(
|
||||
@NotNull
|
||||
final Class<T> cls) {
|
||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Player> getPlayers() {
|
||||
@NotNull
|
||||
public List<Player> getPlayers() {
|
||||
return TaskManager.IMP.sync(() -> parent.getPlayers());
|
||||
}
|
||||
|
||||
@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) {
|
||||
return TaskManager.IMP.sync(() -> parent.getNearbyEntities(location, x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return parent.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull UUID getUID() {
|
||||
@NotNull
|
||||
public UUID getUID() {
|
||||
return parent.getUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Location getSpawnLocation() {
|
||||
@NotNull
|
||||
public Location getSpawnLocation() {
|
||||
return parent.getSpawnLocation();
|
||||
}
|
||||
|
||||
@ -534,7 +584,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull MoonPhase getMoonPhase() {
|
||||
@NotNull
|
||||
public MoonPhase getMoonPhase() {
|
||||
return parent.getMoonPhase();
|
||||
}
|
||||
|
||||
@ -669,45 +720,52 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<BlockPopulator> getPopulators() {
|
||||
@NotNull
|
||||
public List<BlockPopulator> getPopulators() {
|
||||
return parent.getPopulators();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(final @NotNull Location location,
|
||||
final @NotNull Class<T> clazz) throws IllegalArgumentException {
|
||||
public <T extends Entity> T spawn(@NotNull final Location location, @NotNull final Class<T> clazz) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@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 {
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||
@Nullable Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason)
|
||||
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||
@Nullable Consumer<T> function, @NotNull
|
||||
CreatureSpawnEvent.SpawnReason reason)
|
||||
throws IllegalArgumentException {
|
||||
return null;
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function, reason));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull MaterialData data) throws IllegalArgumentException {
|
||||
@NotNull
|
||||
public FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull MaterialData data) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, data));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull Material material, byte data) throws IllegalArgumentException {
|
||||
@NotNull
|
||||
public FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull Material material, byte data) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull BlockData blockData) throws IllegalArgumentException {
|
||||
@NotNull
|
||||
public FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull BlockData blockData) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
|
||||
}
|
||||
|
||||
@ -717,7 +775,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
@ -733,7 +794,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
@ -744,8 +808,9 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z,
|
||||
final boolean includeBiome, final boolean includeBiomeTempRain) {
|
||||
@NotNull
|
||||
public ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z,
|
||||
final boolean includeBiome, final boolean includeBiomeTempRain) {
|
||||
return TaskManager.IMP
|
||||
.sync(() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain));
|
||||
}
|
||||
@ -766,12 +831,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@ -788,6 +855,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public double getTemperature(int x, int z) {
|
||||
return parent.getTemperature(x, z);
|
||||
}
|
||||
@ -798,6 +866,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public double getHumidity(int x, int z) {
|
||||
return parent.getHumidity(x, z);
|
||||
}
|
||||
@ -848,16 +917,19 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Difficulty getDifficulty() {
|
||||
@NotNull
|
||||
public Difficulty getDifficulty() {
|
||||
return parent.getDifficulty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull File getWorldFolder() {
|
||||
@NotNull
|
||||
public File getWorldFolder() {
|
||||
return parent.getWorldFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WorldType getWorldType() {
|
||||
return parent.getWorldType();
|
||||
}
|
||||
@ -948,7 +1020,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
@ -959,7 +1034,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
@ -991,17 +1069,20 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getGameRules() {
|
||||
return parent.getGameRules();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getGameRuleValue(String rule) {
|
||||
return parent.getGameRuleValue(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) {
|
||||
return parent.setGameRuleValue(rule, value);
|
||||
}
|
||||
@ -1012,6 +1093,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <T> T getGameRuleValue(@NotNull GameRule<T> gameRule) {
|
||||
return parent.getGameRuleValue(gameRule);
|
||||
}
|
||||
@ -1027,22 +1109,28 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Spigot spigot() {
|
||||
@NotNull
|
||||
public Spigot spigot() {
|
||||
return parent.spigot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Raid locateNearestRaid(@NotNull Location location, int i) {
|
||||
@Nullable
|
||||
public Raid locateNearestRaid(@NotNull Location location, int i) {
|
||||
return parent.locateNearestRaid(location, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Raid> getRaids() {
|
||||
@NotNull
|
||||
public List<Raid> getRaids() {
|
||||
return parent.getRaids();
|
||||
}
|
||||
|
||||
@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>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -1052,7 +1140,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<MetadataValue> getMetadata(@NotNull String key) {
|
||||
@NotNull
|
||||
public List<MetadataValue> getMetadata(@NotNull String key) {
|
||||
return parent.getMetadata(key);
|
||||
}
|
||||
|
||||
@ -1062,7 +1151,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -1072,12 +1164,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<String> getListeningPluginChannels() {
|
||||
@NotNull
|
||||
public Set<String> getListeningPluginChannels() {
|
||||
return parent.getListeningPluginChannels();
|
||||
}
|
||||
|
||||
@ -1086,19 +1180,22 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0) {
|
||||
@NotNull
|
||||
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0) {
|
||||
return parent.getNearbyEntities(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0,
|
||||
Predicate<Entity> arg1) {
|
||||
@NotNull
|
||||
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0,
|
||||
Predicate<Entity> arg1) {
|
||||
return parent.getNearbyEntities(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1,
|
||||
double arg2, double arg3, Predicate<Entity> arg4) {
|
||||
@NotNull
|
||||
public Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1,
|
||||
double arg2, double arg3, Predicate<Entity> arg4) {
|
||||
return parent.getNearbyEntities(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@ -1196,7 +1293,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Chunk> getForceLoadedChunks() {
|
||||
@NotNull
|
||||
public Collection<Chunk> getForceLoadedChunks() {
|
||||
return parent.getForceLoadedChunks();
|
||||
}
|
||||
|
||||
@ -1216,18 +1314,22 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Plugin> getPluginChunkTickets(int x, int z) {
|
||||
@NotNull
|
||||
public Collection<Plugin> getPluginChunkTickets(int x, int z) {
|
||||
return getBukkitWorld().getPluginChunkTickets(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
|
||||
@NotNull
|
||||
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
|
||||
return getBukkitWorld().getPluginChunkTickets();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getHighestBlockYAt(int x, int z,
|
||||
com.destroystokyo.paper.@NotNull HeightmapType heightmap)
|
||||
@NotNull
|
||||
com.destroystokyo.paper.HeightmapType heightmap)
|
||||
throws UnsupportedOperationException {
|
||||
return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap));
|
||||
}
|
||||
@ -1258,14 +1360,16 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Chunk> getChunkAtAsync(int arg0, int arg1, boolean arg2) {
|
||||
return parent.getChunkAtAsync(arg0, arg1, arg2);
|
||||
@NotNull
|
||||
public CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen) {
|
||||
return parent.getChunkAtAsync(x, z, gen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen,
|
||||
boolean urgent) {
|
||||
return null;
|
||||
@NotNull
|
||||
public CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen,
|
||||
boolean urgent) {
|
||||
return parent.getChunkAtAsync(x, z, gen, urgent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1274,16 +1378,19 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void getChunkAtAsync(int x, int z, @NotNull ChunkLoadCallback cb) {
|
||||
parent.getChunkAtAsync(x, z, cb);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void getChunkAtAsync(@NotNull Location location, @NotNull ChunkLoadCallback cb) {
|
||||
parent.getChunkAtAsync(location, cb);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void getChunkAtAsync(@NotNull Block block, @NotNull ChunkLoadCallback cb) {
|
||||
parent.getChunkAtAsync(block, cb);
|
||||
}
|
||||
@ -1343,20 +1450,25 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightmapType heightmap)
|
||||
throws UnsupportedOperationException {
|
||||
return parent.getHighestBlockYAt(location, heightmap);
|
||||
}
|
||||
|
||||
@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 {
|
||||
return parent.getHighestBlockAt(x, z, heightmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Block getHighestBlockAt(@NotNull Location location,
|
||||
@NotNull HeightmapType heightmap) throws UnsupportedOperationException {
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public Block getHighestBlockAt(@NotNull Location location,
|
||||
@NotNull HeightmapType heightmap) throws UnsupportedOperationException {
|
||||
return parent.getHighestBlockAt(location, heightmap);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,12 @@ package com.boydti.fawe.bukkit.wrapper.state;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
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.HashMap;
|
||||
@ -11,13 +17,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
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 {
|
||||
private final CompoundTag root;
|
||||
|
||||
@ -38,7 +37,9 @@ public final class AsyncDataContainer implements PersistentDataContainer {
|
||||
CompoundTag tag = root();
|
||||
Map<String, Tag> raw;
|
||||
if (tag == null) {
|
||||
if (!create) return Collections.emptyMap();
|
||||
if (!create) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Tag> map = root.getValue();
|
||||
map.put("PublicBukkitValues", new CompoundTag(raw = new HashMap<>()));
|
||||
} 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(type, "The provided type for the custom value was null");
|
||||
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();
|
||||
}
|
||||
|
||||
@ -106,7 +109,7 @@ public final class AsyncDataContainer implements PersistentDataContainer {
|
||||
return false;
|
||||
} else {
|
||||
Map<String, Tag> myRawMap = this.getRaw();
|
||||
Map<String, Tag> theirRawMap = ((AsyncDataContainer)obj).getRaw();
|
||||
Map<String, Tag> theirRawMap = ((AsyncDataContainer) obj).getRaw();
|
||||
return Objects.equals(myRawMap, theirRawMap);
|
||||
}
|
||||
}
|
||||
|
@ -8,15 +8,15 @@ import com.sk89q.jnbt.Tag;
|
||||
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.legacy.LegacyComponentSerializer;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
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 AsyncSign(AsyncBlock block, BaseBlock state) {
|
||||
@ -38,12 +38,16 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
||||
}
|
||||
|
||||
private String fromJson(String jsonInput) {
|
||||
if (jsonInput == null || jsonInput.isEmpty()) return "";
|
||||
if (jsonInput == null || jsonInput.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return GsonComponentSerializer.INSTANCE.deserialize(jsonInput).toString();
|
||||
}
|
||||
|
||||
private String toJson(String oldInput) {
|
||||
if (oldInput == null || oldInput.isEmpty()) return "";
|
||||
if (oldInput == null || oldInput.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return LegacyComponentSerializer.INSTANCE.serialize(TextComponent.of(oldInput));
|
||||
}
|
||||
|
||||
@ -73,16 +77,20 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PersistentDataContainer getPersistentDataContainer() {
|
||||
@NotNull
|
||||
public PersistentDataContainer getPersistentDataContainer() {
|
||||
return new AsyncDataContainer(getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable DyeColor getColor() {
|
||||
@Nullable
|
||||
public DyeColor getColor() {
|
||||
CompoundTag nbt = getNbtData();
|
||||
if (nbt != null) {
|
||||
String color = nbt.getString("Color").toUpperCase();
|
||||
if (!color.isEmpty()) return DyeColor.valueOf(color);
|
||||
String color = nbt.getString("Color").toUpperCase(Locale.ROOT);
|
||||
if (!color.isEmpty()) {
|
||||
return DyeColor.valueOf(color);
|
||||
}
|
||||
}
|
||||
return DyeColor.BLACK;
|
||||
}
|
||||
@ -92,7 +100,7 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
||||
CompoundTag nbt = getNbtData();
|
||||
if (nbt != null) {
|
||||
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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
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.item.ItemType;
|
||||
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 org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -55,6 +50,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.
|
||||
*/
|
||||
@ -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 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
|
||||
* @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
|
||||
* @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
|
||||
* @return The Bukkit Material
|
||||
@ -345,7 +346,7 @@ public enum BukkitAdapter {
|
||||
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
|
||||
* @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
|
||||
* @return The itemtype
|
||||
@ -370,7 +371,7 @@ public enum BukkitAdapter {
|
||||
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
|
||||
* @return The WorldEdit BlockState
|
||||
@ -382,7 +383,7 @@ public enum BukkitAdapter {
|
||||
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
|
||||
* @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
|
||||
* @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
|
||||
* @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
|
||||
* @return The Bukkit ItemStack
|
||||
|
@ -94,6 +94,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
||||
print(TextComponent.of(part, TextColor.RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
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.world.block.BlockState;
|
||||
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.BundledBlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
@ -46,7 +45,9 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
BlockMaterial result = adapter.getMaterial(blockType);
|
||||
if (result != null) return result;
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Material mat = BukkitAdapter.adapt(blockType);
|
||||
if (mat == null) {
|
||||
@ -69,7 +70,9 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
BlockMaterial result = adapter.getMaterial(state);
|
||||
if (result != null) return result;
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return super.getMaterial(state);
|
||||
}
|
||||
@ -81,6 +84,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
}
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||
|
@ -19,13 +19,9 @@
|
||||
|
||||
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.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import java.util.Optional;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.MapBackedValueStore;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Locale;
|
||||
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 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BukkitCommandInspector.class);
|
||||
|
@ -19,25 +19,24 @@
|
||||
|
||||
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.extension.platform.AbstractNonPlayerActor;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
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.entity.Entity;
|
||||
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 {
|
||||
|
||||
/**
|
||||
@ -45,8 +44,8 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
*/
|
||||
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
|
||||
|
||||
private CommandSender sender;
|
||||
private WorldEditPlugin plugin;
|
||||
private final CommandSender sender;
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
||||
checkNotNull(plugin);
|
||||
@ -68,6 +67,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage(part);
|
||||
@ -75,25 +75,29 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage("\u00A7d" + part);
|
||||
sender.sendMessage("§d" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage("\u00A77" + part);
|
||||
sender.sendMessage("§7" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.sendMessage("\u00A7c" + part);
|
||||
sender.sendMessage("§c" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.Animals;
|
||||
@ -44,6 +42,8 @@ import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
class BukkitEntityProperties implements EntityProperties {
|
||||
|
||||
private final Entity entity;
|
||||
|
@ -14,7 +14,9 @@ public class BukkitEntityRegistry implements EntityRegistry {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
String name = type.getName();
|
||||
if (name != null) {
|
||||
if (name.indexOf(':') == -1) name = "minecraft:" + name;
|
||||
if (name.indexOf(':') == -1) {
|
||||
name = "minecraft:" + name;
|
||||
}
|
||||
types.add(name);
|
||||
}
|
||||
}
|
||||
|
@ -62,12 +62,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitPlayer extends AbstractPlayerActor {
|
||||
@ -173,23 +172,24 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("\u00A7d" + part);
|
||||
player.sendMessage("§d" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("\u00A77" + part);
|
||||
player.sendMessage("§7" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("\u00A7c" + part);
|
||||
player.sendMessage("§c" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
component = Caption.color(TranslatableComponent.of("prefix", component), getLocale());
|
||||
|
@ -44,14 +44,14 @@ import org.enginehub.piston.inject.MapBackedValueStore;
|
||||
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 {
|
||||
|
||||
private WorldEditPlugin plugin;
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
* Construct the object.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
@ -42,10 +42,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
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.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
@ -55,6 +51,11 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
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.
|
||||
*/
|
||||
@ -68,7 +69,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
int getDataVersion();
|
||||
|
||||
/**
|
||||
* Get a data fixer, or null if not supported
|
||||
* Get a data fixer, or null if not supported.
|
||||
*
|
||||
* @return the data fixer
|
||||
*/
|
||||
@ -76,6 +77,8 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
DataFixer getDataFixer();
|
||||
|
||||
/**
|
||||
* Check if this adapter supports the watchdog.
|
||||
*
|
||||
* @return {@code true} if {@link #tickWatchdog()} is implemented
|
||||
*/
|
||||
default boolean supportsWatchdog() {
|
||||
@ -217,14 +220,13 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
return null;
|
||||
}
|
||||
|
||||
default @Nullable World createWorld(WorldCreator creator) {
|
||||
@Nullable
|
||||
default World createWorld(WorldCreator creator) {
|
||||
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a fake chunk packet to a player
|
||||
* @param player
|
||||
* @param packet
|
||||
* Send a fake chunk packet to a player.
|
||||
*/
|
||||
default void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) {
|
||||
throw new UnsupportedOperationException("Cannot send fake chunks");
|
||||
|
@ -1,7 +1,5 @@
|
||||
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.world.block.BlockState;
|
||||
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.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
private int[] itemTypes;
|
||||
private int[] blockTypes;
|
||||
@ -25,7 +26,9 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
blockTypes = new int[materials.length];
|
||||
for (int i = 0; i < materials.length; i++) {
|
||||
Material material = materials[i];
|
||||
if (material.isLegacy()) continue;
|
||||
if (material.isLegacy()) {
|
||||
continue;
|
||||
}
|
||||
NamespacedKey key = material.getKey();
|
||||
String id = key.getNamespace() + ":" + key.getKey();
|
||||
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
|
||||
* @return The itemtype
|
||||
@ -51,7 +54,9 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
try {
|
||||
return ItemTypes.get(itemTypes[material.ordinal()]);
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return asItemType(material);
|
||||
if (init()) {
|
||||
return asItemType(material);
|
||||
}
|
||||
return ItemTypes.get(itemTypes[material.ordinal()]);
|
||||
}
|
||||
}
|
||||
@ -61,13 +66,15 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
try {
|
||||
return BlockTypesCache.values[blockTypes[material.ordinal()]];
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return asBlockType(material);
|
||||
if (init()) {
|
||||
return asBlockType(material);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockStateHolder from a Bukkit BlockData
|
||||
* Create a WorldEdit BlockStateHolder from a Bukkit BlockData.
|
||||
*
|
||||
* @param blockData The Bukkit BlockData
|
||||
* @return The WorldEdit BlockState
|
||||
@ -79,11 +86,15 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
Material material = blockData.getMaterial();
|
||||
BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]);
|
||||
List<? extends Property> propList = type.getProperties();
|
||||
if (propList.size() == 0) return type.getDefaultState();
|
||||
if (propList.size() == 0) {
|
||||
return type.getDefaultState();
|
||||
}
|
||||
String properties = blockData.getAsString();
|
||||
return BlockState.get(type, properties, type.getDefaultState());
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return adapt(blockData);
|
||||
if (init()) {
|
||||
return adapt(blockData);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public interface IBukkitAdapter {
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position){
|
||||
default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
|
||||
return adapt(world, position.toVector3());
|
||||
}
|
||||
|
||||
@ -254,7 +254,9 @@ public interface IBukkitAdapter {
|
||||
*/
|
||||
default ItemStack adapt(BaseItemStack 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());
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,9 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
|
||||
private BlockData[][] blockDataCache;
|
||||
|
||||
private boolean init() {
|
||||
if (blockDataCache != null) return false;
|
||||
if (blockDataCache != null) {
|
||||
return false;
|
||||
}
|
||||
this.blockDataCache = new BlockData[BlockTypes.size()][];
|
||||
blockDataCache[0] = new BlockData[] {Material.AIR.createBlockData()};
|
||||
return true;
|
||||
@ -42,7 +44,9 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
|
||||
}
|
||||
return blockData;
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return adapt(block);
|
||||
if (init()) {
|
||||
return adapt(block);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,15 @@ import com.boydti.fawe.beta.IQueueChunk;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
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.google.common.io.Files;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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.SideEffectSet;
|
||||
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.*;
|
||||
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.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.Location;
|
||||
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.generator.ChunkGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -79,9 +111,9 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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> {
|
||||
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() {
|
||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) return false;
|
||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) {
|
||||
return false;
|
||||
}
|
||||
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||
BlockState state = BlockTypesCache.states[i];
|
||||
@ -202,9 +236,13 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (existing == blockData) return true;
|
||||
if (existing == blockData) {
|
||||
return true;
|
||||
}
|
||||
if (section == null) {
|
||||
if (blockData.isAir()) return true;
|
||||
if (blockData.isAir()) {
|
||||
return true;
|
||||
}
|
||||
sections[y4] = section = new ChunkSection(y4 << 4);
|
||||
}
|
||||
nmsChunk.setType(blockPos, blockData, false);
|
||||
@ -300,7 +338,7 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
||||
} catch (NullPointerException e) {
|
||||
init();
|
||||
return adaptToChar(ibd);
|
||||
} catch(ArrayIndexOutOfBoundsException e1){
|
||||
} catch (ArrayIndexOutOfBoundsException e1) {
|
||||
Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!");
|
||||
return 0;
|
||||
}
|
||||
@ -406,7 +444,7 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
||||
originalWorld.getMethodProfiler(),
|
||||
server.worldLoadListenerFactory.create(11),
|
||||
env,
|
||||
gen){
|
||||
gen) {
|
||||
@Override
|
||||
public boolean addEntityChunk(net.minecraft.server.v1_15_R1.Entity entity) {
|
||||
//Fixes #320; Prevent adding entities so we aren't attempting to spawn them asynchronously
|
||||
@ -421,10 +459,12 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
||||
IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
|
||||
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15_2(freshWorld, x, z) {
|
||||
@Override
|
||||
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
||||
Chunk cached = nmsWorld.getChunkIfLoaded(X, Z);
|
||||
if (cached != null) return cached;
|
||||
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(X, Z));
|
||||
public Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||
Chunk cached = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(chunkX, chunkZ));
|
||||
while (!future.isDone()) {
|
||||
// this feels so dirty
|
||||
freshWorld.getChunkProvider().runTasks();
|
||||
|
@ -88,7 +88,9 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
|
||||
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
|
||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||
BlockState state = BlockTypesCache.states[i];
|
||||
@ -189,9 +191,13 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (existing == blockData) return true;
|
||||
if (existing == blockData) {
|
||||
return true;
|
||||
}
|
||||
if (section == null) {
|
||||
if (blockData.isAir()) return true;
|
||||
if (blockData.isAir()) {
|
||||
return true;
|
||||
}
|
||||
sections[y4] = section = new ChunkSection(y4 << 4);
|
||||
}
|
||||
nmsChunk.setType(blockPos, blockData, false);
|
||||
@ -287,7 +293,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
||||
} catch (NullPointerException e) {
|
||||
init();
|
||||
return adaptToChar(ibd);
|
||||
} catch(ArrayIndexOutOfBoundsException e1){
|
||||
} catch (ArrayIndexOutOfBoundsException e1) {
|
||||
Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!");
|
||||
return 0;
|
||||
}
|
||||
@ -393,7 +399,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
||||
// originalWorld.getMethodProfiler(),
|
||||
// server.worldLoadListenerFactory.create(11),
|
||||
// env,
|
||||
// gen){
|
||||
// gen) {
|
||||
// @Override
|
||||
// public boolean addEntityChunk(Entity entity) {
|
||||
// //Fixes #320; Prevent adding entities so we aren't attempting to spawn them asynchronously
|
||||
|
@ -23,9 +23,14 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
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.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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.SideEffectSet;
|
||||
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.*;
|
||||
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.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.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
|
||||
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.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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> {
|
||||
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() {
|
||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) return false;
|
||||
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) {
|
||||
return false;
|
||||
}
|
||||
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
|
||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||
BlockState state = BlockTypesCache.states[i];
|
||||
@ -188,9 +218,13 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (existing == blockData) return true;
|
||||
if (existing == blockData) {
|
||||
return true;
|
||||
}
|
||||
if (section == null) {
|
||||
if (blockData.isAir()) return true;
|
||||
if (blockData.isAir()) {
|
||||
return true;
|
||||
}
|
||||
sections[y4] = section = new ChunkSection(y4 << 4);
|
||||
}
|
||||
nmsChunk.setType(blockPos, blockData, false);
|
||||
@ -286,7 +320,7 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
} catch (NullPointerException e) {
|
||||
init();
|
||||
return adaptToChar(ibd);
|
||||
} catch(ArrayIndexOutOfBoundsException e1){
|
||||
} catch (ArrayIndexOutOfBoundsException e1) {
|
||||
Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!");
|
||||
return 0;
|
||||
}
|
||||
@ -392,7 +426,7 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
// originalWorld.getMethodProfiler(),
|
||||
// server.worldLoadListenerFactory.create(11),
|
||||
// env,
|
||||
// gen){
|
||||
// gen) {
|
||||
// @Override
|
||||
// public boolean addEntityChunk(Entity entity) {
|
||||
// //Fixes #320; Prevent adding entities so we aren't attempting to spawn them asynchronously
|
||||
|
@ -79,70 +79,57 @@ public class Fawe {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Fawe.class);
|
||||
|
||||
/**
|
||||
* The FAWE instance;
|
||||
*/
|
||||
private static Fawe INSTANCE;
|
||||
private static Fawe instance;
|
||||
|
||||
/**
|
||||
* TPS timer
|
||||
* The ticks-per-second timer.
|
||||
*/
|
||||
private final FaweTimer timer;
|
||||
private FaweVersion version;
|
||||
private VisualQueue visualQueue;
|
||||
private TextureUtil textures;
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// private DefaultTransformParser transformParser;
|
||||
|
||||
|
||||
private QueueHandler queueHandler;
|
||||
|
||||
/**
|
||||
* Get the implementation specific class
|
||||
*
|
||||
* @return
|
||||
* Get the implementation specific class.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
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
|
||||
*
|
||||
* @return
|
||||
* Get the implementation independent class.
|
||||
*/
|
||||
public static Fawe get() {
|
||||
return INSTANCE;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Fawe
|
||||
*
|
||||
* @param implementation
|
||||
* @throws InstanceAlreadyExistsException
|
||||
* This method is not for public use. If you have to ask what it does then you shouldn't be using it.
|
||||
*/
|
||||
public static void set(final IFawe implementation) throws InstanceAlreadyExistsException, IllegalArgumentException {
|
||||
if (INSTANCE != null) {
|
||||
throw new InstanceAlreadyExistsException("FAWE has already been initialized with: " + INSTANCE.IMP);
|
||||
if (instance != null) {
|
||||
throw new InstanceAlreadyExistsException("FAWE has already been initialized with: " + instance.implementation);
|
||||
}
|
||||
if (implementation == null) {
|
||||
throw new IllegalArgumentException("Implementation may not be null.");
|
||||
}
|
||||
INSTANCE = new Fawe(implementation);
|
||||
instance = new Fawe(implementation);
|
||||
}
|
||||
|
||||
public static void debugPlain(String s) {
|
||||
if (INSTANCE != null) {
|
||||
INSTANCE.IMP.debug(s);
|
||||
if (instance != null) {
|
||||
instance.implementation.debug(s);
|
||||
} else {
|
||||
System.out.println(s);
|
||||
log.debug(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write something to the console
|
||||
*
|
||||
* @param s
|
||||
* Write something to the console.
|
||||
*/
|
||||
public static void debug(String s) {
|
||||
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
|
||||
*/
|
||||
@ -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 Fawe(final IFawe implementation) {
|
||||
INSTANCE = this;
|
||||
this.IMP = implementation;
|
||||
instance = this;
|
||||
this.implementation = implementation;
|
||||
this.thread = Thread.currentThread();
|
||||
/*
|
||||
* Implementation dependent stuff
|
||||
*/
|
||||
this.setupConfigs();
|
||||
TaskManager.IMP = this.IMP.getTaskManager();
|
||||
TaskManager.IMP = this.implementation.getTaskManager();
|
||||
|
||||
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(IMP.getDirectory(), Settings.IMP.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS), false);
|
||||
MainUtil.deleteOlder(MainUtil.getFile(this.implementation
|
||||
.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
|
||||
TaskManager.IMP.later(() -> {
|
||||
try {
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// transformParser = new DefaultTransformParser(getWorldEdit());
|
||||
visualQueue = new VisualQueue(3);
|
||||
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
||||
} catch (Throwable ignored) {}
|
||||
WEManager.IMP.managers.addAll(Fawe.this.implementation.getMaskManagers());
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}, 0);
|
||||
|
||||
TaskManager.IMP.repeat(timer, 1);
|
||||
@ -214,18 +202,13 @@ public class Fawe {
|
||||
if (queueHandler == null) {
|
||||
synchronized (this) {
|
||||
if (queueHandler == null) {
|
||||
queueHandler = IMP.getQueueHandler();
|
||||
queueHandler = implementation.getQueueHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return queueHandler;
|
||||
}
|
||||
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// public DefaultTransformParser getTransformParser() {
|
||||
// return transformParser;
|
||||
// }
|
||||
|
||||
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
||||
// TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
|
||||
TextureUtil tu = getTextureUtil();
|
||||
@ -257,32 +240,27 @@ public class Fawe {
|
||||
}
|
||||
|
||||
/**
|
||||
* The FaweTimer is a useful class for monitoring TPS
|
||||
*
|
||||
* @return FaweTimer
|
||||
* Gets the TPS monitor.
|
||||
*/
|
||||
public FaweTimer getTimer() {
|
||||
return timer;
|
||||
}
|
||||
|
||||
/**
|
||||
* The visual queue is used to queue visualizations
|
||||
*
|
||||
* @return
|
||||
* Get the visual queue.
|
||||
*/
|
||||
public VisualQueue getVisualQueue() {
|
||||
return visualQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* The FAWE version
|
||||
* - Unofficial jars may be lacking version information
|
||||
* The FAWE version.
|
||||
*
|
||||
* @apiNote Unofficial jars may be lacking version information
|
||||
* @return FaweVersion
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
FaweVersion getVersion() {
|
||||
public FaweVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -293,8 +271,8 @@ public class Fawe {
|
||||
public void setupConfigs() {
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "lang/strings.json", null);
|
||||
// Setting up config.yml
|
||||
File file = new File(this.IMP.getDirectory(), "config.yml");
|
||||
Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", "");
|
||||
File file = new File(this.implementation.getDirectory(), "config.yml");
|
||||
Settings.IMP.PLATFORM = implementation.getPlatform().replace("\"", "");
|
||||
try (InputStream stream = getClass().getResourceAsStream(File.separator + "fawe.properties");
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
|
||||
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.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-1.16/" + version.build;
|
||||
Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit/commit/" + Integer.toHexString(version.hash);
|
||||
} catch (Throwable ignore) {}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
try {
|
||||
Settings.IMP.reload(file);
|
||||
} catch (Throwable e) {
|
||||
debug("====== Failed to load config ======");
|
||||
debug("Please validate your yaml files:");
|
||||
e.printStackTrace();
|
||||
debug("====================================");
|
||||
log.error("Failed to load config.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,22 +310,15 @@ public class Fawe {
|
||||
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.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
|
||||
debug("====== ZSTD COMPRESSION BINDING NOT FOUND ======");
|
||||
debug(e.getMessage());
|
||||
debug("FAWE will work but won't compress data as much");
|
||||
debug("===============================================");
|
||||
log.error("ZSTD Compression Binding Not Found.\n"
|
||||
+ "FAWE will still work but compression won't work as well.\n", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
net.jpountz.util.Native.load();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
debug("====== LZ4 COMPRESSION BINDING NOT FOUND ======");
|
||||
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("===============================================");
|
||||
log.error("LZ4 Compression Binding Not Found.\n"
|
||||
+ "FAWE will still work but compression will be slower.\n", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,22 +371,18 @@ public class Fawe {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main thread
|
||||
*
|
||||
* @return
|
||||
* Get the main thread.
|
||||
*/
|
||||
public Thread getMainThread() {
|
||||
return this.thread;
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
* @return
|
||||
* Sets the main thread to the current thread.
|
||||
*/
|
||||
public Thread setMainThread() {
|
||||
return this.thread = Thread.currentThread();
|
||||
|
@ -55,19 +55,20 @@ import javax.annotation.Nullable;
|
||||
* FaweAPI.[some method]
|
||||
*/
|
||||
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
|
||||
* @see EditSessionBuilder
|
||||
*/
|
||||
@Deprecated
|
||||
public static EditSessionBuilder getEditSessionBuilder(World 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
|
||||
*/
|
||||
@ -75,26 +76,15 @@ public class FaweAPI {
|
||||
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>
|
||||
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
|
||||
* - The WorldEdit EditSession can do a lot more<br>
|
||||
* Remember to commit when you're done!<br>
|
||||
* You can either use a {@code IQueueExtent} or an {@code EditSession} to change blocks.
|
||||
*
|
||||
* @param world The name of the world
|
||||
* <p>
|
||||
* 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 autoQueue If it should start dispatching before you enqueue it.
|
||||
* @return the queue extent
|
||||
*/
|
||||
@ -118,10 +108,10 @@ 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 format The format to use (some formats may not be supported)
|
||||
* @param format The format to use (some formats may not be supported)
|
||||
* @return The download URL or null
|
||||
*/
|
||||
public static URL upload(final Clipboard clipboard, final ClipboardFormat format) {
|
||||
@ -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
|
||||
* @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
|
||||
*/
|
||||
@ -158,28 +148,26 @@ public class FaweAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a player's allowed WorldEdit region
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* Get a player's allowed WorldEdit region.
|
||||
*/
|
||||
public static Region[] getRegions(Player player) {
|
||||
return WEManager.IMP.getMask(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the edit with the following extent<br>
|
||||
* - 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>
|
||||
* Cancel the edit with the following extent.
|
||||
*
|
||||
* @param extent
|
||||
* @param reason
|
||||
* @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession
|
||||
* <p>
|
||||
* The extent must be the one being used by an EditSession, otherwise an error will be thrown.
|
||||
* 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) {
|
||||
try {
|
||||
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
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* Get the DiskStorageHistory object representing a File.
|
||||
*/
|
||||
public static DiskStorageHistory getChangeSetFromFile(File file) {
|
||||
if (!file.exists() || file.isDirectory()) {
|
||||
@ -200,7 +185,7 @@ public class FaweAPI {
|
||||
if (Settings.IMP.HISTORY.USE_DISK) {
|
||||
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!");
|
||||
}
|
||||
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>
|
||||
* - Note: An edit outside the radius may be included if it overlaps with an edit inside that depends on it.
|
||||
* Used in the rollback to generate a list of {@link DiskStorageHistory} objects.
|
||||
*
|
||||
* @param origin - The origin location
|
||||
* @param user - The uuid (may be null)
|
||||
* @param radius - The radius from the origin of the edit
|
||||
* @param origin - The origin location
|
||||
* @param user - The uuid (may be null)
|
||||
* @param radius - The radius from the origin of the edit
|
||||
* @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>
|
||||
* Reading only part of the file will result in unreliable bounds info for large edits
|
||||
* @param shallow - If shallow is true, FAWE will only read the first {@link
|
||||
* Settings.HISTORY#BUFFER_SIZE} bytes to obtain history info
|
||||
* @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) {
|
||||
Extent extent = origin.getExtent();
|
||||
@ -312,35 +299,19 @@ public class FaweAPI {
|
||||
/**
|
||||
* 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) {
|
||||
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
|
||||
* @param major
|
||||
* @param minor
|
||||
* @param minor2
|
||||
* @return true if version is >= major, minor, minor2
|
||||
*/
|
||||
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>
|
||||
* <ol>
|
||||
* <li>Removes all lighting, then relights.</li>
|
||||
* <li>Relights in parallel (if enabled) for best performance.</li>
|
||||
* <li>Resends the chunks to the client.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param world World to relight in
|
||||
* @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)
|
||||
*
|
||||
* @param run
|
||||
* Runs a task when the server is low on memory.
|
||||
*/
|
||||
public static void addMemoryLimitedTask(Runnable run) {
|
||||
MemUtil.addMemoryLimitedTask(run);
|
||||
}
|
||||
|
||||
/**
|
||||
* Have a task run when the server is no longer low on memory (configured threshold)
|
||||
*
|
||||
* @param run
|
||||
* Runs a task when the server is no longer low on memory.
|
||||
*/
|
||||
public static void addMemoryPlentifulTask(Runnable run) {
|
||||
MemUtil.addMemoryPlentifulTask(run);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Map of translation ket to value
|
||||
*/
|
||||
public static Map<String, String> getTranslations(Locale 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)
|
||||
* @param layerOffset
|
||||
* @param blocks
|
||||
* @return palette
|
||||
*/
|
||||
public Palette toPaletteUnstretched(int layerOffset, int[] blocks) {
|
||||
@ -518,7 +516,9 @@ public enum FaweCache implements Trimable {
|
||||
}
|
||||
list.add(tag);
|
||||
}
|
||||
if (clazz == null) clazz = EndTag.class;
|
||||
if (clazz == null) {
|
||||
clazz = EndTag.class;
|
||||
}
|
||||
return new ListTag(clazz, list);
|
||||
}
|
||||
|
||||
@ -532,7 +532,9 @@ public enum FaweCache implements Trimable {
|
||||
}
|
||||
list.add(tag);
|
||||
}
|
||||
if (clazz == null) clazz = EndTag.class;
|
||||
if (clazz == null) {
|
||||
clazz = EndTag.class;
|
||||
}
|
||||
return new ListTag(clazz, list);
|
||||
}
|
||||
|
||||
@ -543,9 +545,9 @@ public enum FaweCache implements Trimable {
|
||||
int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
|
||||
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads);
|
||||
return new ThreadPoolExecutor(nThreads, nThreads,
|
||||
0L, TimeUnit.MILLISECONDS, queue
|
||||
, Executors.defaultThreadFactory(),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()) {
|
||||
0L, TimeUnit.MILLISECONDS, queue,
|
||||
Executors.defaultThreadFactory(),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()) {
|
||||
protected void afterExecute(Runnable r, Throwable t) {
|
||||
try {
|
||||
super.afterExecute(r, t);
|
||||
|
@ -1,7 +1,11 @@
|
||||
package com.boydti.fawe;
|
||||
|
||||
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) {
|
||||
this.year = year;
|
||||
|
@ -18,8 +18,8 @@ public class CombinedBlocks implements IBlocks {
|
||||
private final int addMask;
|
||||
|
||||
/**
|
||||
* @param secondary
|
||||
* @param primary
|
||||
* TODO Add a constructor here to satisfy checkstyle.
|
||||
*
|
||||
* @param addMask - bitMask for force sending sections, else 0 to send the primary ones
|
||||
*/
|
||||
public CombinedBlocks(IBlocks secondary, IBlocks primary, int addMask) {
|
||||
@ -92,11 +92,15 @@ public class CombinedBlocks implements IBlocks {
|
||||
BlockVector3 pos = entry.getKey();
|
||||
BlockState block = primary.getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||
if (block.getBlockType() == BlockTypes.__RESERVED__) {
|
||||
if (copy == null) copy = new HashMap<>(tiles);
|
||||
if (copy == null) {
|
||||
copy = new HashMap<>(tiles);
|
||||
}
|
||||
copy.put(pos, entry.getValue());
|
||||
}
|
||||
}
|
||||
if (copy != null) return copy;
|
||||
if (copy != null) {
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tiles;
|
||||
@ -116,8 +120,12 @@ public class CombinedBlocks implements IBlocks {
|
||||
Set<CompoundTag> joined = primary.getEntities();
|
||||
if (primary != secondary) {
|
||||
Set<CompoundTag> ents2 = secondary.getEntities();
|
||||
if (joined.isEmpty()) return ents2;
|
||||
if (ents2.isEmpty()) return joined;
|
||||
if (joined.isEmpty()) {
|
||||
return ents2;
|
||||
}
|
||||
if (ents2.isEmpty()) {
|
||||
return joined;
|
||||
}
|
||||
joined = new HashSet<>(joined);
|
||||
joined.addAll(ents2);
|
||||
}
|
||||
|
@ -15,12 +15,9 @@ import java.util.concurrent.Future;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface IBatchProcessor {
|
||||
|
||||
/**
|
||||
* Process a chunk that has been set
|
||||
* @param chunk
|
||||
* @param get
|
||||
* @param set
|
||||
* @return
|
||||
* Process a chunk that has been 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
|
||||
* @param child
|
||||
* @return
|
||||
* Convert this processor into an Extent based processor instead of a queue batch based on.
|
||||
*/
|
||||
@Nullable
|
||||
Extent construct(Extent child);
|
||||
|
||||
/**
|
||||
* Utility method to trim a chunk based on min and max Y
|
||||
* @param set
|
||||
* @param minY
|
||||
* @param maxY
|
||||
* Utility method to trim a chunk based on min and max Y.
|
||||
* @return false if chunk is empty of blocks
|
||||
*/
|
||||
default boolean trimY(IChunkSet set, int minY, int maxY) {
|
||||
@ -52,7 +44,9 @@ public interface IBatchProcessor {
|
||||
if (layer == minLayer) {
|
||||
char[] arr = set.load(layer);
|
||||
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);
|
||||
} else {
|
||||
set.setBlocks(layer, null);
|
||||
@ -65,7 +59,9 @@ public interface IBatchProcessor {
|
||||
if (layer == minLayer) {
|
||||
char[] arr = set.load(layer);
|
||||
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);
|
||||
} else {
|
||||
set.setBlocks(layer, null);
|
||||
@ -91,9 +87,8 @@ public interface IBatchProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to trim entity and blocks with a provided contains function
|
||||
* @param set
|
||||
* @param contains
|
||||
* Utility method to trim entity and blocks with a provided contains function.
|
||||
*
|
||||
* @return false if chunk is empty of NBT
|
||||
*/
|
||||
default boolean trimNBT(IChunkSet set, Function<BlockVector3, Boolean> contains) {
|
||||
@ -110,9 +105,7 @@ public interface IBatchProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Join two processors and return the result
|
||||
* @param other
|
||||
* @return
|
||||
* Join two processors and return the result.
|
||||
*/
|
||||
default IBatchProcessor join(IBatchProcessor other) {
|
||||
return MultiBatchProcessor.of(this, other);
|
||||
@ -122,13 +115,11 @@ public interface IBatchProcessor {
|
||||
return MultiBatchProcessor.of(this, other);
|
||||
}
|
||||
|
||||
default void flush() {}
|
||||
default void flush() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new processor after removing all are instances of a specified class
|
||||
* @param clazz
|
||||
* @param <T>
|
||||
* @return
|
||||
* Return a new processor after removing all are instances of a specified class.
|
||||
*/
|
||||
default <T extends IBatchProcessor> IBatchProcessor remove(Class<T> clazz) {
|
||||
if (clazz.isInstance(this)) {
|
||||
|
@ -19,7 +19,7 @@ import java.util.Set;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* A shared interface for IGetBlocks and ISetBlocks
|
||||
* A shared interface for IGetBlocks and ISetBlocks.
|
||||
*/
|
||||
public interface IBlocks extends Trimable {
|
||||
|
||||
|
@ -75,16 +75,16 @@ public interface IChunkSet extends IBlocks, OutputExtent {
|
||||
}
|
||||
|
||||
// Default to avoid tricky child classes. We only need it in a few cases anyway.
|
||||
default void setFastMode(boolean fastMode){}
|
||||
default void setFastMode(boolean fastMode) {}
|
||||
|
||||
default boolean isFastMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow setting for bitmask for flushing lighting. Default to avoid tricky child classes.
|
||||
default void setBitMask(int bitMask){}
|
||||
default void setBitMask(int bitMask) {}
|
||||
|
||||
default int getBitMask(){
|
||||
default int getBitMask() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -49,16 +49,16 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
void init(Extent extent, IChunkCache<IChunkGet> get, IChunkCache<IChunkSet> set);
|
||||
|
||||
/**
|
||||
* Get the cached get object
|
||||
* - Faster than getting it using NMS and allows for wrapping
|
||||
* @param x
|
||||
* @param z
|
||||
* Get the cached get object. This is faster than getting the object using NMS and allows for
|
||||
* wrapping.
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
* @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 chunkZ
|
||||
* @return
|
||||
@ -88,19 +88,18 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
boolean isFastMode();
|
||||
|
||||
/**
|
||||
* Create a new root IChunk object<br> - Full chunks will be reused, so a more optimized chunk
|
||||
* can be returned in that case<br> - Don't wrap the chunk, that should be done in {@link
|
||||
* #wrap(T)}
|
||||
* Create a new root IChunk object. Full chunks will be reused, so a more optimized chunk can be
|
||||
* returned in that case.
|
||||
*
|
||||
* @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
|
||||
* @return a more optimized chunk object
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
void flush();
|
||||
|
||||
/**
|
||||
* A filter block is used to iterate over blocks / positions
|
||||
* - Essentially combines BlockVector3, Extent and BlockState functions in a way that avoids lookups
|
||||
* @return
|
||||
* A filter block is used to iterate over blocks / positions. Essentially combines BlockVector3,
|
||||
* Extent and BlockState functions in a way that avoids lookups.
|
||||
*/
|
||||
ChunkFilterBlock initFilterBlock();
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
package com.boydti.fawe.beta;
|
||||
|
||||
/**
|
||||
* Interface for objects that can be trimmed (memory related)<br> - Trimming will reduce its memory
|
||||
* footprint
|
||||
* Interface for objects that can be trimmed (memory related). Trimming will reduce its memory
|
||||
* footprint.
|
||||
*/
|
||||
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
|
||||
* @return if this object is empty at the end of the trim, and can therefore be deleted
|
||||
*/
|
||||
boolean trim(boolean aggressive);
|
||||
|
||||
default void recycle() {}
|
||||
default void recycle() {
|
||||
}
|
||||
}
|
||||
|
@ -68,19 +68,33 @@ public class BitSetBlocks implements IChunkSet {
|
||||
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
|
||||
public void setEntity(CompoundTag tag) {
|
||||
@ -134,11 +148,13 @@ public class BitSetBlocks implements IChunkSet {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public char[][] getLight() {
|
||||
@Override
|
||||
public char[][] getLight() {
|
||||
return new char[0][];
|
||||
}
|
||||
|
||||
@Override public char[][] getSkyLight() {
|
||||
@Override
|
||||
public char[][] getSkyLight() {
|
||||
return new char[0][];
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ public abstract class CharBlocks implements IBlocks {
|
||||
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);
|
||||
|
||||
|
@ -24,6 +24,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
private static final Pool<CharSetBlocks> POOL = FaweCache.IMP.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
||||
|
||||
public static CharSetBlocks newInstance() {
|
||||
return POOL.poll();
|
||||
}
|
||||
@ -38,7 +39,8 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
private boolean fastMode = false;
|
||||
private int bitMask = -1;
|
||||
|
||||
private CharSetBlocks() {}
|
||||
private CharSetBlocks() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
@ -52,7 +54,9 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
|
||||
@Override
|
||||
public BiomeType getBiomeType(int x, int y, int z) {
|
||||
if (biomes == null) return null;
|
||||
if (biomes == null) {
|
||||
return null;
|
||||
}
|
||||
return biomes[(z << 4) | x];
|
||||
}
|
||||
|
||||
@ -213,7 +217,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return setBiome(position.getX(),position.getY(), position.getZ(), biome);
|
||||
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,8 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class FallbackChunkGet implements IChunkGet {
|
||||
private final int bx, bz;
|
||||
private final int bx;
|
||||
private final int bz;
|
||||
private final Extent extent;
|
||||
|
||||
public FallbackChunkGet(Extent extent, int chunkX, int chunkZ) {
|
||||
@ -32,6 +33,7 @@ public class FallbackChunkGet implements IChunkGet {
|
||||
this.bx = chunkX << 4;
|
||||
this.bz = chunkZ << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(int x, int y, int 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
|
||||
*/
|
||||
|
@ -45,7 +45,9 @@ public class AsyncPreloader implements Preloader, Runnable {
|
||||
@Override
|
||||
public void update(Player player) {
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(player);
|
||||
if (session == null) return;
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
World world = player.getWorld();
|
||||
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
|
||||
try {
|
||||
@ -67,7 +69,8 @@ public class AsyncPreloader implements Preloader, Runnable {
|
||||
update.notify();
|
||||
}
|
||||
}
|
||||
} catch (IncompleteRegionException ignore){}
|
||||
} catch (IncompleteRegionException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,7 @@ import java.util.UUID;
|
||||
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")
|
||||
public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
@ -189,7 +189,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFullBright(ChunkHolder chunk, int layer){
|
||||
public void setFullBright(ChunkHolder chunk, int layer) {
|
||||
chunk.chunkSet.setFullBright(layer);
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFullBright(ChunkHolder chunk, int layer){
|
||||
public void setFullBright(ChunkHolder chunk, int layer) {
|
||||
chunk.getOrCreateSet();
|
||||
chunk.delegate = BOTH;
|
||||
chunk.setFullBright(layer);
|
||||
@ -425,7 +425,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFullBright(ChunkHolder chunk, int layer){
|
||||
public void setFullBright(ChunkHolder chunk, int layer) {
|
||||
chunk.chunkSet.setFullBright(layer);
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFullBright(ChunkHolder chunk, int layer){
|
||||
public void setFullBright(ChunkHolder chunk, int layer) {
|
||||
chunk.getOrCreateSet();
|
||||
chunk.delegate = SET;
|
||||
chunk.setFullBright(layer);
|
||||
@ -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() {
|
||||
return extent;
|
||||
@ -911,6 +911,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
|
||||
public interface IBlockDelegate {
|
||||
<C extends Future<C>> IChunkGet get(ChunkHolder<C> chunk);
|
||||
|
||||
IChunkSet set(ChunkHolder chunk);
|
||||
|
||||
boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome);
|
||||
|
@ -14,12 +14,12 @@ public final class LinkedFilter<T extends Filter, S extends Filter> extends Dele
|
||||
|
||||
private final S child;
|
||||
|
||||
public LinkedFilter(T parent, S child){
|
||||
public LinkedFilter(T parent, S child) {
|
||||
super(parent);
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public S getChild(){
|
||||
public S getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
|
||||
*
|
||||
* @return number of blocks which passed the Mask test and were applied to
|
||||
*/
|
||||
public int getBlocksApplied(){
|
||||
public int getBlocksApplied() {
|
||||
return this.changes.get();
|
||||
}
|
||||
|
||||
|
@ -54,11 +54,6 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
||||
return getFullBlock().toBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(BlockState state) {
|
||||
setFullBlock(state.toBaseBlock(getBlock().getNbtData()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
return getFullBlock().getNbtData();
|
||||
@ -79,6 +74,11 @@ public abstract class AbstractFilterBlock extends FilterBlock {
|
||||
return BlockVector3.at(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(BlockState state) {
|
||||
setFullBlock(state.toBaseBlock(getBlock().getNbtData()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
|
@ -16,8 +16,11 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
||||
private final char[] blocks;
|
||||
private final byte[] heights;
|
||||
private final int yOffset;
|
||||
private final int width, length;
|
||||
private int x, z, index;
|
||||
private final int width;
|
||||
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,
|
||||
int yOffset) {
|
||||
@ -51,11 +54,6 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
||||
return BlockTypesCache.states[getOrdinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(BlockState state) {
|
||||
blocks[index] = state.getOrdinalChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock() {
|
||||
return getBlock().toBaseBlock();
|
||||
@ -90,14 +88,19 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(BlockState state) {
|
||||
blocks[index] = state.getOrdinalChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return getExtent().setBlock(x,y, z, block);
|
||||
return getExtent().setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return getExtent().setBiome(x,y, z,biome);
|
||||
return getExtent().setBiome(x, y, z, biome);
|
||||
}
|
||||
}
|
||||
|
@ -34,10 +34,20 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
private CharGetBlocks get;
|
||||
private IChunkSet set;
|
||||
private char[] getArr;
|
||||
private @Nullable char[] setArr;
|
||||
@Nullable
|
||||
private char[] setArr;
|
||||
private SetDelegate delegate;
|
||||
// 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) {
|
||||
super(extent);
|
||||
@ -107,8 +117,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(Filter filter, int yStart, int yEnd) {
|
||||
for (y = yStart, index = yStart << 8; y <= yEnd; y++) {
|
||||
public void filter(Filter filter, int startY, int endY) {
|
||||
for (y = startY, index = startY << 8; y <= endY; y++) {
|
||||
for (z = 0; z < 16; z++) {
|
||||
for (x = 0; x < 16; x++, index++) {
|
||||
filter.applyBlock(this);
|
||||
|
@ -23,21 +23,12 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize with chunk coordinates
|
||||
* - The layer must also be initialized
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
* @return
|
||||
* Initialize with chunk coordinates. The layer must also be initialized.
|
||||
*/
|
||||
public abstract ChunkFilterBlock initChunk(int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Initialize a chunk layer
|
||||
* - The chunk coordinates must also be initialized first
|
||||
* @param iget
|
||||
* @param iset
|
||||
* @param layer
|
||||
* @return
|
||||
* Initialize a chunk layer. the Chunk coordinates need to be initialized first.
|
||||
*/
|
||||
public abstract ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer);
|
||||
|
||||
@ -46,55 +37,33 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
||||
|
||||
|
||||
/**
|
||||
* Filter a single block
|
||||
* @param filter
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* Filter a single block.
|
||||
*/
|
||||
public abstract void filter(Filter filter, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Filter a cuboid region
|
||||
* @param filter
|
||||
* @param minX
|
||||
* @param minY
|
||||
* @param minZ
|
||||
* @param maxX
|
||||
* @param maxY
|
||||
* @param maxZ
|
||||
* Filter a cuboid region.
|
||||
*/
|
||||
public abstract void filter(Filter filter, int minX, int minY, int minZ, int maxX, int maxY,
|
||||
int maxZ);
|
||||
|
||||
/**
|
||||
* Filter everything in the layer
|
||||
* @param filter
|
||||
* Filter everything in the layer.
|
||||
*/
|
||||
public abstract void filter(Filter filter);
|
||||
|
||||
/**
|
||||
* Filter everything between y layers
|
||||
* @param filter
|
||||
* @param yStart
|
||||
* @param yEnd
|
||||
* Filter everything between y layers.
|
||||
*/
|
||||
public abstract void filter(Filter filter, int yStart, int yEnd);
|
||||
public abstract void filter(Filter filter, int startY, int endY);
|
||||
|
||||
/**
|
||||
* Filter with a region
|
||||
* @param filter
|
||||
* @param region
|
||||
* Filter with a region.
|
||||
*/
|
||||
public abstract void filter(Filter filter, Region region);
|
||||
|
||||
/**
|
||||
* Filter with a chunk object
|
||||
* @param chunk
|
||||
* @param get
|
||||
* @param set
|
||||
* @param filter
|
||||
* @return
|
||||
* Filter with a chunk object.
|
||||
*/
|
||||
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter) {
|
||||
initChunk(chunk.getX(), chunk.getZ());
|
||||
@ -108,14 +77,7 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a chunk with a region / filter
|
||||
* @param chunk
|
||||
* @param get
|
||||
* @param set
|
||||
* @param filter
|
||||
* @param region
|
||||
* @param full
|
||||
* @return
|
||||
* Filter a chunk with a region / filter.
|
||||
*/
|
||||
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter, Region region, boolean full) {
|
||||
if (region != null) {
|
||||
|
@ -4,7 +4,9 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
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) {
|
||||
this.x = x;
|
||||
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
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);
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
@ -319,7 +320,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
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);
|
||||
break east;
|
||||
}
|
||||
@ -370,7 +371,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
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);
|
||||
break west;
|
||||
}
|
||||
@ -421,7 +422,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
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);
|
||||
break south;
|
||||
}
|
||||
@ -472,7 +473,7 @@ public class NMSRelighter implements Relighter {
|
||||
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||
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);
|
||||
break north;
|
||||
}
|
||||
@ -611,7 +612,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairNorth(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -629,7 +630,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairSouth(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -647,7 +648,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairEast(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -665,7 +666,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private boolean checkStairWest(BlockState state) {
|
||||
if (!state.getBlockType().getId().toLowerCase().contains("stair")) {
|
||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||
return true;
|
||||
}
|
||||
Direction direction = getStairDir(state);
|
||||
@ -687,7 +688,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private String getStairShape(BlockState state) {
|
||||
return state.getState(stairShape).toLowerCase();
|
||||
return state.getState(stairShape).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
private boolean isStairOrTrueTop(BlockState state, boolean top) {
|
||||
@ -784,8 +785,9 @@ public class NMSRelighter implements Relighter {
|
||||
|
||||
public void fixBlockLighting() {
|
||||
synchronized (lightQueue) {
|
||||
while (!lightLock.compareAndSet(false, true))
|
||||
while (!lightLock.compareAndSet(false, true)) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
updateBlockLight(this.lightQueue);
|
||||
} finally {
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.beta.implementation.lighting;
|
||||
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 cz chunk z
|
||||
@ -14,7 +14,7 @@ public interface Relighter {
|
||||
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 y block y
|
||||
@ -23,14 +23,14 @@ public interface Relighter {
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Fix block light values in all chunks added to relighter
|
||||
* Fix block light values in all chunks added to relighter.
|
||||
*/
|
||||
void fixBlockLighting();
|
||||
|
||||
/**
|
||||
* Fix sky light values in all chunks added to relighter
|
||||
* Fix sky light values in all chunks added to relighter.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
public static class SkipReason {
|
||||
class SkipReason {
|
||||
public static final byte NONE = 0;
|
||||
public static final byte AIR = 1;
|
||||
public static final byte SOLID = 2;
|
||||
|
@ -116,8 +116,8 @@ public class ChunkPacket implements Function<byte[], byte[]>, Supplier<byte[]> {
|
||||
fos.writeVarInt(sectionBytes.length);
|
||||
fos.write(sectionBytes);
|
||||
// TODO entities / NBT
|
||||
// Set<CompoundTag> entities = chunk.getEntities();
|
||||
// Map<BlockVector3, CompoundTag> tiles = chunk.getTiles();
|
||||
//Set<CompoundTag> entities = chunk.getEntities();
|
||||
//Map<BlockVector3, CompoundTag> tiles = chunk.getTiles();
|
||||
fos.writeVarInt(0); // (Entities / NBT)
|
||||
return baos.toByteArray();
|
||||
} catch (Throwable e) {
|
||||
|
@ -573,7 +573,9 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
@Deprecated
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||
limit.THROW_MAX_CHANGES();
|
||||
if (block.hasNbtData()) limit.MAX_BLOCKSTATES();
|
||||
if (block.hasNbtData()) {
|
||||
limit.MAX_BLOCKSTATES();
|
||||
}
|
||||
try {
|
||||
return super.setBlock(position, block);
|
||||
} catch (FaweException e) {
|
||||
@ -587,7 +589,9 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
limit.THROW_MAX_CHANGES();
|
||||
if (block.hasNbtData()) limit.MAX_BLOCKSTATES();
|
||||
if (block.hasNbtData()) {
|
||||
limit.MAX_BLOCKSTATES();
|
||||
}
|
||||
try {
|
||||
return super.setBlock(x, y, z, block);
|
||||
} catch (FaweException e) {
|
||||
|
@ -33,7 +33,7 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
||||
for (IBatchProcessor processor : processors) {
|
||||
if (processor instanceof MultiBatchProcessor) {
|
||||
list.addAll(Arrays.asList(((MultiBatchProcessor) processor).processors));
|
||||
} else if (!(processor instanceof EmptyBatchProcessor)){
|
||||
} else if (!(processor instanceof EmptyBatchProcessor)) {
|
||||
list.add(processor);
|
||||
}
|
||||
}
|
||||
@ -154,7 +154,9 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
for (IBatchProcessor processor : this.processors) processor.flush();
|
||||
for (IBatchProcessor processor : this.processors) {
|
||||
processor.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,7 +44,9 @@ public class PersistentChunkSendProcessor extends ChunkSendProcessor {
|
||||
current.put(pair, (Character) bitMask);
|
||||
if (previous != null) {
|
||||
Character lastValue = previous.remove(pair);
|
||||
if (lastValue != null) bitMask |= lastValue;
|
||||
if (lastValue != null) {
|
||||
bitMask |= lastValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CombinedBlocks(get, set, bitMask);
|
||||
@ -56,7 +58,9 @@ public class PersistentChunkSendProcessor extends ChunkSendProcessor {
|
||||
}
|
||||
|
||||
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);
|
||||
current.clear();
|
||||
queue = null;
|
||||
|
@ -106,7 +106,8 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
|
||||
while (true) {
|
||||
// Get the next chunk posWeakChunk
|
||||
final int chunkX, chunkZ;
|
||||
final int chunkX;
|
||||
final int chunkZ;
|
||||
synchronized (chunksIter) {
|
||||
if (!chunksIter.hasNext()) {
|
||||
break;
|
||||
|
@ -21,7 +21,9 @@ public class QueuePool<T> extends ConcurrentLinkedQueue<T> implements Pool<T> {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if (!isEmpty()) super.clear();
|
||||
if (!isEmpty()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
* Resets the queue.
|
||||
*/
|
||||
protected synchronized void reset() {
|
||||
if (!this.initialized) return;
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
if (!this.chunks.isEmpty()) {
|
||||
for (IChunk chunk : this.chunks.values()) {
|
||||
chunk.recycle();
|
||||
@ -175,9 +177,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
|
||||
if (Fawe.isMainThread()) {
|
||||
V result = (V)chunk.call();
|
||||
if (result == null){
|
||||
if (result == null) {
|
||||
return (V) (Future) Futures.immediateFuture(null);
|
||||
}else{
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -285,7 +287,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
while (!submissions.isEmpty()) {
|
||||
Future future = submissions.poll();
|
||||
try {
|
||||
while (future != null) future = (Future) future.get();
|
||||
while (future != null) {
|
||||
future = (Future) future.get();
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -294,7 +298,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
for (int i = 0; i < overflow; i++) {
|
||||
Future first = submissions.poll();
|
||||
try {
|
||||
while (first != null) first = (Future) first.get();
|
||||
while (first != null) {
|
||||
first = (Future) first.get();
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -158,13 +158,15 @@ public class AnvilCommands {
|
||||
name = "deleteallunvisited",
|
||||
aliases = {"delunvisited" },
|
||||
desc = "Delete all chunks which haven't been occupied",
|
||||
descFooter = "occupied for `age-ticks` (20t = 1s) and \n" +
|
||||
"Have not been accessed since `file-duration` (ms) after creation and\n" +
|
||||
"Have not been used in the past `chunk-inactivity` (ms)" +
|
||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
descFooter = "occupied for `age-ticks` (20t = 1s) and \n"
|
||||
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
|
||||
+ "Have not been used in the past `chunk-inactivity` (ms)"
|
||||
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
)
|
||||
@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 result = runWithWorld(player, folder, filter, true);
|
||||
// if (result != null) {
|
||||
@ -176,14 +178,18 @@ public class AnvilCommands {
|
||||
name = "deleteallunclaimed",
|
||||
aliases = {"delallunclaimed" },
|
||||
desc = "Delete all chunks which haven't been occupied",
|
||||
descFooter = "Supports: WG, P2, GP:\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 used in the past `chunk-inactivity` (ms)" +
|
||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
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"
|
||||
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
|
||||
+ "Have not been used in the past `chunk-inactivity` (ms)"
|
||||
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
)
|
||||
@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
|
||||
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||
// if (debug) {
|
||||
@ -198,15 +204,19 @@ public class AnvilCommands {
|
||||
@Command(
|
||||
name = "deleteunclaimed",
|
||||
desc = "Delete all chunks which haven't been occupied",
|
||||
descFooter = "(Supports: WG, P2, GP):\n" +
|
||||
"Is not claimed\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 used in the past `chunk-inactivity` (ms)" +
|
||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
descFooter = "(Supports: WorldGuard, PlotSquared, GriefPrevention):\n"
|
||||
+ "Is not claimed\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 used in the past `chunk-inactivity` (ms)"
|
||||
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
)
|
||||
@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
|
||||
// if (debug) {
|
||||
// filter.enableDebug();
|
||||
@ -221,8 +231,8 @@ public class AnvilCommands {
|
||||
name = "deletealloldregions",
|
||||
aliases = {"deloldreg" },
|
||||
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" +
|
||||
"(months are not a unit of time) e.g., 8h5m12s\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"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.deletealloldregions")
|
||||
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
|
||||
@ -236,12 +246,13 @@ public class AnvilCommands {
|
||||
|
||||
@Command(
|
||||
name = "trimallplots",
|
||||
|
||||
desc = "Trim chunks in a Plot World",
|
||||
descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n"
|
||||
)
|
||||
@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
|
||||
// int visitTime = deleteUnvisited ? 1 : -1;
|
||||
// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
|
||||
@ -259,7 +270,9 @@ public class AnvilCommands {
|
||||
desc = "Delete chunks matching a specific biome"
|
||||
)
|
||||
@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 result = runWithWorld(player, folder, filter, true, unsafe);
|
||||
// if (result != null) {
|
||||
@ -272,7 +285,9 @@ public class AnvilCommands {
|
||||
desc = "Trim all air in the world"
|
||||
)
|
||||
@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 result = runWithWorld(player, folder, filter, true, unsafe);
|
||||
// if (result != null) {
|
||||
@ -282,7 +297,6 @@ public class AnvilCommands {
|
||||
|
||||
@Command(
|
||||
name = "debugfixroads",
|
||||
|
||||
desc = "debug - do not use"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.debugfixroads")
|
||||
@ -300,7 +314,13 @@ public class AnvilCommands {
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
)
|
||||
@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
|
||||
// if (useMap) {
|
||||
// if (to instanceof RandomPattern) {
|
||||
@ -329,7 +349,9 @@ public class AnvilCommands {
|
||||
desc = "Count all blocks in a world"
|
||||
)
|
||||
@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);
|
||||
// MCAFilterCounter filter;
|
||||
// if (useData || arg.contains(":")) { // Optimize for both cases
|
||||
@ -403,7 +425,9 @@ public class AnvilCommands {
|
||||
desc = "Count blocks in a selection"
|
||||
)
|
||||
@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
|
||||
// MCAFilterCounter filter;
|
||||
// if (useData || arg.contains(":")) { // Optimize for both cases
|
||||
@ -425,7 +449,9 @@ public class AnvilCommands {
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
)
|
||||
@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[] count;
|
||||
// MCAFilter<long[]> counts;
|
||||
@ -504,7 +530,11 @@ public class AnvilCommands {
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
)
|
||||
@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
|
||||
// if (from == null) {
|
||||
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
||||
@ -526,7 +556,13 @@ public class AnvilCommands {
|
||||
desc = "Replace all blocks in the selection with a pattern"
|
||||
)
|
||||
@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
|
||||
// if (useMap) {
|
||||
// if (to instanceof RandomPattern) {
|
||||
@ -556,7 +592,7 @@ public class AnvilCommands {
|
||||
desc = "Set all blocks in the selection with a pattern"
|
||||
)
|
||||
@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 {
|
||||
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
|
||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||
@ -602,17 +638,18 @@ public class AnvilCommands {
|
||||
// MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin);
|
||||
// FawePlayer fp = FawePlayer.wrap(player);
|
||||
// fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard);
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , selection.getArea()));
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy", selection.getArea()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "paste",
|
||||
desc = "Paste chunks from your anvil clipboard",
|
||||
descFooter = "Paste the chunks from your anvil clipboard.\n" +
|
||||
"The -c flag will align the paste to the chunks."
|
||||
descFooter = "Paste the chunks from your anvil clipboard."
|
||||
)
|
||||
@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
|
||||
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
||||
// if (clipboard == null) {
|
||||
@ -639,6 +676,6 @@ public class AnvilCommands {
|
||||
// pasteQueue.pasteRegion(copyQueue, copyRegion, offset, iAnvilHistory);
|
||||
// } catch (IOException e) { throw new RuntimeException(e); }
|
||||
// });
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , player.getPosition().toBlockVector()));
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste", player.getPosition().toBlockVector()));
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@
|
||||
// desc = "Set the floor and main block"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void column(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void column(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||
// if (image != null) {
|
||||
// gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
||||
@ -264,7 +264,7 @@
|
||||
// desc = "Set the floor (default: grass)"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void floorCmd(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void floorCmd(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// floor(player, pattern, image, mask, disableWhiteOnly);
|
||||
// player.print("Set floor!");
|
||||
// assertSettings(player).resetComponent();
|
||||
@ -287,14 +287,14 @@
|
||||
// desc = "Set the main block (default: stone)"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void mainCmd(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void mainCmd(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// main(player, pattern, image, maskOpt, disableWhiteOnly);
|
||||
// player.print("Set main!");
|
||||
// assertSettings(player).resetComponent();
|
||||
// component(player);
|
||||
// }
|
||||
//
|
||||
// public void main(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void main(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||
// if (image != null) {
|
||||
// gen.setMain(load(image), pattern, !disableWhiteOnly);
|
||||
@ -313,7 +313,7 @@
|
||||
// "e.g., Tallgrass"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void overlay(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void overlay(Player player, @Arg(desc = "Pattern") Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||
// if (image != null) {
|
||||
// gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
||||
@ -335,13 +335,13 @@
|
||||
// " - A good value for radius and iterations would be 1 8."
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void smoothCmd(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void smoothCmd(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// smooth(player, radius, iterations, image, mask, disableWhiteOnly);
|
||||
// assertSettings(player).resetComponent();
|
||||
// component(player);
|
||||
// }
|
||||
//
|
||||
// private void smooth(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// private void smooth(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||
// if (image != null) {
|
||||
// gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
||||
@ -355,7 +355,7 @@
|
||||
// desc = "Create some snow"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void snow(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void snow(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||
// floor(player, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly);
|
||||
// main(player, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly);
|
||||
@ -422,7 +422,7 @@
|
||||
// Request.request().setExtent(generator);
|
||||
//
|
||||
// Set<BlockType> blocks;
|
||||
// switch (argOpt.toLowerCase()) {
|
||||
// switch (argOpt.toLowerCase(Locale.ROOT)) {
|
||||
// case "true":
|
||||
// case "*": {
|
||||
// generator.setTextureUtil(Fawe.get().getTextureUtil());
|
||||
@ -535,7 +535,7 @@
|
||||
// " - If a mask is used, the biome will be set anywhere the mask applies"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void biome(Player player, @Arg(desc = "Biome type") BiomeType biome, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||
// public void biome(Player player, @Arg(desc = "Biome type") BiomeType biome, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||
// HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||
// if (image != null) {
|
||||
// gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||
@ -819,7 +819,7 @@
|
||||
// TextComponent.of("/cfi randomization " + !rand)));
|
||||
// @NotNull Builder builder = TextComponent.builder(">> Current Settings <<");
|
||||
// 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(
|
||||
// "/cfi randomization " + !rand)).hoverEvent(HoverEvent.showText(
|
||||
// TextComponent.of("/cfi randomization " + !rand))));
|
||||
@ -871,7 +871,7 @@
|
||||
// desc = "Select a mask"
|
||||
// )
|
||||
// @CommandPermissions("worldedit.anvil.cfi")
|
||||
// public void mask(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){
|
||||
// public void mask(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context) {
|
||||
// CFISettings settings = assertSettings(player);
|
||||
// String[] split = getArguments(context).split(" ");
|
||||
// int index = 2;
|
||||
@ -950,7 +950,7 @@
|
||||
// JsonObject data1 = obj.get("data").getAsJsonObject();
|
||||
// String link = data1.get("link").getAsString();
|
||||
// URL url = new URL(link);
|
||||
// player.print(Caption.of("fawe.web.download.link" , url));
|
||||
// player.print(Caption.of("fawe.web.download.link", url));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
|
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