Interface DataHolder<T,V extends PacketBlockViewer<T>>

All Known Subinterfaces:
PacketBlockHolder<T,V>
All Known Implementing Classes:
PacketBlock, PacketBlockGroup

public interface DataHolder<T,V extends PacketBlockViewer<T>>
  • Method Summary

    Modifier and Type
    Method
    Description
    default List<org.bukkit.util.BoundingBox>
     
    default int
     
    default int
    getBreakSpeed(@NonNull org.bukkit.entity.Player player)
    Calculates and retrieves the break speed for the given player.
    default T
     
    default T
    getData(@Nullable org.bukkit.entity.Player player)
     
    @NonNull DataHandler<T,V>
     
    default boolean
     
    default boolean
     
    default void
    Sends block updates to all the viewers currently tracking the block at the specified location.
    default void
    setAddViewerOnJoin(boolean addViewerOnJoin)
     
    default void
    setBlockDataAndUpdate(@NonNull org.bukkit.entity.Player player, T data)
    Sets the block data for the specified player and sends an update.
    default void
    setBreakSpeed(int breakSpeed)
     
    default void
    setData(@NonNull org.bukkit.entity.Player player, T data)
    Sets the data for a specific player.
    default void
    setData(T data)
     
    default void
    Sets the data for all viewers and updates them accordingly.
    default void
    setDataSupplier(@NonNull org.bukkit.entity.Player player, T data)
    Sets the data supplier for a specific player, allowing for dynamic control over block data.
    default void
    Sets the block data supplier for all viewers and updates the block data for each viewer based on the provided BlockData.
    default void
    setGlobalBreakAnimation(boolean globalBreakAnimation)
     
  • Method Details

    • getDataHandler

      @NonNull @NonNull DataHandler<T,V> getDataHandler()
    • setDataForAll

      default void setDataForAll(@NonNull T data)
      Sets the data for all viewers and updates them accordingly.
      Parameters:
      data - the block data to be set for all viewers
    • setDataSupplierForAll

      default void setDataSupplierForAll(@NonNull T data)
      Sets the block data supplier for all viewers and updates the block data for each viewer based on the provided BlockData.
      Parameters:
      data - the BlockData object to be supplied to all viewers
    • setData

      default void setData(@NonNull @NonNull org.bukkit.entity.Player player, @Nullable T data)
      Sets the data for a specific player.
      Parameters:
      player - the player for whom the block data is being set; must not be null
      data - the data to associate with the player; can be null to reset or remove the block data
    • setDataSupplier

      default void setDataSupplier(@NonNull @NonNull org.bukkit.entity.Player player, @NonNull T data)
      Sets the data supplier for a specific player, allowing for dynamic control over block data.
      Parameters:
      player - the player for whom the BlockData supplier is being set, must not be null
      data - the data object to be supplied, must not be null
    • setBlockDataAndUpdate

      default void setBlockDataAndUpdate(@NonNull @NonNull org.bukkit.entity.Player player, @Nullable T data)
      Sets the block data for the specified player and sends an update.
      Parameters:
      player - the player for whom the block data is being set, must not be null
      data - the block data to be set, can be null
    • getBreakSpeed

      default int getBreakSpeed(@NonNull @NonNull org.bukkit.entity.Player player)
      Calculates and retrieves the break speed for the given player.
      Parameters:
      player - the player whose break speed is being requested, must not be null
      Returns:
      the calculated break speed for the player; returns a default value if not available
    • sendUpdates

      default void sendUpdates()
      Sends block updates to all the viewers currently tracking the block at the specified location.

      This method iterates through all viewers stored in the `viewers` map and attempts to send a block update to each. If a viewer no longer exists or is offline, they are removed from the `viewers` map.

      The block state sent to each viewer is dependent on the `getBlockState(Player)` implementation, which determines the block's appearance based on the specific viewer.

    • getBoundingBoxes

      default List<org.bukkit.util.BoundingBox> getBoundingBoxes()
    • getData

      default T getData()
    • getData

      default T getData(@Nullable @Nullable org.bukkit.entity.Player player)
    • isAddViewerOnJoin

      default boolean isAddViewerOnJoin()
    • isGlobalBreakAnimation

      default boolean isGlobalBreakAnimation()
    • getBreakSpeed

      default int getBreakSpeed()
    • setBreakSpeed

      default void setBreakSpeed(int breakSpeed)
    • setAddViewerOnJoin

      default void setAddViewerOnJoin(boolean addViewerOnJoin)
    • setGlobalBreakAnimation

      default void setGlobalBreakAnimation(boolean globalBreakAnimation)
    • setData

      default void setData(T data)