mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Part 1 of upstream merge and format
This commit is contained in:
@ -29,12 +29,6 @@ import com.boydti.fawe.util.image.ImageViewer;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -47,6 +41,13 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FaweBukkit implements IFawe, Listener {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class);
|
||||
@ -83,18 +84,20 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
|
||||
chunksStretched = Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1]) >= 16;
|
||||
|
||||
chunksStretched =
|
||||
Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1]) >= 16;
|
||||
|
||||
//Vault is Spigot/Paper only so this needs to be done in the Bukkit module
|
||||
setupVault();
|
||||
|
||||
|
||||
//PlotSquared support is limited to Spigot/Paper as of 02/20/2020
|
||||
TaskManager.IMP.later(this::setupPlotSquared, 0);
|
||||
|
||||
|
||||
// Registered delayed Event Listeners
|
||||
TaskManager.IMP.task(() -> {
|
||||
// Fix for ProtocolSupport
|
||||
Settings.IMP.PROTOCOL_SUPPORT_FIX = Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
|
||||
Settings.IMP.PROTOCOL_SUPPORT_FIX =
|
||||
Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
|
||||
|
||||
// This class
|
||||
Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin);
|
||||
@ -112,28 +115,31 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueueHandler getQueueHandler() {
|
||||
@Override public QueueHandler getQueueHandler() {
|
||||
return new BukkitQueueHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ImageViewer getImageViewer(com.sk89q.worldedit.entity.Player player) {
|
||||
if (listeningImages && imageListener == null) return null;
|
||||
if (listeningImages && imageListener == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
listeningImages = true;
|
||||
registerPacketListener();
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
|
||||
if (manager.getPlugin("PacketListenerApi") == null) {
|
||||
File output = new File(plugin.getDataFolder().getParentFile(), "PacketListenerAPI_v3.7.6-SNAPSHOT.jar");
|
||||
File output = new File(plugin.getDataFolder().getParentFile(),
|
||||
"PacketListenerAPI_v3.7.6-SNAPSHOT.jar");
|
||||
byte[] jarData = Jars.PL_v3_7_6.download();
|
||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||
fos.write(jarData);
|
||||
}
|
||||
}
|
||||
if (manager.getPlugin("MapManager") == null) {
|
||||
File output = new File(plugin.getDataFolder().getParentFile(), "MapManager_v1.7.8-SNAPSHOT.jar");
|
||||
File output = new File(plugin.getDataFolder().getParentFile(),
|
||||
"MapManager_v1.7.8-SNAPSHOT.jar");
|
||||
byte[] jarData = Jars.MM_v1_7_8.download();
|
||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||
fos.write(jarData);
|
||||
@ -144,17 +150,16 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
this.imageListener = new BukkitImageListener(plugin);
|
||||
}
|
||||
return viewer;
|
||||
} catch (Throwable ignore) {}
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(final String message) {
|
||||
@Override public void debug(final String message) {
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDirectory() {
|
||||
@Override public File getDirectory() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@ -172,9 +177,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vault isn't required, but used for setting player permissions (WorldEdit bypass)
|
||||
*/
|
||||
private void setupVault() {
|
||||
try {
|
||||
this.vault = new VaultUtil();
|
||||
@ -182,8 +184,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDebugInfo() {
|
||||
@Override public String getDebugInfo() {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
|
||||
msg.append("Plugins: \n");
|
||||
@ -195,10 +196,9 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* The task manager handles sync/async tasks
|
||||
* The task manager handles sync/async tasks.
|
||||
*/
|
||||
@Override
|
||||
public TaskManager getTaskManager() {
|
||||
@Override public TaskManager getTaskManager() {
|
||||
return new BukkitTaskMan(plugin);
|
||||
}
|
||||
|
||||
@ -209,9 +209,9 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
/**
|
||||
* A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions
|
||||
*/
|
||||
@Override
|
||||
public Collection<FaweMaskManager> getMaskManagers() {
|
||||
final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
@Override public Collection<FaweMaskManager> getMaskManagers() {
|
||||
final Plugin worldguardPlugin =
|
||||
Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
final ArrayList<FaweMaskManager> managers = new ArrayList<>();
|
||||
if (worldguardPlugin != null && worldguardPlugin.isEnabled()) {
|
||||
try {
|
||||
@ -236,7 +236,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
|
||||
final Plugin griefpreventionPlugin =
|
||||
Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
|
||||
if (griefpreventionPlugin != null && griefpreventionPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new GriefPreventionFeature(griefpreventionPlugin));
|
||||
@ -258,8 +259,7 @@ 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);
|
||||
@ -282,38 +282,34 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
wePlayer.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatform() {
|
||||
@Override public String getPlatform() {
|
||||
return "Bukkit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
@Override public UUID getUUID(String name) {
|
||||
return Bukkit.getOfflinePlayer(name).getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(UUID uuid) {
|
||||
@Override public String getName(UUID uuid) {
|
||||
return Bukkit.getOfflinePlayer(uuid).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Preloader getPreloader() {
|
||||
@Override public Preloader getPreloader() {
|
||||
if (PaperLib.isPaper()) {
|
||||
return new AsyncPreloader();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunksStretched() {
|
||||
@Override public boolean isChunksStretched() {
|
||||
return chunksStretched;
|
||||
}
|
||||
|
||||
private void setupPlotSquared() {
|
||||
Plugin plotSquared = this.plugin.getServer().getPluginManager().getPlugin("PlotSquared");
|
||||
if (plotSquared == null)
|
||||
if (plotSquared == null) {
|
||||
return;
|
||||
}
|
||||
if (plotSquared.getClass().getPackage().toString().contains("intellectualsites")) {
|
||||
WEManager.IMP.managers
|
||||
.add(new com.boydti.fawe.bukkit.regions.plotsquaredv4.PlotSquaredFeature());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_14;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
@ -28,21 +26,6 @@ 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 java.util.AbstractSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
import net.minecraft.server.v1_14_R1.BiomeBase;
|
||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_14_R1.Chunk;
|
||||
@ -72,6 +55,25 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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 java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
@SuppressWarnings("checkstyle:TypeName")
|
||||
public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_14.class);
|
||||
@ -79,26 +81,27 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
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];
|
||||
|
||||
public BukkitGetBlocks_1_14(World world, int X, int Z) {
|
||||
this(((CraftWorld) world).getHandle(), X, Z);
|
||||
public BukkitGetBlocks_1_14(World world, int chunkX, int chunkZ) {
|
||||
this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public BukkitGetBlocks_1_14(WorldServer world, int X, int Z) {
|
||||
public BukkitGetBlocks_1_14(WorldServer world, int chunkX, int chunkZ) {
|
||||
this.world = world;
|
||||
this.X = X;
|
||||
this.Z = Z;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return X;
|
||||
return chunkX;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return Z;
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,16 +112,21 @@ public class BukkitGetBlocks_1_14 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;
|
||||
}
|
||||
return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
return new LazyCompoundTag_1_14(
|
||||
Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
}
|
||||
|
||||
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||
private static final Function<BlockPosition, BlockVector3> posNms2We =
|
||||
v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||
|
||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
private static final Function<TileEntity, CompoundTag> nmsTile2We =
|
||||
tileEntity -> new LazyCompoundTag_1_14(
|
||||
Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
|
||||
@Override
|
||||
public Map<BlockVector3, CompoundTag> getTiles() {
|
||||
@ -135,19 +143,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
if (skyLight[layer] == null) {
|
||||
//getDataLayerData
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||
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;
|
||||
}
|
||||
long l = BlockPosition.a(x, y, z);
|
||||
return skyLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
|
||||
return skyLight[layer]
|
||||
.a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)),
|
||||
SectionPosition.b(BlockPosition.d(l)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,19 +168,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
if (blockLight[layer] == null) {
|
||||
//getDataLayerData
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
NibbleArray nibbleArray =
|
||||
world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).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.BLOCK, sectionPosition, nibbleArray);
|
||||
((LightEngine) world.getChunkProvider().getLightEngine())
|
||||
.a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray);
|
||||
}
|
||||
blockLight[layer] = nibbleArray;
|
||||
}
|
||||
long l = BlockPosition.a(x, y, z);
|
||||
return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
|
||||
return blockLight[layer]
|
||||
.a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)),
|
||||
SectionPosition.b(BlockPosition.d(l)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,7 +212,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
List<Entity>[] slices = getChunk().getEntitySlices();
|
||||
int size = 0;
|
||||
for (List<Entity> slice : slices) {
|
||||
if (slice != null) size += slice.size();
|
||||
if (slice != null) {
|
||||
size += slice.size();
|
||||
}
|
||||
}
|
||||
if (slices.length == 0) {
|
||||
return Collections.emptySet();
|
||||
@ -238,19 +256,21 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> result = StreamSupport
|
||||
.stream(Iterables.concat(slices).spliterator(), false).map(input -> {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance()
|
||||
.getBukkitImplAdapter();
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
return (CompoundTag) adapter.toNative(input.save(tag));
|
||||
}).collect(Collectors.toList());
|
||||
Iterable<CompoundTag> result =
|
||||
StreamSupport.stream(Iterables.concat(slices).spliterator(), false)
|
||||
.map(input -> {
|
||||
BukkitImplAdapter adapter =
|
||||
WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
return (CompoundTag) adapter.toNative(input.save(tag));
|
||||
}).collect(Collectors.toList());
|
||||
return result.iterator();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||
private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections,
|
||||
ChunkSection section, char[] arr, int layer) {
|
||||
synchronized (get) {
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
@ -272,15 +292,16 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
entity.valid = false;
|
||||
}
|
||||
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int X, int Z) {
|
||||
return BukkitAdapter_1_14.ensureLoaded(nmsWorld, X, Z);
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int chunkX,
|
||||
int chunkZ) {
|
||||
return BukkitAdapter_1_14.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
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
|
||||
@ -309,7 +330,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
if (!set.hasSection(layer)) continue;
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bitMask |= 1 << layer;
|
||||
|
||||
@ -318,13 +341,16 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
ChunkSection existingSection = sections[layer];
|
||||
if (existingSection == null) {
|
||||
newSection = BukkitAdapter_1_14.newChunkSection(layer, setArr, fastmode);
|
||||
if (BukkitAdapter_1_14.setSectionAtomic(sections, null, newSection, layer)) {
|
||||
if (BukkitAdapter_1_14
|
||||
.setSectionAtomic(sections, null, newSection, layer)) {
|
||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||
continue;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@ -349,9 +375,12 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
} else if (lock.isModified()) {
|
||||
this.reset(layer);
|
||||
}
|
||||
newSection = BukkitAdapter_1_14.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_14.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||
log.error("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
|
||||
newSection = BukkitAdapter_1_14
|
||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_14
|
||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ
|
||||
+ " layer: " + layer);
|
||||
continue;
|
||||
} else {
|
||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||
@ -399,12 +428,14 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
|
||||
Runnable[] syncTasks = null;
|
||||
|
||||
int bx = X << 4;
|
||||
int bz = Z << 4;
|
||||
int bx = chunkX << 4;
|
||||
int bz = chunkZ << 4;
|
||||
|
||||
Set<UUID> entityRemoves = set.getEntityRemoves();
|
||||
if (entityRemoves != null && !entityRemoves.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[3];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[3];
|
||||
}
|
||||
|
||||
syncTasks[2] = () -> {
|
||||
final List<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||
@ -426,7 +457,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
|
||||
Set<CompoundTag> entities = set.getEntities();
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[2];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[2];
|
||||
}
|
||||
|
||||
syncTasks[1] = () -> {
|
||||
for (final CompoundTag nativeTag : entities) {
|
||||
@ -435,7 +468,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
final ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
||||
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
||||
if (idTag == null || posTag == null || rotTag == null) {
|
||||
getLogger(BukkitGetBlocks_1_14.class).debug("Unknown entity tag: " + nativeTag);
|
||||
getLogger(BukkitGetBlocks_1_14.class)
|
||||
.debug("Unknown entity tag: " + nativeTag);
|
||||
continue;
|
||||
}
|
||||
final double x = posTag.getDouble(0);
|
||||
@ -450,18 +484,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
Entity entity = type.a(nmsWorld);
|
||||
if (entity != null) {
|
||||
UUID uuid = entity.getUniqueID();
|
||||
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
||||
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
||||
entityTagMap.put("UUIDMost",
|
||||
new LongTag(uuid.getMostSignificantBits()));
|
||||
entityTagMap.put("UUIDLeast",
|
||||
new LongTag(uuid.getLeastSignificantBits()));
|
||||
if (nativeTag != null) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
|
||||
BukkitImplAdapter adapter =
|
||||
WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
final NBTTagCompound tag =
|
||||
(NBTTagCompound) adapter.fromNative(nativeTag);
|
||||
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);
|
||||
nmsWorld
|
||||
.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,7 +511,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
// set tiles
|
||||
Map<BlockVector3, CompoundTag> tiles = set.getTiles();
|
||||
if (tiles != null && !tiles.isEmpty()) {
|
||||
if (syncTasks == null) syncTasks = new Runnable[1];
|
||||
if (syncTasks == null) {
|
||||
syncTasks = new Runnable[1];
|
||||
}
|
||||
|
||||
syncTasks[0] = () -> {
|
||||
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
||||
@ -490,8 +531,10 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
tileEntity = nmsWorld.getTileEntity(pos);
|
||||
}
|
||||
if (tileEntity != null) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
|
||||
BukkitImplAdapter adapter =
|
||||
WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
final NBTTagCompound tag =
|
||||
(NBTTagCompound) adapter.fromNative(nativeTag);
|
||||
tag.set("x", new NBTTagInt(x));
|
||||
tag.set("y", new NBTTagInt(y));
|
||||
tag.set("z", new NBTTagInt(z));
|
||||
@ -514,8 +557,11 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
nmsChunk.mustNotSave = false;
|
||||
nmsChunk.markDirty();
|
||||
// send to player
|
||||
BukkitAdapter_1_14.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) finalizer.run();
|
||||
BukkitAdapter_1_14
|
||||
.sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate);
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (syncTasks != null) {
|
||||
@ -532,7 +578,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
}
|
||||
}
|
||||
if (callback == null) {
|
||||
if (finalizer != null) finalizer.run();
|
||||
if (finalizer != null) {
|
||||
finalizer.run();
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return queueHandler.async(callback, null);
|
||||
@ -545,7 +593,9 @@ public class BukkitGetBlocks_1_14 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();
|
||||
}
|
||||
@ -577,11 +627,13 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
lock.setModified(false);
|
||||
// Efficiently convert ChunkSection to raw data
|
||||
try {
|
||||
FAWE_Spigot_v1_14_R4 adapter = ((FAWE_Spigot_v1_14_R4) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
||||
FAWE_Spigot_v1_14_R4 adapter =
|
||||
((FAWE_Spigot_v1_14_R4) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
||||
|
||||
final DataPaletteBlock<IBlockData> blocks = section.getBlocks();
|
||||
final DataBits bits = (DataBits) BukkitAdapter_1_14.fieldBits.get(blocks);
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette.get(blocks);
|
||||
final DataPalette<IBlockData> palette =
|
||||
(DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette.get(blocks);
|
||||
|
||||
final int bitsPerEntry = bits.c();
|
||||
final long[] blockStates = bits.a();
|
||||
@ -695,7 +747,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
synchronized (this) {
|
||||
tmp = nmsChunk;
|
||||
if (tmp == null) {
|
||||
nmsChunk = tmp = ensureLoaded(this.world, X, Z);
|
||||
nmsChunk = tmp = ensureLoaded(this.world, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -708,12 +760,14 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
continue;
|
||||
}
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), Y);
|
||||
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(skyBlock).a(sectionPosition);
|
||||
NibbleArray nibble =
|
||||
world.getChunkProvider().getLightEngine().a(skyBlock).a(sectionPosition);
|
||||
if (nibble == null) {
|
||||
byte[] a = new byte[2048];
|
||||
Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0);
|
||||
nibble = new NibbleArray(a);
|
||||
((LightEngine) world.getChunkProvider().getLightEngine()).a(skyBlock, sectionPosition, nibble);
|
||||
((LightEngine) world.getChunkProvider().getLightEngine())
|
||||
.a(skyBlock, sectionPosition, nibble);
|
||||
}
|
||||
synchronized (nibble) {
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
@ -745,7 +799,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
try {
|
||||
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();
|
||||
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette.get(blocksExisting);
|
||||
final DataPalette<IBlockData> palette =
|
||||
(DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette
|
||||
.get(blocksExisting);
|
||||
int paletteSize;
|
||||
|
||||
if (palette instanceof DataPaletteLinear) {
|
||||
|
@ -8,16 +8,16 @@ import java.lang.reflect.Method;
|
||||
|
||||
public class BukkitReflectionUtils {
|
||||
/**
|
||||
* prefix of bukkit classes
|
||||
* Prefix of Bukkit classes.
|
||||
*/
|
||||
private static volatile String preClassB = null;
|
||||
/**
|
||||
* prefix of minecraft classes
|
||||
* Prefix of Minecraft classes.
|
||||
*/
|
||||
private static volatile String preClassM = null;
|
||||
|
||||
/**
|
||||
* check server version and class names
|
||||
* Check server version and class names.
|
||||
*/
|
||||
public static void init() {
|
||||
final Server server = Bukkit.getServer();
|
||||
@ -50,18 +50,22 @@ public class BukkitReflectionUtils {
|
||||
* @return RefClass object
|
||||
* @throws RuntimeException if no class found
|
||||
*/
|
||||
public static ReflectionUtils.RefClass getRefClass(final String... classes) throws RuntimeException {
|
||||
public static ReflectionUtils.RefClass getRefClass(final String... classes)
|
||||
throws RuntimeException {
|
||||
if (preClassM == null) {
|
||||
init();
|
||||
}
|
||||
for (String className : classes) {
|
||||
try {
|
||||
className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
|
||||
className = className.replace("{cb}", preClassB).replace("{nms}", preClassM)
|
||||
.replace("{nm}", "net.minecraft");
|
||||
return ReflectionUtils.getRefClass(Class.forName(className));
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"));
|
||||
throw new RuntimeException(
|
||||
"no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM)
|
||||
.replace("{nm}", "net.minecraft"));
|
||||
}
|
||||
|
||||
public static Class<?> getNmsClass(final String name) {
|
||||
|
@ -9,10 +9,8 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import java.util.Collections;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -31,8 +29,8 @@ import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AsyncBlock implements Block {
|
||||
|
||||
@ -72,27 +70,33 @@ public class AsyncBlock implements Block {
|
||||
return world.getBlock(x, y, z).getBlockType().getInternalId();
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncBlock getRelative(int modX, int modY, int modZ) {
|
||||
return new AsyncBlock(world, x + modX, y + modY, z + modZ);
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncBlock getRelative(BlockFace face) {
|
||||
return this.getRelative(face.getModX(), face.getModY(), face.getModZ());
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncBlock getRelative(BlockFace face, int distance) {
|
||||
return this.getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
|
||||
return this.getRelative(face.getModX() * distance, face.getModY() * distance,
|
||||
face.getModZ() * distance);
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public Material getType() {
|
||||
return getBlockData().getMaterial();
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return BukkitAdapter.adapt(world.getBlock(x, y, z));
|
||||
}
|
||||
@ -137,7 +141,8 @@ public class AsyncBlock implements Block {
|
||||
return (byte) 15;
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
@ -157,14 +162,15 @@ public class AsyncBlock implements Block {
|
||||
return z;
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Location loc) {
|
||||
if(loc != null) {
|
||||
if (loc != null) {
|
||||
loc.setWorld(this.getWorld());
|
||||
loc.setX(this.x);
|
||||
loc.setY(this.y);
|
||||
@ -173,7 +179,8 @@ public class AsyncBlock implements Block {
|
||||
return loc;
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncChunk getChunk() {
|
||||
return world.getChunkAt(x >> 4, z >> 4);
|
||||
}
|
||||
@ -219,7 +226,8 @@ public class AsyncBlock implements Block {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncBlockState getState() {
|
||||
BaseBlock state = world.getFullBlock(x, y, z);
|
||||
switch (state.getBlockType().getInternalId()) {
|
||||
@ -247,7 +255,8 @@ public class AsyncBlock implements Block {
|
||||
return getState();
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
return world.getAdapter().adapt(world.getBiomeType(x, y, z));
|
||||
}
|
||||
@ -339,13 +348,15 @@ public class AsyncBlock implements Block {
|
||||
public boolean breakNaturally(@NotNull ItemStack tool, boolean value) {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops() {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(@NotNull ItemStack tool) {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool));
|
||||
}
|
||||
@ -355,7 +366,8 @@ public class AsyncBlock implements Block {
|
||||
this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(@NotNull String metadataKey) {
|
||||
return this.getUnsafeBlock().getMetadata(metadataKey);
|
||||
}
|
||||
@ -376,11 +388,13 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, @NotNull FluidCollisionMode arg3) {
|
||||
public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2,
|
||||
@NotNull FluidCollisionMode arg3) {
|
||||
return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public BoundingBox getBoundingBox() {
|
||||
return this.getUnsafeBlock().getBoundingBox();
|
||||
}
|
||||
|
@ -1,19 +1,14 @@
|
||||
package com.boydti.fawe.bukkit.wrapper;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -22,6 +17,8 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AsyncBlockState implements BlockState {
|
||||
|
||||
private BaseBlock state;
|
||||
@ -165,7 +162,8 @@ public class AsyncBlockState implements BlockState {
|
||||
@Override
|
||||
public void setRawData(byte data) {
|
||||
int combinedId = getTypeId() + (data << BlockTypesCache.BIT_OFFSET);
|
||||
state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId).toBaseBlock(state.getNbtData());
|
||||
state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId)
|
||||
.toBaseBlock(state.getNbtData());
|
||||
this.blockData = BukkitAdapter.adapt(state);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.boydti.fawe.bukkit.wrapper;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import java.util.function.Supplier;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.World;
|
||||
@ -15,6 +13,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AsyncChunk implements Chunk {
|
||||
|
||||
@ -68,11 +67,14 @@ public class AsyncChunk implements Chunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain) {
|
||||
public ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome,
|
||||
boolean includeBiomeTempRain) {
|
||||
if (Fawe.isMainThread()) {
|
||||
return world.getChunkAt(x, z).getChunkSnapshot(includeMaxblocky, includeBiome, includeBiomeTempRain);
|
||||
return world.getChunkAt(x, z)
|
||||
.getChunkSnapshot(includeMaxblocky, includeBiome, includeBiomeTempRain);
|
||||
}
|
||||
return whenLoaded(() -> world.getChunkAt(x, z).getChunkSnapshot(includeBiome, includeBiome, includeBiomeTempRain));
|
||||
return whenLoaded(() -> world.getChunkAt(x, z)
|
||||
.getChunkSnapshot(includeBiome, includeBiome, includeBiomeTempRain));
|
||||
}
|
||||
|
||||
private <T> T whenLoaded(Supplier<T> task) {
|
||||
|
@ -13,14 +13,6 @@ 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 java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -69,14 +61,24 @@ import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Modify the world from an async thread<br>
|
||||
* - Use world.commit() to execute all the changes<br>
|
||||
* - Any Chunk/Block/BlockState objects returned should also be safe to use from the same async thread<br>
|
||||
* - Only block read,write and biome write are fast, other methods will perform slower async<br>
|
||||
* -
|
||||
* @see #wrap(World)
|
||||
* @see #create(WorldCreator)
|
||||
* - Use world.commit() to execute all the changes<br>
|
||||
* - Any Chunk/Block/BlockState objects returned should also be safe to use from the same async thread<br>
|
||||
* - Only block read,write and biome write are fast, other methods will perform slower async<br>
|
||||
* -
|
||||
*
|
||||
* @see #wrap(World)
|
||||
* @see #create(WorldCreator)
|
||||
*/
|
||||
public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@ -84,14 +86,15 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
private BukkitImplAdapter adapter;
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i,
|
||||
double v3, double v4, double v5, double v6, T t) {
|
||||
parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, v6, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #wrap(World)} instead
|
||||
* @param parent Parent world
|
||||
* @param parent Parent world
|
||||
* @param autoQueue
|
||||
* @deprecated use {@link #wrap(World)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public AsyncWorld(World parent, boolean autoQueue) {
|
||||
@ -103,9 +106,9 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #wrap(World)} instead
|
||||
* @param parent
|
||||
* @param extent
|
||||
* @deprecated use {@link #wrap(World)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public AsyncWorld(World parent, Extent extent) {
|
||||
@ -115,7 +118,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a world for async usage
|
||||
* Wrap a world for async usage.
|
||||
*
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
@ -137,7 +141,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
/**
|
||||
* Create a world async (untested)
|
||||
* - Only optimized for 1.10
|
||||
* - Only optimized for 1.10
|
||||
*
|
||||
* @param creator
|
||||
* @return
|
||||
*/
|
||||
@ -173,47 +178,56 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, T t) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i,
|
||||
T t) {
|
||||
parent.spawnParticle(particle, location, i, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z,
|
||||
int count, T data) {
|
||||
parent.spawnParticle(particle, x, y, z, count, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) {
|
||||
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count,
|
||||
double offsetX, double offsetY, double offsetZ) {
|
||||
parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5) {
|
||||
public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i,
|
||||
double v3, double v4, double v5) {
|
||||
parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, T t) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i,
|
||||
double v, double v1, double v2, T t) {
|
||||
parent.spawnParticle(particle, location, i, v, v1, v2, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, T t) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i,
|
||||
double v3, double v4, double v5, T t) {
|
||||
parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, double v3) {
|
||||
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i,
|
||||
double v, double v1, double v2, double v3) {
|
||||
parent.spawnParticle(particle, location, i, v, v1, v2, v3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6) {
|
||||
public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i,
|
||||
double v3, double v4, double v5, double v6) {
|
||||
parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, v6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, double v3, T t) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i,
|
||||
double v, double v1, double v2, double v3, T t) {
|
||||
parent.spawnParticle(particle, location, i, v, v1, v2, v3, t);
|
||||
}
|
||||
|
||||
@ -236,7 +250,9 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
for (int y = getMaxHeight() - 1; y >= 0; y--) {
|
||||
BlockState state = this.getBlock(x, y, z);
|
||||
if (!state.getMaterial().isAir()) return y;
|
||||
if (!state.getMaterial().isAir()) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -259,7 +275,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(int i, int i1, @NotNull HeightMap heightMap) {
|
||||
return parent.getHighestBlockYAt(i,i1, heightMap);
|
||||
return parent.getHighestBlockYAt(i, i1, heightMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -410,17 +426,20 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Item dropItemNaturally(final @NotNull Location location, final @NotNull ItemStack item) {
|
||||
public @NotNull Item dropItemNaturally(final @NotNull Location location,
|
||||
final @NotNull 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) {
|
||||
public @NotNull Arrow spawnArrow(final @NotNull Location location,
|
||||
final @NotNull Vector direction, final float speed, final float spread) {
|
||||
return TaskManager.IMP.sync(() -> parent.spawnArrow(location, direction, speed, spread));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AbstractArrow> @NotNull T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
|
||||
public <T extends AbstractArrow> @NotNull T spawnArrow(@NotNull Location location,
|
||||
@NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
|
||||
return parent.spawnArrow(location, direction, speed, spread, clazz);
|
||||
}
|
||||
|
||||
@ -430,7 +449,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(final @NotNull Location loc, final @NotNull TreeType type, final @NotNull BlockChangeDelegate delegate) {
|
||||
public boolean generateTree(final @NotNull Location loc, final @NotNull TreeType type,
|
||||
final @NotNull BlockChangeDelegate delegate) {
|
||||
return TaskManager.IMP.sync(() -> parent.generateTree(loc, type, delegate));
|
||||
}
|
||||
|
||||
@ -466,7 +486,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> @NotNull Collection<T> getEntitiesByClass(final @NotNull Class<T> cls) {
|
||||
public <T extends Entity> @NotNull Collection<T> getEntitiesByClass(
|
||||
final @NotNull Class<T> cls) {
|
||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
|
||||
}
|
||||
|
||||
@ -481,7 +502,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(final @NotNull Location location, final double x, final double y, final double z) {
|
||||
public @NotNull Collection<Entity> getNearbyEntities(final @NotNull Location location,
|
||||
final double x, final double y, final double z) {
|
||||
return TaskManager.IMP.sync(() -> parent.getNearbyEntities(location, x, y, z));
|
||||
}
|
||||
|
||||
@ -576,17 +598,17 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(final double x, final double y, final double z, final float power, final boolean setFire, final boolean breakBlocks) {
|
||||
return TaskManager.IMP.sync(
|
||||
() ->
|
||||
parent.createExplosion(x, y, z, power, setFire, breakBlocks));
|
||||
public boolean createExplosion(final double x, final double y, final double z,
|
||||
final float power, final boolean setFire, final boolean breakBlocks) {
|
||||
return TaskManager.IMP
|
||||
.sync(() -> parent.createExplosion(x, y, z, power, setFire, breakBlocks));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(double x, double y, double z, float power, boolean setFire,
|
||||
boolean breakBlocks, @Nullable Entity source) {
|
||||
return TaskManager.IMP.sync(
|
||||
() -> parent.createExplosion(x, y, z, power, setFire, breakBlocks, source));
|
||||
return TaskManager.IMP
|
||||
.sync(() -> parent.createExplosion(x, y, z, power, setFire, breakBlocks, source));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -641,33 +663,40 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(final @NotNull Location location, final @NotNull Class<T> clazz) throws IllegalArgumentException {
|
||||
public <T extends Entity> @NotNull T spawn(final @NotNull Location location,
|
||||
final @NotNull Class<T> clazz) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||
Consumer<T> function) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, @Nullable Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason) throws IllegalArgumentException {
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||
@Nullable Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason)
|
||||
throws IllegalArgumentException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException {
|
||||
public @NotNull 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 {
|
||||
public @NotNull 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 {
|
||||
public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location,
|
||||
@NotNull BlockData blockData) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
|
||||
}
|
||||
|
||||
@ -677,7 +706,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(final @NotNull Location location, final @NotNull Effect effect, final int data, final int radius) {
|
||||
public void playEffect(final @NotNull Location location, final @NotNull Effect effect,
|
||||
final int data, final int radius) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -692,7 +722,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(final @NotNull Location location, final @NotNull Effect effect, final T data, final int radius) {
|
||||
public <T> void playEffect(final @NotNull Location location, final @NotNull Effect effect,
|
||||
final T data, final int radius) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -702,9 +733,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z, final boolean includeBiome, final boolean includeBiomeTempRain) {
|
||||
return TaskManager.IMP.sync(
|
||||
() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain));
|
||||
public @NotNull ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z,
|
||||
final boolean includeBiome, final boolean includeBiomeTempRain) {
|
||||
return TaskManager.IMP
|
||||
.sync(() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -729,7 +761,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public @NotNull Biome getBiome(int x, int y, int z) {
|
||||
return adapter.adapt(getExtent().getBiomeType(x,y,z));
|
||||
return adapter.adapt(getExtent().getBiomeType(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -884,11 +916,13 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
parent.setWaterAnimalSpawnLimit(limit);
|
||||
}
|
||||
|
||||
@Override public int getWaterAmbientSpawnLimit() {
|
||||
@Override
|
||||
public int getWaterAmbientSpawnLimit() {
|
||||
return parent.getWaterAmbientSpawnLimit();
|
||||
}
|
||||
|
||||
@Override public void setWaterAmbientSpawnLimit(int limit) {
|
||||
@Override
|
||||
public void setWaterAmbientSpawnLimit(int limit) {
|
||||
parent.setWaterAmbientSpawnLimit(limit);
|
||||
}
|
||||
|
||||
@ -903,7 +937,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(final @NotNull Location location, final @NotNull Sound sound, final float volume, final float pitch) {
|
||||
public void playSound(final @NotNull Location location, final @NotNull Sound sound,
|
||||
final float volume, final float pitch) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -913,7 +948,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(final @NotNull Location location, final @NotNull String sound, final float volume, final float pitch) {
|
||||
public void playSound(final @NotNull Location location, final @NotNull String sound,
|
||||
final float volume, final float pitch) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -923,7 +959,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
public void playSound(@NotNull Location location, @NotNull Sound sound,
|
||||
@NotNull SoundCategory category, float volume, float pitch) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -933,7 +970,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) {
|
||||
public void playSound(@NotNull Location location, @NotNull String sound,
|
||||
@NotNull SoundCategory category, float volume, float pitch) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -1042,13 +1080,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0, Predicate<Entity> arg1) {
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0,
|
||||
Predicate<Entity> arg1) {
|
||||
return parent.getNearbyEntities(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1, double arg2, double arg3,
|
||||
Predicate<Entity> arg4) {
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1,
|
||||
double arg2, double arg3, Predicate<Entity> arg4) {
|
||||
return parent.getNearbyEntities(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@ -1058,7 +1097,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location locateNearestStructure(@NotNull Location arg0, @NotNull StructureType arg1, int arg2, boolean arg3) {
|
||||
public Location locateNearestStructure(@NotNull Location arg0, @NotNull StructureType arg1,
|
||||
int arg2, boolean arg3) {
|
||||
return parent.locateNearestStructure(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@ -1083,46 +1123,51 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(
|
||||
@NotNull Location arg0, @NotNull Vector arg1, double arg2, @NotNull FluidCollisionMode arg3, boolean arg4,
|
||||
double arg5, Predicate<Entity> arg6) {
|
||||
public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2,
|
||||
@NotNull FluidCollisionMode arg3, boolean arg4, double arg5, Predicate<Entity> arg6) {
|
||||
return parent.rayTrace(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceBlocks(@NotNull Location arg0, @NotNull Vector arg1, double arg2) {
|
||||
public RayTraceResult rayTraceBlocks(@NotNull Location arg0, @NotNull Vector arg1,
|
||||
double arg2) {
|
||||
return parent.rayTraceBlocks(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) {
|
||||
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction,
|
||||
double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) {
|
||||
return parent.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double arg2, @NotNull FluidCollisionMode fluidCollisionMode,
|
||||
boolean ignorePassableBlocks) {
|
||||
return parent.rayTraceBlocks(start, direction, arg2, fluidCollisionMode, ignorePassableBlocks);
|
||||
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction,
|
||||
double arg2, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) {
|
||||
return parent
|
||||
.rayTraceBlocks(start, direction, arg2, fluidCollisionMode, ignorePassableBlocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance) {
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction,
|
||||
double maxDistance) {
|
||||
return parent.rayTraceEntities(start, direction, maxDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, double arg3) {
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1,
|
||||
double arg2, double arg3) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, Predicate<Entity> arg3) {
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1,
|
||||
double arg2, Predicate<Entity> arg3) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, double arg3,
|
||||
Predicate<Entity> arg4) {
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1,
|
||||
double arg2, double arg3, Predicate<Entity> arg4) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@ -1170,7 +1215,9 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.@NotNull HeightmapType heightmap) throws UnsupportedOperationException {
|
||||
public int getHighestBlockYAt(int x, int z,
|
||||
com.destroystokyo.paper.@NotNull HeightmapType heightmap)
|
||||
throws UnsupportedOperationException {
|
||||
return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap));
|
||||
}
|
||||
|
||||
@ -1205,7 +1252,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent) {
|
||||
public @NotNull CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen,
|
||||
boolean urgent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1241,8 +1289,10 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(Entity source, @NotNull Location loc, float power, boolean setFire, boolean breakBlocks) {
|
||||
return TaskManager.IMP.sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks));
|
||||
public boolean createExplosion(Entity source, @NotNull Location loc, float power,
|
||||
boolean setFire, boolean breakBlocks) {
|
||||
return TaskManager.IMP
|
||||
.sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1259,13 +1309,17 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(
|
||||
@NotNull Particle particle, List<Player> receivers, @NotNull Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
|
||||
parent.spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, extra, data);
|
||||
public <T> void spawnParticle(@NotNull Particle particle, List<Player> receivers,
|
||||
@NotNull Player source, double x, double y, double z, int count, double offsetX,
|
||||
double offsetY, double offsetZ, double extra, T data) {
|
||||
parent.spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ,
|
||||
extra, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, List<Player> list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, List<Player> list, Player player,
|
||||
double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t,
|
||||
boolean b) {
|
||||
parent.spawnParticle(particle, list, player, v, v1, v2, i, v3, v4, v5, v6, t, b);
|
||||
}
|
||||
|
||||
@ -1273,7 +1327,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count,
|
||||
double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data,
|
||||
boolean force) {
|
||||
parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ, extra, data, force);
|
||||
parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ, extra, data,
|
||||
force);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,8 @@ public class CommandInfo {
|
||||
|
||||
private final String[] aliases;
|
||||
private final Object registeredWith;
|
||||
private final String usage, desc;
|
||||
private final String usage;
|
||||
private final String desc;
|
||||
private final String[] permissions;
|
||||
|
||||
public CommandInfo(String usage, String desc, String[] aliases, Object registeredWith) {
|
||||
|
@ -37,7 +37,8 @@ import java.util.Set;
|
||||
public class CommandRegistration {
|
||||
|
||||
static {
|
||||
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory());
|
||||
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class,
|
||||
new DynamicPluginCommandHelpTopic.Factory());
|
||||
}
|
||||
|
||||
protected final Plugin plugin;
|
||||
@ -55,7 +56,9 @@ public class CommandRegistration {
|
||||
}
|
||||
|
||||
public Plugin getCommandOwner(String label) {
|
||||
if (serverCommandMap == null) return null;
|
||||
if (serverCommandMap == null) {
|
||||
return null;
|
||||
}
|
||||
Command command = serverCommandMap.getCommand(label);
|
||||
if (command instanceof PluginIdentifiableCommand) {
|
||||
return ((PluginIdentifiableCommand) command).getPlugin();
|
||||
@ -87,8 +90,8 @@ public class CommandRegistration {
|
||||
|
||||
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
|
||||
if (commandMap == null) {
|
||||
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
|
||||
": Could not retrieve server CommandMap, using fallback instead!");
|
||||
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName()
|
||||
+ ": Could not retrieve server CommandMap, using fallback instead!");
|
||||
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin);
|
||||
} else {
|
||||
|
@ -22,8 +22,6 @@ package com.sk89q.bukkit.util;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -31,8 +29,11 @@ import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin
|
||||
* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DynamicPluginCommand extends org.bukkit.command.Command implements PluginIdentifiableCommand {
|
||||
@ -105,7 +106,7 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable ignore) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
} else if (PermissionsResolverManager.isInitialized() && sender instanceof OfflinePlayer) {
|
||||
for (String permission : permissions) {
|
||||
|
@ -31,10 +31,10 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
private YAMLProcessor config;
|
||||
private Map<String, Set<String>> userPermissionsCache;
|
||||
private Set<String> defaultPermissionsCache;
|
||||
private Map<String, Set<String>> userGroups;
|
||||
private final YAMLProcessor config;
|
||||
private final Map<String, Set<String>> userPermissionsCache = new HashMap<>();
|
||||
private final Set<String> defaultPermissionsCache = new HashSet<>();
|
||||
private final Map<String, Set<String>> userGroups = new HashMap<>();
|
||||
|
||||
public ConfigurationPermissionsResolver(YAMLProcessor config) {
|
||||
this.config = config;
|
||||
@ -42,9 +42,10 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
public static YAMLNode generateDefaultPerms(YAMLNode section) {
|
||||
section.setProperty("groups.default.permissions", new String[] {
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"});
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"
|
||||
});
|
||||
section.setProperty("groups.admins.permissions", new String[] { "*" });
|
||||
section.setProperty("users.sk89q.permissions", new String[] { "worldedit" });
|
||||
section.setProperty("users.sk89q.groups", new String[] { "admins" });
|
||||
@ -53,9 +54,9 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
userGroups = new HashMap<>();
|
||||
userPermissionsCache = new HashMap<>();
|
||||
defaultPermissionsCache = new HashSet<>();
|
||||
userGroups.clear();
|
||||
userPermissionsCache.clear();
|
||||
defaultPermissionsCache.clear();
|
||||
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||
|
||||
|
@ -78,6 +78,8 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
while (dotPos > -1) {
|
||||
@ -86,6 +88,8 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dotPos = permission.lastIndexOf(".", dotPos - 1);
|
||||
}
|
||||
@ -126,19 +130,23 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public Permissible getPermissible(OfflinePlayer offline) {
|
||||
if (offline == null) return null;
|
||||
if (offline == null) {
|
||||
return null;
|
||||
}
|
||||
Permissible perm = null;
|
||||
if (offline instanceof Permissible) {
|
||||
perm = (Permissible) offline;
|
||||
} else {
|
||||
Player player = offline.getPlayer();
|
||||
if (player != null) perm = player;
|
||||
if (player != null) {
|
||||
perm = player;
|
||||
}
|
||||
}
|
||||
return perm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the permission from dinnerperms
|
||||
* Checks the permission from dinnerperms.
|
||||
*
|
||||
* @param perms Permissible to check for
|
||||
* @param permission The permission to check
|
||||
|
@ -35,8 +35,8 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NijiPermissionsResolver.class);
|
||||
|
||||
private Server server;
|
||||
private Permissions api;
|
||||
private final Server server;
|
||||
private final Permissions api;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
@ -76,7 +76,9 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
try {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) return false;
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return api.getHandler().has(player, permission);
|
||||
} catch (Throwable t) {
|
||||
@ -107,7 +109,9 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
public boolean inGroup(String name, String group) {
|
||||
try {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) return false;
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return api.getHandler().inGroup(player.getWorld().getName(), name, group);
|
||||
} catch (Throwable t) {
|
||||
@ -124,13 +128,17 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
public String[] getGroups(String name) {
|
||||
try {
|
||||
Player player = server.getPlayerExact(name);
|
||||
if (player == null) return new String[0];
|
||||
if (player == null) {
|
||||
return new String[0];
|
||||
}
|
||||
String[] groups = null;
|
||||
try {
|
||||
groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName());
|
||||
} catch (Throwable t) {
|
||||
String group = api.Security.getGroup(player.getWorld().getName(), player.getName());
|
||||
if (group != null) groups = new String[] { group };
|
||||
if (group != null) {
|
||||
groups = new String[] { group };
|
||||
}
|
||||
}
|
||||
if (groups == null) {
|
||||
return new String[0];
|
||||
|
@ -40,24 +40,24 @@ import java.util.List;
|
||||
|
||||
public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
private static final String CONFIG_HEADER = "#\r\n" +
|
||||
"# WEPIF Configuration File\r\n" +
|
||||
"#\r\n" +
|
||||
"# This file handles permissions configuration for every plugin using WEPIF\r\n" +
|
||||
"#\r\n" +
|
||||
"# About editing this file:\r\n" +
|
||||
"# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n" +
|
||||
"# you use an editor like Notepad++ (recommended for Windows users), you\r\n" +
|
||||
"# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n" +
|
||||
"# be changed in Settings > Preferences > Language Menu.\r\n" +
|
||||
"# - Don't get rid of the indents. They are indented so some entries are\r\n" +
|
||||
"# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n" +
|
||||
"# category.\r\n" +
|
||||
"# - If you want to check the format of this file before putting it\r\n" +
|
||||
"# into WEPIF, paste it into http://yaml-online-parser.appspot.com/\r\n" +
|
||||
"# and see if it gives \"ERROR:\".\r\n" +
|
||||
"# - Lines starting with # are comments and so they are ignored.\r\n" +
|
||||
"\r\n";
|
||||
private static final String CONFIG_HEADER = "#\r\n"
|
||||
+ "# WEPIF Configuration File\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# This file handles permissions configuration for every plugin using WEPIF\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# About editing this file:\r\n"
|
||||
+ "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n"
|
||||
+ "# you use an editor like Notepad++ (recommended for Windows users), you\r\n"
|
||||
+ "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n"
|
||||
+ "# be changed in Settings > Preferences > Language Menu.\r\n"
|
||||
+ "# - Don't get rid of the indents. They are indented so some entries are\r\n"
|
||||
+ "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n"
|
||||
+ "# category.\r\n"
|
||||
+ "# - If you want to check the format of this file before putting it\r\n"
|
||||
+ "# into WEPIF, paste it into https://yaml-online-parser.appspot.com/\r\n"
|
||||
+ "# and see if it gives \"ERROR:\".\r\n"
|
||||
+ "# - Lines starting with # are comments and so they are ignored.\r\n"
|
||||
+ "\r\n";
|
||||
|
||||
private static PermissionsResolverManager instance;
|
||||
|
||||
@ -78,22 +78,22 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Server server;
|
||||
private final Server server;
|
||||
private PermissionsResolver permissionResolver;
|
||||
private YAMLProcessor config;
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
};
|
||||
|
||||
protected PermissionsResolverManager(Plugin plugin) {
|
||||
@ -225,7 +225,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
Class<?> next = null;
|
||||
try {
|
||||
next = Class.forName(getClass().getPackage().getName() + "." + nextName);
|
||||
} catch (ClassNotFoundException e) {}
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) {
|
||||
logger.warn("WEPIF: Invalid or unknown class found in enabled resolvers: "
|
||||
@ -239,12 +240,12 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
if (!stagedEnabled.contains(clazz.getSimpleName()) &&
|
||||
!disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
if (!stagedEnabled.contains(clazz.getSimpleName())
|
||||
&& !disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
disabledResolvers.add(clazz.getSimpleName());
|
||||
logger.info("New permissions resolver: "
|
||||
+ clazz.getSimpleName() + " detected. " +
|
||||
"Added to disabled resolvers list.");
|
||||
+ clazz.getSimpleName() + " detected. "
|
||||
+ "Added to disabled resolvers list.");
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class bPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
return new bPermissionsResolver(server);
|
||||
}
|
||||
|
||||
|
||||
private final Server server;
|
||||
|
||||
public bPermissionsResolver(Server server) {
|
||||
|
@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* YAMLConfiguration but with setting for no op permissions and plugin root data folder
|
||||
* YAMLConfiguration but with setting for no op permissions and plugin root data folder.
|
||||
*/
|
||||
public class BukkitConfiguration extends YAMLConfiguration {
|
||||
|
||||
@ -59,8 +59,8 @@ public class BukkitConfiguration extends YAMLConfiguration {
|
||||
File toDir = new File(getWorkingDirectory(), file);
|
||||
if (fromDir.exists() & !toDir.exists()) {
|
||||
if (fromDir.renameTo(toDir)) {
|
||||
plugin.getLogger().info("Migrated " + name + " folder '" + file +
|
||||
"' from server root to plugin data folder.");
|
||||
plugin.getLogger().info("Migrated " + name + " folder '" + file
|
||||
+ "' from server root to plugin data folder.");
|
||||
} else {
|
||||
plugin.getLogger().warning("Error while migrating " + name + " folder!");
|
||||
}
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -35,9 +32,10 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* An adapter to adapt a Bukkit entity into a WorldEdit one.
|
||||
*/
|
||||
|
@ -406,10 +406,11 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
||||
SingleThreadQueueExtent extent = new SingleThreadQueueExtent();
|
||||
extent.init(null, (x, z) -> new BukkitGetBlocks_1_14(freshWorld, x, z) {
|
||||
@Override
|
||||
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
||||
Chunk cached = nmsWorld.getChunkIfLoaded(X, Z);
|
||||
public Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) {
|
||||
Chunk cached = nmsWorld.getChunkIfLoaded(chunkX, chunkZ);
|
||||
if (cached != null) return cached;
|
||||
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(X, Z));
|
||||
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(
|
||||
chunkX, chunkZ));
|
||||
while (!future.isDone()) {
|
||||
// this feels so dirty
|
||||
freshWorld.getChunkProvider().runTasks();
|
||||
|
Reference in New Issue
Block a user