mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00: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
This commit is contained in:
@ -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) {
|
||||
@ -516,7 +527,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||
tag.remove(name);
|
||||
}
|
||||
|
||||
|
||||
entity.f(tag);
|
||||
entity.setLocation(x, y, z, yaw, pitch);
|
||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
@ -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;
|
||||
@ -170,4 +171,4 @@ public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IB
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException {
|
||||
return this.adapter.setBlock(this.getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4).bukkitChunk, position.getBlockX(), position.getBlockY(), position.getBlockZ(), block, sideEffectSet.shouldApply(SideEffect.LIGHTING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -171,4 +172,4 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException {
|
||||
return this.adapter.setBlock(this.getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4).bukkitChunk, position.getBlockX(), position.getBlockY(), position.getBlockZ(), block, sideEffectSet.shouldApply(SideEffect.LIGHTING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -171,4 +172,4 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException {
|
||||
return this.adapter.setBlock(this.getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4).bukkitChunk, position.getBlockX(), position.getBlockY(), position.getBlockZ(), block, sideEffectSet.shouldApply(SideEffect.LIGHTING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,4 +86,4 @@ public class ChunkListener_9 extends ChunkListener {
|
||||
StackTraceElement[] elems = getElements(ex);
|
||||
return elems.length > i ? elems[i] : null;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -111,7 +110,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (isAllowed(player, plot, type)) {
|
||||
regions = plot.getRegions();
|
||||
} else {
|
||||
} else {
|
||||
plot = null;
|
||||
regions = WEManager.getMask(pp);
|
||||
if (regions.size() == 1) {
|
||||
@ -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) {
|
||||
@ -115,7 +114,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (isAllowed(player, plot, type)) {
|
||||
regions = plot.getRegions();
|
||||
} else {
|
||||
} else {
|
||||
plot = null;
|
||||
regions = WEManager.getMask(pp);
|
||||
if (regions.size() == 1) {
|
||||
@ -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,10 +14,12 @@ 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);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
@ -231,7 +265,7 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
Supplier<CompoundTag> saveTag = () -> {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
readEntityIntoTag(mcEntity, tag);
|
||||
|
||||
|
||||
//add Id for AbstractChangeSet to work
|
||||
CompoundTag natve = (CompoundTag) toNative(tag);
|
||||
natve.getValue().put("Id", new StringTag(id));
|
||||
@ -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
|
||||
|
Reference in New Issue
Block a user