Class ChairNMS

java.lang.Object
de.sprax2013.betterchairs.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 Details

    • REGENERATION_EFFECT_DURATION

      public static final int REGENERATION_EFFECT_DURATION
      See Also:
  • Constructor Details

    • ChairNMS

      public ChairNMS()
  • Method Details

    • spawnChairEntity

      @NotNull public abstract @NotNull Entity spawnChairEntity(@NotNull @NotNull Location loc, int regenerationAmplifier, boolean useArmorStand)
      Spawns an Entity that is/has:
      • Invisible
      • Invincible
      • NoGravity
      • Silent
      • DisabledSlots (if it is an ArmorStand)
      • NoBounce (if it is an Arrow)
      The entity may fulfill the above with the help of getListener() and ChairUtils.applyChairProtections(Entity)
      Parameters:
      loc - The location for the Chair-Entity
      regenerationAmplifier - The amplifier for the regeneration effect
      useArmorStand - Whether an ArmorStand should be used as Entity
      Returns:
      The created Entity to be used for a Chair
      See Also:
    • killChairEntity

      public abstract void killChairEntity(@NotNull @NotNull Entity entity)
      Parameters:
      entity - The Entity that should be deleted
      Throws:
      IllegalArgumentException - if entity is not an instance of the custom Entity
    • isStair

      public abstract boolean isStair(@NotNull @NotNull Block block)
    • isStairUpsideDown

      public abstract boolean isStairUpsideDown(@NotNull @NotNull Block block)
    • getBlockRotation

      @NotNull public abstract @NotNull BlockFace getBlockRotation(@NotNull @NotNull Block block)
    • isSlab

      public abstract boolean isSlab(@NotNull @NotNull 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 Block block)
    • hasEmptyMainHand

      public abstract boolean hasEmptyMainHand(@NotNull @NotNull Player player)
    • isChair

      public abstract boolean isChair(@NotNull @NotNull Entity entity)
      Checks if an Entity 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:
      entity - Entity to check
      Returns:
      true if Entity is or will be used as Chair, false otherwise
      See Also:
    • getListener

      @Nullable public @Nullable Listener getListener()
    • getRegenerationAmplifier

      public static int getRegenerationAmplifier(Player p)