Package org.bukkit

Interface WorldBorder


public interface WorldBorder
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    changeSize(double newSize, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) long ticks)
    Sets the border to a square region with the specified side length in blocks.
    Gets the current border center.
    double
    Gets the current border damage amount.
    double
    Gets the current border damage buffer.
    double
    Gets the absolute value of the maximum x/z center coordinate of a WorldBorder.
    double
    Gets the maximum possible size of a WorldBorder.
    double
    Gets the current side length of the border.
    int
    Gets the current border warning distance.
    default @org.checkerframework.checker.index.qual.NonNegative int
    Deprecated, for removal: This API element is subject to removal in a future version.
    @org.checkerframework.checker.index.qual.NonNegative int
    Gets the current border warning time in ticks.
    Get the World in which the border resides.
    boolean
    Check if the specified location is inside this border.
    void
    Resets the border to default values.
    void
    setCenter(double x, double z)
    Sets the new border center.
    void
    Sets the new border center.
    void
    setDamageAmount(double damage)
    Sets the amount of damage a player takes when outside the border plus the border buffer.
    void
    setDamageBuffer(double blocks)
    Sets the amount of blocks a player may safely be outside the border before taking damage.
    void
    setSize(double newSize)
    Sets the border to a square region with the specified side length in blocks.
    default void
    setSize(double newSize, long seconds)
    Deprecated, for removal: This API element is subject to removal in a future version.
    default void
    setSize(double newSize, @NotNull TimeUnit unit, @org.checkerframework.checker.index.qual.NonNegative long time)
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    setWarningDistance(int distance)
    Sets the warning distance that causes the screen to be tinted red when the player is within the specified number of blocks from the border.
    default void
    setWarningTime(@org.checkerframework.checker.index.qual.NonNegative int seconds)
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    setWarningTimeTicks(@org.checkerframework.checker.index.qual.NonNegative int ticks)
    Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time.
  • Method Details

    • getWorld

      Get the World in which the border resides.
      Returns:
      the associated world, or null if this world border is not associated with any specific world, such as those created via Server.createWorldBorder()
    • reset

      void reset()
      Resets the border to default values.
    • getSize

      double getSize()
      Gets the current side length of the border.
      Returns:
      The current side length of the border.
    • setSize

      void setSize(double newSize)
      Sets the border to a square region with the specified side length in blocks.
      Parameters:
      newSize - The new size of the border.
      Throws:
      IllegalArgumentException - if newSize is less than 1.0D or greater than getMaxSize()
      See Also:
    • changeSize

      void changeSize(double newSize, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) long ticks)
      Sets the border to a square region with the specified side length in blocks.
      Parameters:
      newSize - The new side length of the border.
      ticks - The time in ticks in which the border grows or shrinks from the previous size to that being set.
      Throws:
      IllegalArgumentException - if newSize is less than 1.0D or greater than getMaxSize()
      IllegalArgumentException - if ticks is out of range
      See Also:
    • setSize

      @Deprecated(since="1.21.11", forRemoval=true) default void setSize(double newSize, long seconds)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the border to a square region with the specified side length in blocks.
      Parameters:
      newSize - The new side length of the border.
      seconds - The time in seconds in which the border grows or shrinks from the previous size to that being set.
      Throws:
      IllegalArgumentException - if seconds is out of range once converted in ticks
    • setSize

      @Deprecated(since="1.21.11", forRemoval=true) default void setSize(double newSize, @NotNull @NotNull TimeUnit unit, @org.checkerframework.checker.index.qual.NonNegative long time)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the border to a square region with the specified side length in blocks.
      Parameters:
      newSize - The new side length of the border.
      unit - The time unit.
      time - The time in which the border grows or shrinks from the previous size to that being set.
      Throws:
      IllegalArgumentException - if newSize is less than 1.0D or greater than getMaxSize()
      IllegalArgumentException - if time is out of range once converted in ticks
    • getCenter

      Gets the current border center.
      Returns:
      The current border center.
    • setCenter

      void setCenter(double x, double z)
      Sets the new border center.
      Parameters:
      x - The new center x-coordinate.
      z - The new center z-coordinate.
      Throws:
      IllegalArgumentException - if the absolute value of x or z is higher than getMaxCenterCoordinate()
    • setCenter

      void setCenter(@NotNull @NotNull Location location)
      Sets the new border center.
      Parameters:
      location - The new location of the border center. (Only x/z used)
      Throws:
      IllegalArgumentException - if location is null or the absolute value of Location.getX() or Location.getZ() is higher than getMaxCenterCoordinate()
    • getDamageBuffer

      double getDamageBuffer()
      Gets the current border damage buffer.
      Returns:
      The current border damage buffer.
    • setDamageBuffer

      void setDamageBuffer(double blocks)
      Sets the amount of blocks a player may safely be outside the border before taking damage.
      Parameters:
      blocks - The amount of blocks. (The default is 5 blocks.)
    • getDamageAmount

      double getDamageAmount()
      Gets the current border damage amount.
      Returns:
      The current border damage amount.
    • setDamageAmount

      void setDamageAmount(double damage)
      Sets the amount of damage a player takes when outside the border plus the border buffer.
      Parameters:
      damage - The amount of damage. (The default is 0.2 damage per second per block.)
    • getWarningTime

      @Deprecated(since="1.21.11", forRemoval=true) default @org.checkerframework.checker.index.qual.NonNegative int getWarningTime()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the current border warning time in seconds.
      Returns:
      The current border warning time in seconds.
    • setWarningTime

      @Deprecated(since="1.21.11", forRemoval=true) default void setWarningTime(@org.checkerframework.checker.index.qual.NonNegative int seconds)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time.
      Parameters:
      seconds - The amount of time in seconds.
    • getWarningTimeTicks

      @org.checkerframework.checker.index.qual.NonNegative int getWarningTimeTicks()
      Gets the current border warning time in ticks.
      Returns:
      The current border warning time in ticks.
    • setWarningTimeTicks

      void setWarningTimeTicks(@org.checkerframework.checker.index.qual.NonNegative int ticks)
      Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time.
      Parameters:
      ticks - The number of ticks.
    • getWarningDistance

      int getWarningDistance()
      Gets the current border warning distance.
      Returns:
      The current border warning distance.
    • setWarningDistance

      void setWarningDistance(int distance)
      Sets the warning distance that causes the screen to be tinted red when the player is within the specified number of blocks from the border.
      Parameters:
      distance - The distance in blocks. (The default is 5 blocks.)
    • isInside

      boolean isInside(@NotNull @NotNull Location location)
      Check if the specified location is inside this border.
      Parameters:
      location - the location to check
      Returns:
      if this location is inside the border or not
    • getMaxSize

      double getMaxSize()
      Gets the maximum possible size of a WorldBorder.
      Returns:
      The maximum size the WorldBorder
    • getMaxCenterCoordinate

      double getMaxCenterCoordinate()
      Gets the absolute value of the maximum x/z center coordinate of a WorldBorder.
      Returns:
      The absolute maximum center coordinate of the WorldBorder