API improvements

This commit is contained in:
MattBDev
2020-01-15 20:38:46 -05:00
parent da7c21d32a
commit 0cad7f229b
29 changed files with 38 additions and 96 deletions

View File

@ -3,7 +3,7 @@ package com.boydti.fawe.bukkit.adapter;
import com.sk89q.worldedit.world.block.BlockID;
import java.util.function.Function;
public class NMSAdapter<T> {
public class NMSAdapter {
public static int createPalette(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, int[] num_palette_buffer, char[] set) {
int air = 0;
int num_palette = 0;

View File

@ -102,7 +102,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
* @param notifyAndLight notify and light if set
* @return true if a block was likely changed
*/
boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight);
<B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight);
/**
* Notifies the simulation that the block at the given location has

View File

@ -231,7 +231,7 @@ public interface IBukkitAdapter {
* @param block The WorldEdit BlockStateHolder
* @return The Bukkit BlockData
*/
default BlockData adapt(BlockStateHolder block) {
default <B extends BlockStateHolder<B>> BlockData adapt(B block) {
return Bukkit.createBlockData(block.getAsString());
}

View File

@ -65,7 +65,7 @@ public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
return getParent().getBlock(location);
}
default boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
default <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
return getParent().setBlock(location, state, notifyAndLight);
}
@ -227,7 +227,7 @@ public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
}
@Override
default BlockData adapt(BlockStateHolder block) {
default <B extends BlockStateHolder<B>> BlockData adapt(B block) {
return getParent().adapt(block);
}

View File

@ -26,7 +26,7 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
* @return The Bukkit BlockData
*/
@Override
public BlockData adapt(BlockStateHolder block) {
public <B extends BlockStateHolder<B>> BlockData adapt(B block) {
try {
checkNotNull(block);
int typeId = block.getInternalBlockTypeId();

View File

@ -162,7 +162,6 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
return IRegistry.BLOCK.get(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
}
@SuppressWarnings("deprecation")
@Override
public BaseBlock getBlock(Location location) {
checkNotNull(location);
@ -188,7 +187,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
}
@Override
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
public <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
}
@ -314,7 +313,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
}
@Override
public BlockData adapt(BlockStateHolder state) {
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
try {
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
return material.getCraftBlockData();
@ -397,7 +396,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
public boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
WorldServer originalWorld = ((CraftWorld) world).getHandle();
ChunkProviderServer provider = originalWorld.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
if (provider == null) {
return false;
}

View File

@ -190,7 +190,7 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
}
@Override
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
public <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
}
@ -316,7 +316,7 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
}
@Override
public BlockData adapt(BlockStateHolder state) {
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial();
return material.getCraftBlockData();
}

View File

@ -186,11 +186,11 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
}
@Override
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
public <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
}
public boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update) {
public <B extends BlockStateHolder<B>> boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, B state, boolean update) {
CraftChunk craftChunk = (CraftChunk) chunk;
Chunk nmsChunk = craftChunk.getHandle();
World nmsWorld = nmsChunk.getWorld();
@ -312,7 +312,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
}
@Override
public BlockData adapt(BlockStateHolder state) {
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
BlockMaterial_1_15 material = (BlockMaterial_1_15) state.getMaterial();
return material.getCraftBlockData();
}