Class PacketBlockGroup

java.lang.Object
net.bitbylogic.packetblocks.group.PacketBlockGroup
All Implemented Interfaces:
PacketBlockHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>, DataHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>, MetadataHolder, ViewerHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>

public class PacketBlockGroup extends Object implements PacketBlockHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>
  • Constructor Details

    • PacketBlockGroup

      public PacketBlockGroup(@NonNull @NonNull Map<org.bukkit.Location,org.bukkit.block.data.BlockData> blockLocations)
    • PacketBlockGroup

      public PacketBlockGroup(@NonNull @NonNull Map<org.bukkit.Location,org.bukkit.block.data.BlockData> blockLocations, int breakSpeed)
  • Method Details

    • addLocations

      public void addLocations(@NonNull @NonNull Map<org.bukkit.Location,org.bukkit.block.data.BlockData> locations)
      Adds multiple block locations along with their corresponding block data to the internal data structure. Updates are sent to all viewers tracking the block group, and the necessary metadata is updated accordingly.

      NOTE: Do not call this yourself, use PacketBlockManager.addBlocksToGroup(PacketBlockGroup, Map)

      Parameters:
      locations - a map containing the Location of each block and its associated BlockData; must not be null
    • addLocation

      public void addLocation(@NonNull @NonNull org.bukkit.Location location, @NonNull @NonNull org.bukkit.block.data.BlockData blockData)
      Adds a specific block location along with its corresponding block data to the internal data structure. Updates are sent to all viewers tracking the block group, and necessary metadata is updated accordingly.

      NOTE: Do not call this yourself, use PacketBlockManager.addBlockToGroup(PacketBlockGroup, Location, BlockData)

      Parameters:
      location - the Location of the block to be added; must not be null
      blockData - the BlockData associated with the block at the given location; must not be null
    • removeLocations

      public void removeLocations(@NonNull @NonNull List<org.bukkit.Location> locations)
      Removes the specified list of locations from the internal data structure and notifies all viewers about the changes in those locations.

      NOTE: Do not call this yourself, use PacketBlockManager.removeBlocksFromGroup(PacketBlockGroup, List)

      Parameters:
      locations - A list of Location objects to be removed. Each location in the list will be processed to update the internal state and notify the viewers of changes.
    • removeLocation

      public void removeLocation(@NonNull @NonNull org.bukkit.Location location)
      Removes a specific block location from the group and optionally sends an update to the viewers.

      NOTE: Do not call this yourself, use PacketBlockManager.removeBlockFromGroup(PacketBlockGroup, Location)

      Parameters:
      location - the Location of the block to remove; must not be null
    • removeLocation

      protected void removeLocation(@NonNull @NonNull org.bukkit.Location location, boolean sendUpdate)
    • getBlockStates

      public List<org.bukkit.block.BlockState> getBlockStates(@NonNull @NonNull org.bukkit.entity.Player player)
    • getDataAt

      public Optional<org.bukkit.block.data.BlockData> getDataAt(@Nullable @Nullable org.bukkit.entity.Player player, @NonNull @NonNull org.bukkit.Location location)
    • sendUpdate

      public void sendUpdate(@NonNull @NonNull org.bukkit.entity.Player player)
      Sends a block update to the specified player at the current location.
      Specified by:
      sendUpdate in interface PacketBlockHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>
      Parameters:
      player - the player to whom the block update will be sent
    • existsIn

      public boolean existsIn(@NonNull @NonNull org.bukkit.World world)
      Specified by:
      existsIn in interface PacketBlockHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>
    • existsAt

      public boolean existsAt(@NonNull @NonNull org.bukkit.Location location)
      Specified by:
      existsAt in interface PacketBlockHolder<Map<net.bitbylogic.utils.location.WorldPosition,org.bukkit.block.data.BlockData>,GroupPacketBlockViewer>