More Kotlin

This commit is contained in:
MattBDev
2020-01-21 14:30:13 -05:00
parent 0cad7f229b
commit 88359f0215
82 changed files with 867 additions and 1343 deletions

View File

@ -382,7 +382,7 @@
// int z = location.getBlockZ();
//
// org.bukkit.block.Block bukkitBlock = location.getBlock();
// BaseBlock block = FaweCache.IMP.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
// BaseBlock block = FaweCache.INSTANCE.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
//
// // Read the NBT data
// Object nmsWorld = getHandleWorld.invoke(craftWorld);

View File

@ -208,10 +208,10 @@ public final class BukkitAdapter_1_13 extends NMSAdapter {
if (set == null) {
return newChunkSection(layer, light);
}
final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get();
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
try {
int[] num_palette_buffer = new int[1];
int air;

View File

@ -493,9 +493,9 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {
return FaweCache.IMP.EMPTY_CHAR_4096;
return FaweCache.INSTANCE.getEMPTY_CHAR_4096();
}
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) {
data = new char[4096];
}
DelegateLock lock = BukkitAdapter_1_13.applyLock(section);
@ -522,8 +522,8 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
} else {
num_palette = 0;
int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get();
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
try {
for (int i = 0; i < 4096; i++) {
char paletteVal = data[i];
@ -549,7 +549,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
return data;
}
char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
try {
if (num_palette != 1) {
for (int i = 0; i < num_palette; i++) {

View File

@ -201,10 +201,10 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
if (set == null) {
return newChunkSection(layer);
}
final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get();
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
try {
int[] num_palette_buffer = new int[1];
int air;

View File

@ -490,9 +490,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {
return FaweCache.IMP.EMPTY_CHAR_4096;
return FaweCache.INSTANCE.getEMPTY_CHAR_4096();
}
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) {
data = new char[4096];
}
DelegateLock lock = BukkitAdapter_1_14.applyLock(section);
@ -519,8 +519,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
} else {
num_palette = 0;
int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get();
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
try {
for (int i = 0; i < 4096; i++) {
char paletteVal = data[i];
@ -546,7 +546,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
return data;
}
char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
try {
if (num_palette != 1) {
for (int i = 0; i < num_palette; i++) {

View File

@ -179,10 +179,10 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
if (set == null) {
return newChunkSection(layer);
}
final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get();
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
try {
int[] num_palette_buffer = new int[1];
int air;

View File

@ -96,7 +96,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
BiomeStorage index = getChunk().getBiomeIndex();
BiomeBase base = null;
if (y == -1) {
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
for (y = 0; y < FaweCache.WORLD_HEIGHT; y++) {
base = index.getBiome(x, y, z);
if (base != null) break;
}
@ -324,7 +324,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
if (biome != null) {
final Biome craftBiome = BukkitAdapter.adapt(biome);
BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome);
for (int y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
for (int y = 0; y < FaweCache.WORLD_HEIGHT; y++) {
currentBiomes.setBiome(x, y, z, nmsBiome);
}
}
@ -502,9 +502,9 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {
return FaweCache.IMP.EMPTY_CHAR_4096;
return FaweCache.INSTANCE.getEMPTY_CHAR_4096();
}
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) {
data = new char[4096];
}
DelegateLock lock = BukkitAdapter_1_15.applyLock(section);
@ -531,8 +531,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
} else {
num_palette = 0;
int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get();
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
try {
for (int i = 0; i < 4096; i++) {
char paletteVal = data[i];
@ -558,7 +558,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
return data;
}
char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
try {
if (num_palette != 1) {
for (int i = 0; i < num_palette; i++) {

View File

@ -93,7 +93,7 @@ public class CFIPacketListener implements Listener {
case VOID_AIR:
break;
default: {
BlockStateHolder block = BukkitAdapter.asBlockState(hand);
BlockState block = BukkitAdapter.asBlockState(hand);
if (block != null) {
gen.setBlock(pt, block);
return;
@ -123,7 +123,7 @@ 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.INSTANCE.getCHUNK_FLAG().get().get()) return;
VirtualWorld gen = getGenerator(event);
if (gen != null) {
BlockVector3 origin = gen.getOrigin().toBlockPoint();

View File

@ -312,9 +312,10 @@ public class AsyncBlock implements Block {
return this.getWorld().getHumidity(this.getX(), this.getZ());
}
@NotNull
@Override
public PistonMoveReaction getPistonMoveReaction() {
return null;
return PistonMoveReaction.IGNORE;
}
@Deprecated
@ -332,6 +333,10 @@ public class AsyncBlock implements Block {
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
}
public boolean breakNaturally(@NotNull ItemStack tool, boolean value) {
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
}
@NotNull @Override
public Collection<ItemStack> getDrops() {
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());

View File

@ -1249,12 +1249,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
@Override
public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
return TaskManager.IMP.sync(new Supplier<Integer>() {
@Override
public Integer get() {
return parent.getHighestBlockYAt(x, z, heightmap);
}
});
return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap));
}
@Override

View File

@ -54,7 +54,7 @@ public final class AsyncDataContainer implements PersistentDataContainer {
Validate.notNull(key, "The provided key for the custom value was null");
Validate.notNull(type, "The provided type for the custom value was null");
Validate.notNull(value, "The provided value for the custom value was null");
get().put(key.toString(), FaweCache.IMP.asTag(type.toPrimitive(value, null)));
get().put(key.toString(), FaweCache.INSTANCE.asTag(type.toPrimitive(value, null)));
}
public <T, Z> boolean has(NamespacedKey key, PersistentDataType<T, Z> type) {

View File

@ -347,10 +347,10 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
packet.setNativePacket(nmsPacket);
}
try {
FaweCache.IMP.CHUNK_FLAG.get().set(true);
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true);
current.playerConnection.sendPacket(nmsPacket);
} finally {
FaweCache.IMP.CHUNK_FLAG.get().set(false);
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false);
}
}
}

View File

@ -347,10 +347,10 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
packet.setNativePacket(nmsPacket);
}
try {
FaweCache.IMP.CHUNK_FLAG.get().set(true);
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true);
entityPlayer.playerConnection.sendPacket(nmsPacket);
} finally {
FaweCache.IMP.CHUNK_FLAG.get().set(false);
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false);
}
}
});

View File

@ -25,6 +25,8 @@ import com.bekvon.bukkit.residence.commands.server;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
import com.boydti.fawe.bukkit.adapter.mc1_14.BlockMaterial_1_14;
@ -343,10 +345,10 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
packet.setNativePacket(nmsPacket);
}
try {
FaweCache.IMP.CHUNK_FLAG.get().set(true);
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true);
entityPlayer.playerConnection.sendPacket(nmsPacket);
} finally {
FaweCache.IMP.CHUNK_FLAG.get().set(false);
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false);
}
}
});
@ -431,7 +433,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
// We need to also pull one more chunk in every direction
Fawe.get().getQueueHandler().startSet(true);
try {
SingleThreadQueueExtent extent = new SingleThreadQueueExtent();
IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15(freshWorld, x, z) {
@Override
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {