Class ChairNMS


  • public abstract class ChairNMS
    extends Object
    Provides abstraction to be used in maven modules with the specified spigot version

    Why not just use the Fallback-ChairNMS in #onEnable()?
    • Using the fallback in newer versions requires Spigot to enable old material support
    • NMS allows us to easily rotate the ArmorStand together with the player (without using PlayerMoveEvent)
    • Field Detail

      • REGENERATION_EFFECT_DURATION

        public static final int REGENERATION_EFFECT_DURATION
        See Also:
        Constant Field Values
    • Constructor Detail

      • ChairNMS

        public ChairNMS()
    • Method Detail

      • spawnChairArmorStand

        @NotNull
        public abstract @NotNull org.bukkit.entity.ArmorStand spawnChairArmorStand​(@NotNull
                                                                                   @NotNull org.bukkit.Location loc,
                                                                                   int regenerationAmplifier)
        Spawns an ArmorStand that is/has:
        • Invisible
        • Invincible
        • NoGravity
        • DisabledSlots
        The ArmorStand may fulfill the above with the help of getListener().
        Parameters:
        loc - The location for the Chair-ArmorStand
        regenerationAmplifier - The amplifier for the regeneration effect
        Returns:
        The created ArmorStand to be used for an Chair
        See Also:
        getRegenerationAmplifier(Player)
      • killChairArmorStand

        public abstract void killChairArmorStand​(@NotNull
                                                 @NotNull org.bukkit.entity.ArmorStand armorStand)
        Parameters:
        armorStand - The ArmorStand that should be deleted
        Throws:
        IllegalArgumentException - if armorStand is not an instance of CustomArmorStand
      • isStair

        public abstract boolean isStair​(@NotNull
                                        @NotNull org.bukkit.block.Block block)
      • isStairUpsideDown

        public abstract boolean isStairUpsideDown​(@NotNull
                                                  @NotNull org.bukkit.block.Block block)
      • getBlockRotation

        @NotNull
        public abstract @NotNull org.bukkit.block.BlockFace getBlockRotation​(@NotNull
                                                                             @NotNull org.bukkit.block.Block block)
      • isSlab

        public abstract boolean isSlab​(@NotNull
                                       @NotNull org.bukkit.block.Block block)
        Parameters:
        block - The Block to check
        Returns:
        true if the block is a half slab (not double slab!), false otherwise
      • isSlabTop

        public abstract boolean isSlabTop​(@NotNull
                                          @NotNull org.bukkit.block.Block block)
      • hasEmptyHands

        public abstract boolean hasEmptyHands​(@NotNull
                                              @NotNull org.bukkit.entity.Player player)
      • isChair

        public abstract boolean isChair​(@NotNull
                                        @NotNull org.bukkit.entity.ArmorStand armorStand)
        Checks if an ArmorStand is or will be used as Chair with NMS.
        This method should be used to identify a Chair before it has been spawned into the world.
        This can for example be used to un-cancel an EntitySpawnEvent
        Parameters:
        armorStand - ArmorStand to check
        Returns:
        true if ArmorStand is or will be used as Chair, false otherwise
        See Also:
        ChairManager.isChair(ArmorStand)
      • getListener

        @Nullable
        public @Nullable org.bukkit.event.Listener getListener()
      • getRegenerationAmplifier

        public static int getRegenerationAmplifier​(org.bukkit.entity.Player p)