Fix AsyncBlock

This commit is contained in:
dordsor21 2020-12-31 15:22:29 +00:00
parent df48b7e81d
commit 935130aa0e
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -26,8 +26,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.util.BoundingBox; import org.bukkit.util.BoundingBox;
import org.bukkit.util.RayTraceResult; import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -70,32 +70,32 @@ public class AsyncBlock implements Block {
return world.getBlock(x, y, z).getBlockType().getInternalId(); return world.getBlock(x, y, z).getBlockType().getInternalId();
} }
@NotNull @Nonnull
@Override @Override
public AsyncBlock getRelative(int modX, int modY, int modZ) { public AsyncBlock getRelative(int modX, int modY, int modZ) {
return new AsyncBlock(world, x + modX, y + modY, z + modZ); return new AsyncBlock(world, x + modX, y + modY, z + modZ);
} }
@NotNull @Nonnull
@Override @Override
public AsyncBlock getRelative(BlockFace face) { public AsyncBlock getRelative(BlockFace face) {
return this.getRelative(face.getModX(), face.getModY(), face.getModZ()); return this.getRelative(face.getModX(), face.getModY(), face.getModZ());
} }
@NotNull @Nonnull
@Override @Override
public AsyncBlock getRelative(BlockFace face, int distance) { public AsyncBlock getRelative(BlockFace face, int distance) {
return this.getRelative(face.getModX() * distance, face.getModY() * distance, return this.getRelative(face.getModX() * distance, face.getModY() * distance,
face.getModZ() * distance); face.getModZ() * distance);
} }
@NotNull @Nonnull
@Override @Override
public Material getType() { public Material getType() {
return getBlockData().getMaterial(); return getBlockData().getMaterial();
} }
@NotNull @Nonnull
@Override @Override
public BlockData getBlockData() { public BlockData getBlockData() {
return BukkitAdapter.adapt(world.getBlock(x, y, z)); return BukkitAdapter.adapt(world.getBlock(x, y, z));
@ -141,7 +141,7 @@ public class AsyncBlock implements Block {
return (byte) 15; return (byte) 15;
} }
@NotNull @Nonnull
@Override @Override
public AsyncWorld getWorld() { public AsyncWorld getWorld() {
return world; return world;
@ -162,7 +162,7 @@ public class AsyncBlock implements Block {
return z; return z;
} }
@NotNull @Nonnull
@Override @Override
public Location getLocation() { public Location getLocation() {
return new Location(world, x, y, z); return new Location(world, x, y, z);
@ -179,14 +179,14 @@ public class AsyncBlock implements Block {
return loc; return loc;
} }
@NotNull @Nonnull
@Override @Override
public AsyncChunk getChunk() { public AsyncChunk getChunk() {
return world.getChunkAt(x >> 4, z >> 4); return world.getChunkAt(x >> 4, z >> 4);
} }
@Override @Override
public void setBlockData(@NotNull BlockData blockData) { public void setBlockData(@Nonnull BlockData blockData) {
try { try {
world.setBlock(x, y, z, BukkitAdapter.adapt(blockData)); world.setBlock(x, y, z, BukkitAdapter.adapt(blockData));
} catch (WorldEditException e) { } catch (WorldEditException e) {
@ -195,12 +195,12 @@ public class AsyncBlock implements Block {
} }
@Override @Override
public void setBlockData(@NotNull BlockData blockData, boolean b) { public void setBlockData(@Nonnull BlockData blockData, boolean b) {
setBlockData(blockData); setBlockData(blockData);
} }
@Override @Override
public void setType(@NotNull Material type) { public void setType(@Nonnull Material type) {
try { try {
world.setBlock(x, y, z, BukkitAdapter.asBlockType(type).getDefaultState()); world.setBlock(x, y, z, BukkitAdapter.asBlockType(type).getDefaultState());
} catch (WorldEditException e) { } catch (WorldEditException e) {
@ -209,12 +209,12 @@ public class AsyncBlock implements Block {
} }
@Override @Override
public void setType(@NotNull Material type, boolean applyPhysics) { public void setType(@Nonnull Material type, boolean applyPhysics) {
setType(type); setType(type);
} }
@Override @Override
public BlockFace getFace(@NotNull Block block) { public BlockFace getFace(@Nonnull Block block) {
BlockFace[] directions = BlockFace.values(); BlockFace[] directions = BlockFace.values();
for (BlockFace face : directions) { for (BlockFace face : directions) {
if (this.getX() + face.getModX() == block.getX() if (this.getX() + face.getModX() == block.getX()
@ -226,7 +226,7 @@ public class AsyncBlock implements Block {
return null; return null;
} }
@NotNull @Nonnull
@Override @Override
public AsyncBlockState getState() { public AsyncBlockState getState() {
BaseBlock state = world.getFullBlock(x, y, z); BaseBlock state = world.getFullBlock(x, y, z);
@ -250,19 +250,19 @@ public class AsyncBlock implements Block {
} }
@Override @Override
@NotNull @Nonnull
public AsyncBlockState getState(boolean useSnapshot) { public AsyncBlockState getState(boolean useSnapshot) {
return getState(); return getState();
} }
@NotNull @Nonnull
@Override @Override
public Biome getBiome() { public Biome getBiome() {
return world.getAdapter().adapt(world.getBiomeType(x, y, z)); return world.getAdapter().adapt(world.getBiomeType(x, y, z));
} }
@Override @Override
public void setBiome(@NotNull Biome bio) { public void setBiome(@Nonnull Biome bio) {
BiomeType biome = world.getAdapter().adapt(bio); BiomeType biome = world.getAdapter().adapt(bio);
world.setBiome(x, 0, z, biome); world.setBiome(x, 0, z, biome);
} }
@ -278,17 +278,17 @@ public class AsyncBlock implements Block {
} }
@Override @Override
public boolean isBlockFacePowered(@NotNull BlockFace face) { public boolean isBlockFacePowered(@Nonnull BlockFace face) {
return false; return false;
} }
@Override @Override
public boolean isBlockFaceIndirectlyPowered(@NotNull BlockFace face) { public boolean isBlockFaceIndirectlyPowered(@Nonnull BlockFace face) {
return false; return false;
} }
@Override @Override
public int getBlockPower(@NotNull BlockFace face) { public int getBlockPower(@Nonnull BlockFace face) {
return 0; return 0;
} }
@ -324,7 +324,7 @@ public class AsyncBlock implements Block {
return this.getWorld().getHumidity(this.getX(), this.getZ()); return this.getWorld().getHumidity(this.getX(), this.getZ());
} }
@NotNull @Nonnull
@Override @Override
public PistonMoveReaction getPistonMoveReaction() { public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.IGNORE; return PistonMoveReaction.IGNORE;
@ -341,23 +341,23 @@ public class AsyncBlock implements Block {
} }
@Override @Override
public boolean breakNaturally(@NotNull ItemStack tool) { public boolean breakNaturally(@Nonnull ItemStack tool) {
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool)); return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
} }
public boolean breakNaturally(@NotNull ItemStack tool, boolean value) { public boolean breakNaturally(@Nonnull ItemStack tool, boolean value) {
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool)); return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
} }
@NotNull @Nonnull
@Override @Override
public Collection<ItemStack> getDrops() { public Collection<ItemStack> getDrops() {
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops()); return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());
} }
@NotNull @Nonnull
@Override @Override
public Collection<ItemStack> getDrops(@NotNull ItemStack tool) { public Collection<ItemStack> getDrops(@Nonnull ItemStack tool) {
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool)); return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool));
} }
@ -366,23 +366,23 @@ public class AsyncBlock implements Block {
} }
@Override @Override
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) { public void setMetadata(@Nonnull String metadataKey, @Nonnull MetadataValue newMetadataValue) {
this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue); this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue);
} }
@NotNull @Nonnull
@Override @Override
public List<MetadataValue> getMetadata(@NotNull String metadataKey) { public List<MetadataValue> getMetadata(@Nonnull String metadataKey) {
return this.getUnsafeBlock().getMetadata(metadataKey); return this.getUnsafeBlock().getMetadata(metadataKey);
} }
@Override @Override
public boolean hasMetadata(@NotNull String metadataKey) { public boolean hasMetadata(@Nonnull String metadataKey) {
return this.getUnsafeBlock().hasMetadata(metadataKey); return this.getUnsafeBlock().hasMetadata(metadataKey);
} }
@Override @Override
public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) { public void removeMetadata(@Nonnull String metadataKey, @Nonnull Plugin owningPlugin) {
this.getUnsafeBlock().removeMetadata(metadataKey, owningPlugin); this.getUnsafeBlock().removeMetadata(metadataKey, owningPlugin);
} }
@ -392,12 +392,12 @@ public class AsyncBlock implements Block {
} }
@Override @Override
public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, public RayTraceResult rayTrace(@Nonnull Location arg0, @Nonnull Vector arg1, double arg2,
@NotNull FluidCollisionMode arg3) { @Nonnull FluidCollisionMode arg3) {
return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3); return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3);
} }
public boolean applyBoneMeal(@NotNull BlockFace face) { public boolean applyBoneMeal(@Nonnull BlockFace face) {
throw new UnsupportedOperationException("FAWE does not support this yet"); throw new UnsupportedOperationException("FAWE does not support this yet");
} }
@ -405,22 +405,28 @@ public class AsyncBlock implements Block {
throw new UnsupportedOperationException("FAWE does not support this yet"); throw new UnsupportedOperationException("FAWE does not support this yet");
} }
@NotNull @Nonnull
@Override @Override
public float getDestroySpeed(@NotNull ItemStack itemStack) { public float getDestroySpeed(@Nonnull ItemStack itemStack) {
throw new UnsupportedOperationException("FAWE does not support this yet"); throw new UnsupportedOperationException("FAWE does not support this yet");
} }
@NotNull @Nonnull
@Override @Override
public BoundingBox getBoundingBox() { public BoundingBox getBoundingBox() {
return this.getUnsafeBlock().getBoundingBox(); return this.getUnsafeBlock().getBoundingBox();
} }
@Override @Override
@NotNull @Nonnull
public BlockSoundGroup getSoundGroup() { public BlockSoundGroup getSoundGroup() {
return TaskManager.IMP.sync(() -> getUnsafeBlock().getSoundGroup()); return TaskManager.IMP.sync(() -> getUnsafeBlock().getSoundGroup());
} }
@Override
@Nonnull
public boolean isSolid() {
return this.getType().isSolid();
}
} }