Package net.minestom.server
Interface Viewable
- All Known Subinterfaces:
Scoreboard
- All Known Implementing Classes:
AdvancementTab
,AnvilInventory
,BeaconInventory
,BelowNameTag
,BossBar
,BrewingStandInventory
,Chunk
,DynamicChunk
,EnchantmentTableInventory
,Entity
,EntityAreaEffectCloud
,EntityArmorStand
,EntityBat
,EntityBee
,EntityBlaze
,EntityBoat
,EntityCat
,EntityCaveSpider
,EntityChicken
,EntityCow
,EntityCreature
,EntityCreeper
,EntityDolphin
,EntityEndermite
,EntityEyeOfEnder
,EntityFox
,EntityGhast
,EntityGiant
,EntityGuardian
,EntityIronGolem
,EntityItemFrame
,EntityMooshroom
,EntityOcelot
,EntityPanda
,EntityPhantom
,EntityPig
,EntityPolarBear
,EntityPotion
,EntityRabbit
,EntitySilverfish
,EntitySlime
,EntitySnowman
,EntitySpider
,EntityWitch
,EntityZombie
,EntityZombifiedPiglin
,ExperienceOrb
,FakePlayer
,FurnaceInventory
,Hologram
,Inventory
,ItemEntity
,LivingEntity
,ObjectEntity
,Player
,Sidebar
,TabList
,VillagerInventory
public interface Viewable
Represents something which can be displayed or hidden to players.
-
Method Summary
Modifier and Type Method Description boolean
addViewer(Player player)
Adds a viewer.java.util.Set<Player>
getViewers()
Gets all the viewers of this viewable element.default boolean
isViewer(Player player)
Gets if a player is seeing this viewable object.boolean
removeViewer(Player player)
Removes a viewer.default void
sendPacketsToViewers(ServerPacket... packets)
Sends multiple packets to all viewers.default void
sendPacketToViewers(ServerPacket packet)
Sends a packet to all viewers.default void
sendPacketToViewersAndSelf(ServerPacket 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
Sends multiple packets to all viewers.It is better than looping through the viewers to send a packet since it is here only serialized once.
- Parameters:
packets
- the packets to send
-
sendPacketToViewersAndSelf
Sends a packet to all viewers and the viewable element if it is a player.If 'this' isn't a player, then {only @link #sendPacketToViewers(ServerPacket)} is called.
- Parameters:
packet
- the packet to send
-