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 Details

    • addViewer

      boolean addViewer​(@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 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 java.util.Set<Player> getViewers()
      Gets all the viewers of this viewable element.
      Returns:
      A Set containing all the element's viewers
    • isViewer

      default boolean isViewer​(@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 ServerPacket 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 ServerPacket... packets)
      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

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