Package net.bitbylogic.packetblocks.data
Class DataHandler<T,V extends PacketBlockViewer<T>>
java.lang.Object
net.bitbylogic.packetblocks.data.DataHandler<T,V>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDataHandler(ViewerHolder<T, V> viewerHandler, Consumer<org.bukkit.entity.Player> updateConsumer, Function<T, List<org.bukkit.util.BoundingBox>> boundingBoxProvider, T data, int breakSpeed) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.bukkit.util.BoundingBox> protected intprotected intgetBreakSpeed(@NonNull org.bukkit.entity.Player player) Calculates and retrieves the break speed for the given player.protected TgetData()protected TgetData(@Nullable org.bukkit.entity.Player player) protected booleanprotected booleanprotected voidSends block updates to all the viewers currently tracking the block at the specified location.protected voidsetAddViewerOnJoin(boolean addViewerOnJoin) protected voidsetBlockDataAndUpdate(@NonNull org.bukkit.entity.Player player, T data) Sets the block data for the specified player and sends an update.protected voidsetBreakSpeed(int breakSpeed) protected voidSets the data for a specific player.protected voidprotected voidsetDataForAll(T data) Sets the data for all viewers and updates them accordingly.protected voidsetDataSupplier(@NonNull org.bukkit.entity.Player player, T data) Sets the data supplier for a specific player, allowing for dynamic control over block data.protected voidsetDataSupplierForAll(T data) Sets the block data supplier for all viewers and updates the block data for each viewer based on the provided BlockData.protected voidsetGlobalBreakAnimation(boolean globalBreakAnimation)
-
Field Details
-
data
-
-
Constructor Details
-
DataHandler
-
-
Method Details
-
setDataForAll
Sets the data for all viewers and updates them accordingly.- Parameters:
data- the block data to be set for all viewers
-
setDataSupplierForAll
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
Sets the data for a specific player.- Parameters:
player- the player for whom the block data is being set; must not be nulldata- the data to associate with the player; can be null to reset or remove the block data
-
setDataSupplier
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 nulldata- the data object to be supplied, must not be null
-
setBlockDataAndUpdate
protected 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 nulldata- the block data to be set, can be null
-
getBreakSpeed
protected 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
protected 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
-
getData
-
getData
-
getBreakSpeed
protected int getBreakSpeed() -
isAddViewerOnJoin
protected boolean isAddViewerOnJoin() -
isGlobalBreakAnimation
protected boolean isGlobalBreakAnimation() -
setBreakSpeed
protected void setBreakSpeed(int breakSpeed) -
setAddViewerOnJoin
protected void setAddViewerOnJoin(boolean addViewerOnJoin) -
setGlobalBreakAnimation
protected void setGlobalBreakAnimation(boolean globalBreakAnimation) -
setData
-