Class 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 Detail

      • plugin

        protected static org.bukkit.plugin.java.JavaPlugin plugin
      • chairNMS

        protected final ChairNMS chairNMS
      • disabled

        protected final List<org.bukkit.entity.Player> disabled
    • Constructor Detail

      • ChairManager

        protected ChairManager​(@NotNull
                               @NotNull org.bukkit.plugin.java.JavaPlugin plugin,
                               @NotNull
                               @NotNull ChairNMS chairNMS)
    • Method Detail

      • create

        public boolean create​(org.bukkit.entity.Player player,
                              org.bukkit.block.Block block)
        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(Player)
        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,
                            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 org.bukkit.block.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 org.bukkit.entity.Player p)
      • getChair

        @Nullable
        public @Nullable Chair getChair​(@NotNull
                                        @NotNull org.bukkit.block.Block b)
      • getChair

        @Nullable
        public @Nullable Chair getChair​(@NotNull
                                        @NotNull org.bukkit.entity.ArmorStand armorStand)
      • isChair

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

        public boolean hasChairsDisabled​(org.bukkit.entity.Player player)
      • setChairsDisabled

        public void setChairsDisabled​(org.bukkit.entity.Player player,
                                      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 org.bukkit.plugin.java.JavaPlugin getPlugin()
        May be null if BetterChairs is not enabled
        Returns:
        The JavaPlugin instance representing BetterChairs, or null