-
----
-
-FAWE is a fork of WorldEdit that has huge speed and memory improvements and considerably more features
-
-## Links
-
-* [Spigot Page](https://www.spigotmc.org/threads/fast-async-worldedit.100104/)
-* [Discord](https://discord.gg/KxkjDVg)
-* [Wiki](https://wiki.intellectualsites.com/FastAsyncWorldEdit/index)
-* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit/issues)
-* [Crowdin](https://intellectualsites.crowdin.com/fastasyncworldedit)
-* [JavaDocs](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/javadoc/)
-
-## Downloads
-### 1.15+
-* [Download](https://intellectualsites.github.io/download/fawe.html)
-* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/)
-
-
-## Building
-FAWE uses gradle to build
-You can safely ignore `gradlew setupDecompWorkspace` if you are not planning to work on the forge side of FAWE.
-
-```
-$ gradlew setupDecompWorkspace
-$ gradlew build
-```
-
-The jar is located in `worldedit-bukkit/build/libs/FastAsyncWorldEdit-1.16-###.jar`
-
-## Contributing
-Have an idea for an optimization, or a cool feature?
- - We will accept most PR's
- - Let us know what you've tested / what may need further testing
- - If you need any help, create a ticket or discuss on [Discord](https://discord.gg/KxkjDVg)
-
-## YourKit
-
-
-
-
-Thank you to YourKit for supporting our product by providing us with their innovative and intelligent tools
-for monitoring and profiling Java and .NET applications.
-YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor
+
+
+
+
+---
+
+FAWE is a fork of WorldEdit that has huge speed and memory improvements and considerably more features
+
+## Links
+
+* [Spigot Page](https://www.spigotmc.org/threads/fast-async-worldedit.100104/)
+* [Discord](https://discord.gg/KxkjDVg)
+* [Wiki](https://wiki.intellectualsites.com/FastAsyncWorldEdit/index)
+* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit/issues)
+* [Crowdin](https://intellectualsites.crowdin.com/fastasyncworldedit)
+* [JavaDocs](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/javadoc/)
+
+## Downloads
+### 1.15+
+* [Download](https://www.spigotmc.org/resources/fast-async-worldedit.13932/)
+* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/)
+
+Looking builds for older versions? Download them [here](https://intellectualsites.github.io/download/).
+
+
+## Building
+FAWE uses gradle to build
+You can safely ignore `gradlew setupDecompWorkspace` if you are not planning to work on the forge side of FAWE.
+
+```
+$ gradlew setupDecompWorkspace
+$ gradlew build
+```
+
+The jar is located in `worldedit-bukkit/build/libs/FastAsyncWorldEdit-1.16-###.jar`
+
+## Contributing
+Have an idea for an optimization, or a cool feature?
+ - We will accept most PR's
+ - Let us know what you've tested / what may need further testing
+ - If you need any help, create a ticket or discuss on [Discord](https://discord.gg/KxkjDVg)
+
+## YourKit
+
+
+
+
+Thank you to YourKit for supporting our product by providing us with their innovative and intelligent tools
+for monitoring and profiling Java and .NET applications.
+YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor
diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt
index 47db67011..662e1c150 100644
--- a/buildSrc/src/main/kotlin/PlatformConfig.kt
+++ b/buildSrc/src/main/kotlin/PlatformConfig.kt
@@ -19,6 +19,7 @@ import org.gradle.kotlin.dsl.withType
fun Project.applyPlatformAndCoreConfiguration() {
applyCommonConfiguration()
apply(plugin = "java")
+ apply(plugin = "eclipse")
apply(plugin = "idea")
apply(plugin = "maven")
// apply(plugin = "checkstyle")
diff --git a/config/checkstyle/checkstyle-suppression.xml b/config/checkstyle/checkstyle-suppression.xml
index a48ff1f81..6e77e27e7 100644
--- a/config/checkstyle/checkstyle-suppression.xml
+++ b/config/checkstyle/checkstyle-suppression.xml
@@ -10,4 +10,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index d080f62ec..d024993f8 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -96,6 +96,7 @@ Checks based on Google Checks, modified for EngineHub.
value="Member name ''{0}'' must match pattern ''{1}''."/>
+
@@ -106,6 +107,7 @@ Checks based on Google Checks, modified for EngineHub.
value="Class type name ''{0}'' must match pattern ''{1}''."/>
+
@@ -186,6 +188,7 @@ Checks based on Google Checks, modified for EngineHub.
+
diff --git a/contrib/craftscripts/draw.js b/contrib/craftscripts/draw.js
index fb7e4f050..b117d226e 100644
--- a/contrib/craftscripts/draw.js
+++ b/contrib/craftscripts/draw.js
@@ -83,7 +83,7 @@ var clothColorsOpt = [
];
var clothColorsOptHD = [
makeColor(168, 168, 168), // White
- makeColor(143, 59, 0), // Orange
+ makeColor(143, 59, 0), // Orange
makeColor(152, 0, 67), // Magenta
makeColor(0, 153, 153), // Light blue
makeColor(150, 150, 0), // Yellow
@@ -115,16 +115,16 @@ function colorDistance(c1, c2) {
function findClosestWoolColor(col, clothColors) {
var closestId = 0;
var closestDistance = colorDistance(col, clothColors[0]);
-
- for(var i = 1; i < clothColors.length; i++) {
+
+ for (var i = 1; i < clothColors.length; i++) {
var dist = colorDistance(col, clothColors[i]);
-
- if(dist < closestDistance) {
+
+ if (dist < closestDistance) {
closestId = i;
closestDistance = dist;
}
}
-
+
return closestId;
}
@@ -135,10 +135,10 @@ var f = context.getSafeOpenFile("drawings", argv[1], "png", ["png", "jpg", "jpeg
var sess = context.remember();
var upright = argv[2] == "v";
var colors = clothColors;
-if(argv[3] == "opt") {
+if (argv[3] == "opt") {
colors = clothColorsOpt;
player.print("Using optimized palette");
-} else if(argv[3] == "optHD") {
+} else if (argv[3] == "optHD") {
colors = clothColorsOptHD;
player.print("Using optimized HD palette");
}
diff --git a/contrib/craftscripts/roof.js b/contrib/craftscripts/roof.js
index b1201ea3a..82564e7dc 100644
--- a/contrib/craftscripts/roof.js
+++ b/contrib/craftscripts/roof.js
@@ -31,7 +31,7 @@ var blocktype = context.getBlock(argv[1]);
var cycles = region.getLength();
-if (region.getWidth() > cycles){
+if (region.getWidth() > cycles) {
cycles = region.getWidth();
}
@@ -50,4 +50,4 @@ for (var c = 0; c < cycles; c++) {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java
index fd110b2e3..9357e693f 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java
@@ -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);
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java
index 8550f02b7..c4a539179 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java
@@ -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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BlockMaterial_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BlockMaterial_1_15_2.java
index 7078d9f4d..086b6e776 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BlockMaterial_1_15_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BlockMaterial_1_15_2.java
@@ -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 {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java
index f81bfdd9e..8098145a1 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java
@@ -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 future = craftWorld.getChunkAtAsync(X, Z, true);
+ CompletableFuture 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 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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java
index 504697b57..21e19e33e 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java
@@ -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 posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
- private final static Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_15_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
+ private static final Function 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[] slices = getChunk().getEntitySlices();
int size = 0;
for (List 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 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 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[] entities = nmsChunk.getEntitySlices();
@@ -488,7 +497,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
Set 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 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 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);
}
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/FAWEWorldNativeAccess_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/FAWEWorldNativeAccess_1_15_2.java
index 9ce24d789..bd3767b9a 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/FAWEWorldNativeAccess_1_15_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/FAWEWorldNativeAccess_1_15_2.java
@@ -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 {
- 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;
@@ -170,4 +171,4 @@ public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess> 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));
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BlockMaterial_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BlockMaterial_1_16_1.java
index 207cb6e60..4c64a66ff 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BlockMaterial_1_16_1.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BlockMaterial_1_16_1.java
@@ -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 {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java
index 37e6eb9af..d148d8e81 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java
@@ -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 future = craftWorld.getChunkAtAsync(X, Z, true);
+ CompletableFuture 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 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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java
index 5bd3fb709..a4d4c1227 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java
@@ -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 posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
- private final static Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
+ private static final Function 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[] slices = getChunk().getEntitySlices();
int size = 0;
for (List 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 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 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[] entities = nmsChunk.getEntitySlices();
@@ -456,7 +499,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
Set 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 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 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);
}
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/FAWEWorldNativeAccess_1_16.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/FAWEWorldNativeAccess_1_16.java
index 6b68ae95d..d3a3072e8 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/FAWEWorldNativeAccess_1_16.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/FAWEWorldNativeAccess_1_16.java
@@ -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 {
- 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;
@@ -171,4 +172,4 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess> 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));
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BlockMaterial_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BlockMaterial_1_16_2.java
index a0632695f..1b72cc954 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BlockMaterial_1_16_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BlockMaterial_1_16_2.java
@@ -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 {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java
index 9ce2e25f1..d0c5fb2cd 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java
@@ -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 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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java
index 1965b2830..e61453ddf 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java
@@ -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 posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
- private final static Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
+ private static final Function 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[] slices = getChunk().getEntitySlices();
int size = 0;
for (List 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 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 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[] entities = nmsChunk.getEntitySlices();
@@ -459,7 +502,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
Set 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 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 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);
}
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/FAWEWorldNativeAccess_1_16.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/FAWEWorldNativeAccess_1_16.java
index 4d7c9f5ca..664fd0609 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/FAWEWorldNativeAccess_1_16.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/FAWEWorldNativeAccess_1_16.java
@@ -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 {
- 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;
@@ -171,4 +172,4 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess> 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));
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java
index 0212cdbc8..678270aba 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java
@@ -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);
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java
index 507594edf..176167e36 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java
@@ -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 recipients = event.getRecipients();
-// Iterator 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 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 recipients = event.getRecipients();
+ Iterator 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 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;
+ }
+ }
+ }*/
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java
index 6d2679df3..59f391fbd 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java
@@ -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}.
+ *
+ *
+ * The virtual world will be displayed inside the current world. Block/Chunk/Movement packets
+ * need to be handled properly.
+ *
*/
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 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 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);
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java
index d9b20df0c..4c597c5bf 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java
@@ -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.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 badChunks = new Long2ObjectOpenHashMap<>();
private Long2ObjectOpenHashMap 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) {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener9.java
similarity index 96%
rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java
rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener9.java
index 2c582b7d2..adaa01cd6 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener9.java
@@ -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;
}
-}
\ No newline at end of file
+}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8Plus.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8Plus.java
deleted file mode 100644
index 35e37e5a5..000000000
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8Plus.java
+++ /dev/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();
- }
-}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java
index e89b90745..a50593081 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java
@@ -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 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;
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/preloader/PluginPreloader.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/preloader/PluginPreloader.java
index dcc98dc26..05fbb2f5f 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/preloader/PluginPreloader.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/preloader/PluginPreloader.java
@@ -77,7 +77,9 @@ public class PluginPreloader extends PluginBase {
loaded = region.getChunks();
Iterator 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 onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
+ @Nullable
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return null;
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java
index aeb6ffb9f..134c8c270 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java
@@ -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 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 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);
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java
index c20f7ca43..eb89edfdd 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java
@@ -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);
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java
index 3cb636bee..554be7c7e 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java
@@ -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;
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java
index ba25404bc..27425aa9d 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java
@@ -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);
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java
index d8f922ef0..f3aa053a9 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java
@@ -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()));
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java
index f8f1fe2c2..5704bb9e9 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java
@@ -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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java
index b3ab082e0..437e0c58a 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java
@@ -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 {
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java
index d0cfdf790..4c6be8306 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java
@@ -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 plots = new ArrayList<>(area.getPlots());
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java
index 30ed06ff2..0e5c93da7 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java
@@ -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",
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java
index 36f4944a5..5b28a0c4a 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java
@@ -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 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;
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java
index 2d3e9b613..999a2224f 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java
@@ -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;
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweSchematicHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweSchematicHandler.java
index 40d0668f1..c0539e682 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweSchematicHandler.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweSchematicHandler.java
@@ -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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotRegionFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotRegionFilter.java
index bf1408415..91ca83c74 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotRegionFilter.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotRegionFilter.java
@@ -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 plots = new ArrayList<>(area.getPlots());
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java
index 059fe87c8..e7b105bb1 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java
@@ -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 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;
}
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java
index e3f890537..e79d06ec4 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java
@@ -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> map = hashToNMSTag.get();
if (map == null) {
@@ -72,7 +80,9 @@ public class ItemUtil {
WeakReference 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();
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java
index d1bdf2731..d582e924f 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java
@@ -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
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java
index a2c38dce8..1f5c73c05 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java
@@ -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 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 getDrops(ItemStack tool, Entity entity) {
- return Collections.emptyList(); //todo
- }
-
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java
index d2e3cb30b..e934d45ea 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java
@@ -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];
}
diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java
index f6886b500..8b230cb44 100644
--- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java
+++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java
@@ -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 @NotNull T spawnArrow(@NotNull Location location,
+ public T spawnArrow(@NotNull Location location,
@NotNull Vector direction, float speed, float spread, @NotNull Class 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 getLivingEntities() {
+ @NotNull
+ public List getLivingEntities() {
return TaskManager.IMP.sync(() -> parent.getLivingEntities());
}
+ @NotNull
@Override
@Deprecated
- public @NotNull Collection getEntitiesByClass(final Class... classes) {
+ public Collection getEntitiesByClass(
+ @NotNull
+ final Class... classes) {
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(classes));
}
+ @NotNull
@Override
- public @NotNull Collection getEntitiesByClass(
- final @NotNull Class cls) {
+ public Collection getEntitiesByClass(
+ @NotNull
+ final Class cls) {
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
}
@Override
- public @NotNull Collection getEntitiesByClasses(final Class>... classes) {
+ @NotNull
+ public Collection getEntitiesByClasses(
+ @NotNull
+ final Class>... classes) {
return TaskManager.IMP.sync(() -> parent.getEntitiesByClasses(classes));
}
@Override
- public @NotNull List getPlayers() {
+ @NotNull
+ public List getPlayers() {
return TaskManager.IMP.sync(() -> parent.getPlayers());
}
@Override
- public @NotNull Collection getNearbyEntities(final @NotNull Location location,
+ @NotNull
+ public Collection 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 getPopulators() {
+ @NotNull
+ public List getPopulators() {
return parent.getPopulators();
}
+ @NotNull
@Override
- public @NotNull T spawn(final @NotNull Location location,
- final @NotNull Class clazz) throws IllegalArgumentException {
+ public T spawn(@NotNull final Location location, @NotNull final Class clazz) throws IllegalArgumentException {
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
}
+ @NotNull
@Override
- public @NotNull T spawn(@NotNull Location location, @NotNull Class clazz,
+ public T spawn(@NotNull Location location, @NotNull Class clazz,
Consumer function) throws IllegalArgumentException {
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
}
+ @NotNull
@Override
- public @NotNull T spawn(@NotNull Location location, @NotNull Class clazz,
- @Nullable Consumer function, CreatureSpawnEvent.@NotNull SpawnReason reason)
+ public T spawn(@NotNull Location location, @NotNull Class clazz,
+ @Nullable Consumer 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