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 TypeMethodDescriptionbooleanAdds a viewer.Gets all the viewers of this viewable element.default AudienceGets the result ofgetViewers()as an Adventure Audience.default booleanGets if a player is seeing this viewable object.booleanremoveViewer(Player player) Removes a viewer.default voidsendPacketsToViewers(Collection<SendablePacket> packets) default voidsendPacketsToViewers(SendablePacket... packets) default voidsendPacketToViewers(SendablePacket packet) Sends a packet to all viewers.default voidSends 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
-
isViewer
Gets if a player is seeing this viewable object.- Parameters:
player- the player to check- Returns:
- true if
playeris 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
-