Package net.minestom.server
Interface Viewable
- All Known Subinterfaces:
Scoreboard
- All Known Implementing Classes:
AbstractInventory
,AdvancementTab
,AnvilInventory
,BeaconInventory
,BelowNameTag
,BrewingStandInventory
,Chunk
,DynamicChunk
,EnchantmentTableInventory
,Entity
,EntityCreature
,EntityProjectile
,ExperienceOrb
,FurnaceInventory
,Inventory
,ItemEntity
,LightingChunk
,LivingEntity
,Player
,PlayerInventory
,Sidebar
,TabList
,VillagerInventory
public interface Viewable
Represents something which can be displayed or hidden to players.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a viewer.Gets all the viewers of this viewable element.default @NotNull Audience
Gets the result ofgetViewers()
as an Adventure Audience.default boolean
Gets if a player is seeing this viewable object.boolean
removeViewer
(@NotNull Player player) Removes a viewer.default void
sendPacketsToViewers
(@NotNull Collection<SendablePacket> packets) default void
sendPacketsToViewers
(@NotNull SendablePacket... packets) default void
sendPacketToViewers
(@NotNull SendablePacket packet) Sends a packet to all viewers.default void
sendPacketToViewersAndSelf
(@NotNull SendablePacket packet) Sends a packet to all viewers and the viewable element if it is a player.
-
Method Details
-
addViewer
Adds a viewer.- Parameters:
player
- the viewer to add- Returns:
- true if the player has been added, false otherwise (could be because he is already a viewer)
-
removeViewer
Removes a viewer.- Parameters:
player
- the viewer to remove- Returns:
- true if the player has been removed, false otherwise (could be because he was not a viewer)
-
getViewers
Gets all the viewers of this viewable element.- Returns:
- A Set containing all the element's viewers
-
isViewer
Gets if a player is seeing this viewable object.- Parameters:
player
- the player to check- Returns:
- true if
player
is a viewer, false otherwise
-
sendPacketToViewers
Sends a packet to all viewers.It is better than looping through the viewers to send a packet since it is here only serialized once.
- Parameters:
packet
- the packet to send to all viewers
-
sendPacketsToViewers
-
sendPacketsToViewers
-
sendPacketToViewersAndSelf
Sends a packet to all viewers and the viewable element if it is a player.If 'this' isn't a player, then only
sendPacketToViewers(SendablePacket)
is called.- Parameters:
packet
- the packet to send
-
getViewersAsAudience
Gets the result ofgetViewers()
as an Adventure Audience.- Returns:
- the audience
-
getViewersAsAudiences
- Returns:
- the audiences
-