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 Details

    • addViewer

      boolean addViewer(@NotNull @NotNull Player player)
      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

      boolean removeViewer(@NotNull @NotNull Player player)
      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

      @NotNull @NotNull Set<@NotNull Player> getViewers()
      Gets all the viewers of this viewable element.
      Returns:
      A Set containing all the element's viewers
    • isViewer

      default boolean isViewer(@NotNull @NotNull Player player)
      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

      default void sendPacketToViewers(@NotNull @NotNull SendablePacket packet)
      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

      default void sendPacketsToViewers(@NotNull @NotNull Collection<SendablePacket> packets)
    • sendPacketsToViewers

      default void sendPacketsToViewers(@NotNull @NotNull SendablePacket... packets)
    • sendPacketToViewersAndSelf

      default void sendPacketToViewersAndSelf(@NotNull @NotNull SendablePacket packet)
      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

      @NotNull default @NotNull Audience getViewersAsAudience()
      Gets the result of getViewers() as an Adventure Audience.
      Returns:
      the audience
    • getViewersAsAudiences

      @NotNull default @NotNull Iterable<? extends Audience> getViewersAsAudiences()
      Gets the result of getViewers() as an Iterable of Adventure Audiences.
      Returns:
      the audiences