mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-14 23:38:34 +00:00
update adapter and platform manager
This commit is contained in:
@ -23,9 +23,12 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -39,8 +42,10 @@ import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -72,9 +77,6 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
*/
|
||||
BaseBlock getBlock(Location location);
|
||||
|
||||
boolean setBlock(Chunk chunk, int x, int y, int z, BlockStateHolder<?> state, boolean update);
|
||||
|
||||
boolean isChunkInUse(Chunk chunk);
|
||||
/**
|
||||
* Set the block at the given location.
|
||||
*
|
||||
@ -83,7 +85,11 @@ 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);
|
||||
default boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight) {
|
||||
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
||||
}
|
||||
|
||||
boolean setBlock(Chunk chunk, int x, int y, int z, BlockStateHolder<?> state, boolean update);
|
||||
|
||||
/**
|
||||
* Notifies the simulation that the block at the given location has
|
||||
@ -121,22 +127,6 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
*/
|
||||
Map<String, ? extends Property<?>> getProperties(BlockType blockType);
|
||||
|
||||
default BlockMaterial getMaterial(BlockType blockType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default BlockMaterial getMaterial(BlockState blockState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Tag toNative(T foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default T fromNative(Tag foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given NBT data to the player.
|
||||
*
|
||||
@ -154,7 +144,65 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
*/
|
||||
void sendFakeOP(Player player);
|
||||
|
||||
default @org.jetbrains.annotations.Nullable World createWorld(WorldCreator creator) {
|
||||
/**
|
||||
* Simulates a player using an item.
|
||||
*
|
||||
* @param world the world
|
||||
* @param position the location
|
||||
* @param item the item to be used
|
||||
* @param face the direction in which to "face" when using the item
|
||||
* @return whether the usage was successful
|
||||
*/
|
||||
default boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit ItemStack with NBT, if available.
|
||||
*
|
||||
* @param item the WorldEdit BaseItemStack to adapt
|
||||
* @return the Bukkit ItemStack
|
||||
*/
|
||||
ItemStack adapt(BaseItemStack item);
|
||||
|
||||
/**
|
||||
* Create a WorldEdit ItemStack with NBT, if available.
|
||||
*
|
||||
* @param itemStack the Bukkit ItemStack to adapt
|
||||
* @return the WorldEdit BaseItemStack
|
||||
*/
|
||||
BaseItemStack adapt(ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the internal ID for a given state, if possible.
|
||||
*
|
||||
* @param state The block state
|
||||
* @return the internal ID of the state
|
||||
*/
|
||||
default OptionalInt getInternalBlockStateId(BlockState state) {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
boolean isChunkInUse(Chunk chunk);
|
||||
|
||||
default BlockMaterial getMaterial(BlockType blockType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default BlockMaterial getMaterial(BlockState blockState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Tag toNative(T foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default T fromNative(Tag foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default @Nullable World createWorld(WorldCreator creator) {
|
||||
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user