Quick fix to change from WarningTime to WarningTimeTicks and changed …#8504
Quick fix to change from WarningTime to WarningTimeTicks and changed …#8504AnOwlBe wants to merge 2 commits intoSkriptLang:masterfrom
Conversation
…EffWorldBorderExpand.java to use worldborder.ChangeSize
|
We still support non-1.21.11 versions, so you can't just replace the method. All versions below will need to use the old method and .11+ will need to use the new one. You should also run some tests for every pr before submitting it, btw, no matter how small.the quickTest task at the very least. |
|
So its probably not worth it at all to do this until theres a skript jar that only supports 1.21.11+? |
|
No, look at what I said to do. You just need a version check. |
|
Right but the code for it doesn't exist on older versions so it would error on compile unless I am missing something |
|
it's fine as long as the method doesn't get called on older versions |
| input = Math2.fit(1, input, MAX_WORLDBORDER_SIZE); | ||
| for (WorldBorder worldBorder : worldBorders) | ||
| worldBorder.setSize(input, speed); | ||
| if (Objects.equals(Bukkit.getBukkitVersion().split("-")[0], "1.21.11")) { |
There was a problem hiding this comment.
This is bad practice for version checking, you should use the Skript#isRunningMinecraft method.
Also since you’re using it quite often, you should cache it statically at the top.
| double size = worldBorder.getSize(); | ||
| size = Math2.fit(1, size + input, MAX_WORLDBORDER_SIZE); | ||
| worldBorder.setSize(size, speed); | ||
| if (Objects.equals(Bukkit.getBukkitVersion().split("-")[0], "1.21.11")) { |
| worldBorder.changeSize(input, speed); | ||
| } else { | ||
| worldBorder.setSize(input, speed); | ||
|
|
There was a problem hiding this comment.
Random extra space
| worldBorder.setWarningTimeTicks(to.getWarningTimeTicks()); | ||
| } else { | ||
| worldBorder.setWarningTime(to.getWarningTime()); | ||
|
|
There was a problem hiding this comment.
Random extra space
| worldBorder.setDamageBuffer(to.getDamageBuffer()); | ||
| worldBorder.setWarningDistance(to.getWarningDistance()); | ||
| worldBorder.setWarningTime(to.getWarningTime()); | ||
| if (Objects.equals(Bukkit.getBukkitVersion().split("-")[0], "1.21.11")) { |
There was a problem hiding this comment.
Same as above with version
| @Override | ||
| public @Nullable Timespan convert(WorldBorder worldBorder) { | ||
| return new Timespan(TimePeriod.SECOND, worldBorder.getWarningTime()); | ||
| return new Timespan(TimePeriod.SECOND, worldBorder.getWarningTimeTicks()); |
| public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { | ||
| long input = delta == null ? 15 : (((Timespan) delta[0]).getAs(TimePeriod.SECOND)); | ||
| for (WorldBorder worldBorder : getExpr().getArray(event)) { | ||
| long warnTime = Objects.equals(Bukkit.getBukkitVersion().split("-")[0], "1.21.11") |
There was a problem hiding this comment.
same as above about version checking
| // fit and convert back to seconds | ||
| int warningTime = ((int) Math2.fit(0, time, Integer.MAX_VALUE)) / 20; | ||
| worldBorder.setWarningTime(warningTime); | ||
| if (Objects.equals(Bukkit.getBukkitVersion().split("-")[0], "1.21.11")) { |
There was a problem hiding this comment.
same as above with version checking
| worldBorder.setWarningTimeTicks(warningTime); | ||
| } else { | ||
| worldBorder.setWarningTime(warningTime); | ||
|
|
There was a problem hiding this comment.
random extra space
| worldBorder.setWarningTime(warningTime); | ||
|
|
||
| } | ||
|
|
There was a problem hiding this comment.
Another random extra space
APickledWalrus
left a comment
There was a problem hiding this comment.
This PR needs to account for the fact that the new methods are now operating with ticks rather than seconds.
When getting, timespans need to be created using the TICK time period. When setting, we need to obtain as ticks.
Unfortunately, the changes are going to be a bit more involved because of this.
…EffWorldBorderExpand.java to use worldborder.ChangeSize
Problem
They have been deprecated since mc 1.21.11
Solution
Simply changed a few lines to use the newer system (very small stuff like adding
TicksTesting Completed
No testing this is minor enough that nothing should break
Supporting Information
Completes: none
Related: none
AI assistance: none