Add worldborders#7006
Conversation
|
A lot of chez's stuff might of been repeated he beat me ;( |
sovdeeth
left a comment
There was a problem hiding this comment.
just needs some formatting updates, mainly around annotations!
2cdbc4e to
d7dbc0c
Compare
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @Name("Warning Time of World Border") | ||
| @Description("The warning time of a world border. If the border is shrinking, the player's screen will be tinted red once the border will catch the player within this time period.") |
There was a problem hiding this comment.
so if the player is outside the border it will be tinted red after one second? im not sure what this expression does
There was a problem hiding this comment.
Its specifically when the worldborder is shrinking. If the player is outside the final worldborder (after the shrink), their screen will turn red x seconds before it reaches their current location
| Location location = mode == ChangeMode.SET ? (Location) delta[0] : null; | ||
| for (WorldBorder worldBorder : getExpr().getArray(event)) { | ||
| switch (mode) { | ||
| case SET: |
There was a problem hiding this comment.
Not a big deal, but maybe an enhanced switch?
499ff66 to
e6eef8b
Compare
…order#getMaxCenterCoordinate
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Fusezion
left a comment
There was a problem hiding this comment.
Leaving a proper review to other people, but uhh thoughts on WorldBorder x AnySizedThing? size of worldborder, set size of worldborder to 10
| import org.bukkit.event.player.PlayerQuitEvent.QuitReason; | ||
| import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; | ||
| import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; | ||
| import org.bukkit.event.player.PlayerExpCooldownChangeEvent.ChangeReason; |
There was a problem hiding this comment.
I know you've had some trouble merging/updating your branch, so let's hope nothing got removed in the making.
| if (((long) worldBorder.getWarningDistance() + input) > Integer.MAX_VALUE) { | ||
| worldBorder.setWarningDistance(Integer.MAX_VALUE); | ||
| } else if (((long) worldBorder.getWarningDistance() + input) < Integer.MIN_VALUE) { | ||
| worldBorder.setWarningDistance(Integer.MIN_VALUE); | ||
| } else { | ||
| worldBorder.setWarningDistance(Math.max(worldBorder.getWarningDistance() + input, 0)); | ||
| } | ||
| break; |
There was a problem hiding this comment.
| if (((long) worldBorder.getWarningDistance() + input) > Integer.MAX_VALUE) { | |
| worldBorder.setWarningDistance(Integer.MAX_VALUE); | |
| } else if (((long) worldBorder.getWarningDistance() + input) < Integer.MIN_VALUE) { | |
| worldBorder.setWarningDistance(Integer.MIN_VALUE); | |
| } else { | |
| worldBorder.setWarningDistance(Math.max(worldBorder.getWarningDistance() + input, 0)); | |
| } | |
| break; | |
| int current = worldBorder.getWarningDistance(); | |
| int value = Math2.fit(0, current + input, Integer.MAX_VALUE); | |
| worldBorder.setWarningDistance(value) |
Shouldnt be using MIN_VALUE because that's a negative, I dont think a world border should have a negative distance.
There was a problem hiding this comment.
The MIN_VALUE part is true but I did the rest of it to catch integer overflows during the addition / subtraction. It seems like the Math2.fit wouldn't help that unless I am misunderstanding the code
There was a problem hiding this comment.
Well one thing you should do, is in #acceptChange instead of returning Number.class you should do Integer.class in my opinion. As that in itself would exclude any nan and infinite values. As well as capping the provided number to Integer.MAX_VALUE
There was a problem hiding this comment.
I dont think switching it to integer class fixed the integer overflow issues so I think it might leave it as is with the MIN_VALUE thing fixed
Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>
What do you mean? Is this some newer feature that I haven't seen yet / forgot about? |
sovdeeth
left a comment
There was a problem hiding this comment.
looks good to me
i appreciate the very thorough tests
* Initial setup * Fix imports * Use pattern variables for instanceof * Cleaner switch statements * Specify paper version * Use newer timespan method * Require "world border" when editing a world border's attributes * Move IsInsideWorldBorder to IsWithin condition * Make variable name readable * Clean up conditions * Make radius/diameter optional * Make damage have a minimum of 0 * Make warning distance have a minimum of 0 * Make damage buffer have a minimum of 0 * Make warning time have a minimum of 0 * Force the center location to stay inside the limits defined by WorldBorder#getMaxCenterCoordinate * Tests! * End files with a new line * Apply suggestions from code review Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> * Correct annotation placement * Apply suggestions from code review Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com> * Phil's stuff. * More of Phil's stuff. * Whoops I imported again * Apply suggestions from code review Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com> * register properties as defaults * Add docs * Clean up toString * Update tests * Apply suggestions from code review Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> * Fix imports * Remove duplicate event registration * Update src/main/java/ch/njol/skript/expressions/ExprSecCreateWorldBorder.java Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com> * Fix typo * Validate inputs before setting the value * Update src/main/java/ch/njol/skript/effects/EffWorldBorderExpand.java Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> * Paper's getMaxSize method did not do what I expected * Improve tests * Add check for NaN * Add check for NaN and infinite values * Add check for NaN and overflow during integer math * Apply suggestions from code review Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com> * Move clamp outside loop * Remove extra event-value registration * Improve example for World Border Bounds Change Event * Clean up imports * Set the Warning Distance to 0 rather than MIN_VALUE * Add more tests with large numbers * Account for integer overflow issues * Remove debug code * Use signum to clean up conditions --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com> Co-authored-by: Moderocky <admin@moderocky.com>
Description
Add worldborder syntax to Skript. Continuation of #5229
Player's worldborder is always virtual
Conditions:
Effects:
I don't like the way I am registering the syntax right now with the
ofand'sbut I can't think of a different wayEvents:
Expressions:
Sections:
Target Minecraft Versions: any
Requirements: Paper for worldborder events
Related Issues: #5178, #3848