Class ChairManager

java.lang.Object
de.sprax2013.betterchairs.ChairManager

public class ChairManager extends Object
This class should be instantiated as soon as possible inside JavaPlugin.onEnable() to ensure that other classes relying on it work as intended
  • Field Details

  • Constructor Details

    • ChairManager

      protected ChairManager(@NotNull @NotNull JavaPlugin plugin, @NotNull @NotNull ChairNMS chairNMS)
  • Method Details

    • onQuit

      protected void onQuit(UUID uuid)
    • create

      public boolean create(Player player, Block block)
      This method is a shortcut for create(Player, Block, double) with yOffset = ChairUtils#getSitOffset
      See Also:
    • create

      public boolean create(Player player, Block block, double yOffset)
      Check if a chair can be spawned and call an Event.
      If the event doesn't get cancelled, the player should then be able to sit.
      Ignores hasChairsDisabled(OfflinePlayer)
      Parameters:
      player - The player that should sit
      block - The block the player should sit on
      Returns:
      true if player is now sitting on a chair, false otherwise
    • destroy

      public void destroy(Chair chair, boolean teleportPlayer)
      Calls destroy(Chair, boolean, boolean) with sameTickTeleport = false
      Parameters:
      chair - The Chair that should be destroyed
      teleportPlayer - true, when called without an PlayerTeleportEvent being fired afterwards (e.g. EntityDismountEvent does)
      See Also:
    • destroy

      public void destroy(Chair chair, boolean teleportPlayer, boolean sameTickTeleport)
      Parameters:
      chair - The Chair that should be destroyed
      teleportPlayer - true, when called without an PlayerTeleportEvent being fired afterwards (e.g. EntityDismountEvent does)
      sameTickTeleport - For compatibility reasons the player is teleported on the next server tick. This may not be possible in some situations
    • destroyAll

      public int destroyAll(boolean teleportPlayer)
    • destroyAll

      public int destroyAll(boolean teleportPlayer, boolean sameTickTeleport)
    • isOccupied

      public boolean isOccupied(@NotNull @NotNull Block b)
      Parameters:
      b - The block to check
      Returns:
      true if a player is sitting on it, false otherwise
    • getChair

      @Nullable public @Nullable Chair getChair(@NotNull @NotNull Player p)
    • getChair

      @Nullable public @Nullable Chair getChair(@NotNull @NotNull Block b)
    • getChair

      @Nullable public @Nullable Chair getChair(@NotNull @NotNull Entity entity)
    • isChair

      public boolean isChair(@NotNull @NotNull Entity entity)
      This does not yet guarantee that getChair(Entity) is not null
      This may return true for Entities not yet spawned and thus not yet a Chair that is ready
      Parameters:
      entity - The Entity to check
      Returns:
      true if the Entity is used or may be used as Chair
    • hasChairsDisabled

      public boolean hasChairsDisabled(OfflinePlayer player)
    • hasChairsDisabled

      public boolean hasChairsDisabled(UUID uuid)
    • setChairsDisabled

      public void setChairsDisabled(Player player, boolean areDisabled)
    • setChairsDisabled

      public void setChairsDisabled(UUID uuid, boolean areDisabled)
    • getLogger

      @NotNull public static @NotNull Logger getLogger()
      Returns BetterChair's logger or the global one, when getPlugin() is null.
      Returns:
      The plugin's Logger or the global one, never null
    • getInstance

      @Nullable public static @Nullable ChairManager getInstance()
      May be null if BetterChairs is not enabled
      Returns:
      The ChairManager instance created by BetterChairs, or null
    • getPlugin

      @Nullable public static @Nullable JavaPlugin getPlugin()
      May be null if BetterChairs is not enabled
      Returns:
      The JavaPlugin instance representing BetterChairs, or null