Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/WorldBorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.papermc.paper.util.Tick;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;

public interface WorldBorder {

Expand Down Expand Up @@ -62,7 +63,7 @@ default void setSize(double newSize, long seconds) {
* @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()}
* @throws IllegalArgumentException if ticks are less than 0
*/
void changeSize(double newSize, long ticks);
void changeSize(double newSize, @Range(from = 0, to = Long.MAX_VALUE) long ticks);

/**
* Sets the border to a square region with the specified side length in blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,9 @@ public void addWorld(World world) {

@Override
public WorldBorder createWorldBorder() {
return new CraftWorldBorder(new net.minecraft.world.level.border.WorldBorder());
CraftWorldBorder craftWorldBorder = new CraftWorldBorder(new net.minecraft.world.level.border.WorldBorder());
craftWorldBorder.getHandle().applyInitialSettings(0L); // Like the ServerLevel#getWorldBorder we make sure the Settings are applied
return craftWorldBorder;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public void setSize(double newSize) {

@Override
public void changeSize(double newSize, long ticks) {
Preconditions.checkArgument(ticks >= 0, "ticks cannot be lower than 0");
Preconditions.checkArgument(ticks >= 0, "cannot be lower than 0");
Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize());

ticks = Math.clamp(ticks, 0L, Long.MAX_VALUE);

if (ticks > 0L) {
final long startTime = (this.getWorld() != null) ? this.getWorld().getGameTime() : 0; // Virtual Borders don't have a World
this.handle.lerpSizeBetween(this.handle.getSize(), newSize, ticks, startTime);
Expand Down
Loading