Skip to content

Commit 5e70871

Browse files
committed
Finalization for v9.6.0
1 parent 4f8dc95 commit 5e70871

File tree

7 files changed

+77
-32
lines changed

7 files changed

+77
-32
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.cryptomorin</groupId>
88
<artifactId>XSeries</artifactId>
9-
<version>9.5.0</version>
9+
<version>9.6.0</version>
1010

1111
<name>XSeries</name>
1212
<description>A set of utilities for Minecraft plugins</description>
@@ -254,7 +254,7 @@
254254
<profile>
255255
<id>latest</id>
256256
<properties>
257-
<nms>19_R0</nms>
257+
<nms>20_R0</nms>
258258
</properties>
259259
</profile>
260260
<profile>

src/main/java/com/cryptomorin/xseries/ReflectionUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,20 @@ public static boolean supports(int minorNumber) {
295295
return MINOR_NUMBER >= minorNumber;
296296
}
297297

298+
/**
299+
* Checks whether the server version is equal or greater than the given version.
300+
*
301+
* @param minorNumber the minor version to compare the server version with.
302+
* @param patchNumber the patch number to compare the server version with.
303+
* @return true if the version is equal or newer, otherwise false.
304+
* @see #MINOR_NUMBER
305+
* @see #PATCH_NUMBER
306+
* @since 7.1.0
307+
*/
308+
public static boolean supports(int minorNumber, int patchNumber) {
309+
return MINOR_NUMBER == minorNumber ? supportsPatch(patchNumber) : supports(minorNumber);
310+
}
311+
298312
/**
299313
* Checks whether the server version is equal or greater than the given version.
300314
*

src/main/java/com/cryptomorin/xseries/SkullUtils.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,32 @@ public static String getSkinValue(@Nonnull ItemMeta skull) {
294294

295295
if (profile != null && !profile.getProperties().get("textures").isEmpty()) {
296296
for (Property property : profile.getProperties().get("textures")) {
297-
if (!property.getValue().isEmpty()) return property.getValue();
297+
String value = getPropertyValue(property);
298+
if (!value.isEmpty()) return value;
298299
}
299300
}
300301

301302
return null;
302303
}
303304

305+
/**
306+
* They changed {@link Property} to a Java record in 1.20.2
307+
*
308+
* @since 4.0.1
309+
*/
310+
private static String getPropertyValue(Property property) {
311+
if (ReflectionUtils.supports(12, 2)) {
312+
return property.value();
313+
} else {
314+
try {
315+
//noinspection JavaReflectionMemberAccess
316+
return (String) Property.class.getMethod("getValue").invoke(property);
317+
} catch (Throwable e) {
318+
throw new RuntimeException(e);
319+
}
320+
}
321+
}
322+
304323
/**
305324
* https://help.minecraft.net/hc/en-us/articles/360034636712
306325
*

src/main/java/com/cryptomorin/xseries/XSound.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* play command: <a href="https://minecraft.wiki/w/Commands/play">minecraft.wiki/w</a>
5656
*
5757
* @author Crypto Morin
58-
* @version 9.2.0
58+
* @version 9.2.1
5959
* @see Sound
6060
*/
6161
public enum XSound {
@@ -645,6 +645,12 @@ public enum XSound {
645645
BLOCK_SOUL_SOIL_HIT,
646646
BLOCK_SOUL_SOIL_PLACE,
647647
BLOCK_SOUL_SOIL_STEP,
648+
BLOCK_SPONGE_ABSORB,
649+
BLOCK_SPONGE_BREAK,
650+
BLOCK_SPONGE_FALL,
651+
BLOCK_SPONGE_HIT,
652+
BLOCK_SPONGE_PLACE,
653+
BLOCK_SPONGE_STEP,
648654
BLOCK_SPORE_BLOSSOM_BREAK,
649655
BLOCK_SPORE_BLOSSOM_FALL,
650656
BLOCK_SPORE_BLOSSOM_HIT,
@@ -707,6 +713,11 @@ public enum XSound {
707713
BLOCK_WET_GRASS_HIT,
708714
BLOCK_WET_GRASS_PLACE("BLOCK_WET_GRASS_HIT"),
709715
BLOCK_WET_GRASS_STEP("BLOCK_WET_GRASS_HIT"),
716+
BLOCK_WET_SPONGE_BREAK,
717+
BLOCK_WET_SPONGE_FALL,
718+
BLOCK_WET_SPONGE_HIT,
719+
BLOCK_WET_SPONGE_PLACE,
720+
BLOCK_WET_SPONGE_STEP,
710721
BLOCK_WOODEN_BUTTON_CLICK_OFF("WOOD_CLICK", "BLOCK_WOOD_BUTTON_CLICK_OFF"),
711722
BLOCK_WOODEN_BUTTON_CLICK_ON("WOOD_CLICK", "BLOCK_WOOD_BUTTON_CLICK_ON"),
712723
BLOCK_WOODEN_DOOR_CLOSE("DOOR_CLOSE"),

src/main/java/com/cryptomorin/xseries/particles/ParticleDisplay.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public class ParticleDisplay implements Cloneable {
9898
* instead of handling the direction in a specific axis.
9999
* This makes it easier for them as well and allows easier use of the {@link #rotation} API.
100100
*/
101-
private Supplier<Vector> direction;
101+
private final Vector directionNormal = new Vector(0, 1, 0);
102+
private Supplier<Vector> direction = () -> directionNormal;
102103
@Nonnull
103104
private Axis[] rotationOrder = DEFAULT_ROTATION_ORDER;
104105
@Nullable

src/main/java/com/cryptomorin/xseries/particles/XParticle.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,20 +1442,24 @@ public static BukkitTask atomic(Plugin plugin, int orbits, double radius, double
14421442
/**
14431443
* Spawns animated helix shapes.
14441444
*
1445-
* @param strings the amount of helix strings. The rotation angle will split equally for each.
1446-
* @param radius the radius of the helix.
1447-
* @param rate the rate of helix points.
1448-
* @param extension the helix circle extension.
1449-
* @param length the length of the helix.
1450-
* @param speed the speed of the rate builder in each animation tick.
1451-
* @param fadeUp helix radius will decrease to zero as it gets closer to the top.
1452-
* @param fadeDown helix radius will increase to the original radius as it gets closer to the center.
1445+
* @param strings the amount of helix strings. The rotation angle will split equally for each.
1446+
* @param radius the radius of the helix.
1447+
* @param rate the rate of helix points.
1448+
* @param extension the helix circle extension.
1449+
* @param length the length of the helix.
1450+
* @param speed the amount of blocks the particles advances in one tick. Recommended is 0.5
1451+
* @param rotationRate The amount particles rotate around the circular reference, should be set depending on the amount of strings.
1452+
* 5 is usually a good value.
1453+
* @param fadeUp helix radius will decrease to zero as it gets closer to the top.
1454+
* @param fadeDown helix radius will increase to the original radius as it gets closer to the center.
14531455
* @return the animation runnable. It will return false when the animation is finished.
14541456
* @see #dnaReplication(double, double, int, double, int, int, ParticleDisplay)
14551457
* @since 3.0.0
14561458
*/
1457-
public static BooleanSupplier helix(int strings, double radius, double rate, double extension, int length, int speed,
1458-
boolean fadeUp, boolean fadeDown, ParticleDisplay display) {
1459+
public static BooleanSupplier helix(int strings, double radius, double rate, double extension,
1460+
double length, double speed, double rotationRate,
1461+
boolean fadeUp, boolean fadeDown,
1462+
ParticleDisplay display) {
14591463
return new BooleanSupplier() {
14601464
// If we look at a helix string from above, we'll see a circle tunnel.
14611465
// To make this tunnel we're going to generate circles while moving
@@ -1467,17 +1471,13 @@ public static BooleanSupplier helix(int strings, double radius, double rate, dou
14671471
final double radiusDiv2 = fadeUp && fadeDown ? radiusDiv * 2 : radiusDiv;
14681472
double dynamicRadius = fadeDown ? 0 : radius;
14691473
boolean center = !fadeDown;
1470-
final double rotationRate = distanceBetweenEachCirclePoints / 5;
1474+
final double calculatedRotRate = distanceBetweenEachCirclePoints / rotationRate;
14711475
double rotation = 0;
1472-
final boolean done = false;
1476+
double currentDistance = 0;
14731477

14741478
@Override
14751479
public boolean getAsBoolean() {
1476-
if (done) return false;
1477-
1478-
// int repeat = speed;
1479-
// while (repeat-- > 0) {
1480-
// y += rate;
1480+
if (currentDistance >= length) return false;
14811481

14821482
if (!center) {
14831483
dynamicRadius += radiusDiv2;
@@ -1493,13 +1493,10 @@ public boolean getAsBoolean() {
14931493
display.spawn(x, 0, z);
14941494
}
14951495

1496-
display.advanceInDirection(1);
1497-
rotation += rotationRate;
1498-
// if (y > length) {
1499-
// done = true;
1500-
// return false;
1501-
// }
1502-
// }
1496+
currentDistance += speed;
1497+
if (currentDistance < length) display.advanceInDirection(speed);
1498+
else display.advanceInDirection(speed - (currentDistance - length));
1499+
rotation += calculatedRotRate;
15031500

15041501
return true;
15051502
}
@@ -1522,9 +1519,10 @@ public boolean getAsBoolean() {
15221519
* @see #dnaReplication(Plugin, double, double, int, double, int, int, ParticleDisplay)
15231520
* @since 3.0.0
15241521
*/
1525-
public static BukkitTask helix(Plugin plugin, int strings, double radius, double rate, double extension, int height, int speed,
1522+
public static BukkitTask helix(Plugin plugin, int strings, double radius, double rate,
1523+
double extension, double height, double speed, double rotationRate,
15261524
boolean fadeUp, boolean fadeDown, ParticleDisplay display) {
1527-
BooleanSupplier helix = helix(strings, radius, rate, extension, height, speed, fadeUp, fadeDown, display);
1525+
BooleanSupplier helix = helix(strings, radius, rate, extension, height, speed, rotationRate, fadeUp, fadeDown, display);
15281526
return new BukkitRunnable() {
15291527
@Override
15301528
public void run() {
@@ -1603,7 +1601,7 @@ public static void lightning(Location start, Vector direction, int entries, int
16031601
* @param hydrogenBondDist the distance between each hydrogen bond (read inside method). This distance is also affected by rate.
16041602
* @param display display for strings.
16051603
* @param hydrogenBondDisplay display for hydrogen bonds.
1606-
* @see #helix(Plugin, int, double, double, double, int, int, boolean, boolean, ParticleDisplay)
1604+
* @see #helix(int, double, double, double, double, double, double, boolean, boolean, ParticleDisplay)
16071605
* @see #dnaReplication(Plugin, double, double, int, double, int, int, ParticleDisplay)
16081606
* @since 1.0.0
16091607
*/

src/test/DifferenceHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class DifferenceHelper {
2121
*/
2222
public static void versionDifference() {
2323
Path serverFolder = Bukkit.getWorldContainer().toPath();
24+
System.out.println("Server container: " + serverFolder.toAbsolutePath());
25+
2426
Path materials = serverFolder.resolve("XMaterial.txt"),
2527
sounds = serverFolder.resolve("XSound.txt"),
2628
xPotion = serverFolder.resolve("XPotion.txt"),

0 commit comments

Comments
 (0)