Package org.bukkit
Interface WorldBorder
public interface WorldBorder
-
Method Summary
Modifier and TypeMethodDescriptionGets 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
getSize()
Gets the current side length of the border.int
Gets the current border warning distance.int
Gets the current border warning time in seconds.getWorld()
Get theWorld
in which the border resides.default boolean
isInBounds
(@NotNull Location location) Deprecated, for removal: This API element is subject to removal in a future version.boolean
Check if the specified location is inside this border.void
reset()
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.void
setSize
(double newSize, long seconds) Sets the border to a square region with the specified side length in blocks.void
Sets the border to a square region with the specified side length in blocks.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.void
setWarningTime
(int seconds) 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 theWorld
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 thangetMaxSize()
-
setSize
void setSize(double newSize, long seconds) 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 newSize is less than 1.0D or greater thangetMaxSize()
-
setSize
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 unit isnull
or newSize is less than 1.0D or greater thangetMaxSize()
-
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 thangetMaxCenterCoordinate()
-
setCenter
Sets the new border center.- Parameters:
location
- The new location of the border center. (Only x/z used)- Throws:
IllegalArgumentException
- if location isnull
or the absolute value ofLocation.getX()
orLocation.getZ()
is higher thangetMaxCenterCoordinate()
-
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
int getWarningTime()Gets the current border warning time in seconds.- Returns:
- The current border warning time in seconds.
-
setWarningTime
void setWarningTime(int seconds) 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. (The default is 15 seconds.)
-
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
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
-
isInBounds
@Deprecated(forRemoval=true) @ScheduledForRemoval(inVersion="1.21") default boolean isInBounds(@NotNull @NotNull Location location) Deprecated, for removal: This API element is subject to removal in a future version.useisInside(Location)
for an upstream compatible replacementChecks if the location is within the boundaries of this border.- Parameters:
location
- specific location to check- Returns:
- true if the location is within the bounds of this border, false otherwise.
-
isInside(Location)
for an upstream compatible replacement