Finish converting most of the undeprecated api to jspecify

This commit is contained in:
Jake Potrebic 2024-09-30 11:44:36 -07:00
parent ba3c29b92e
commit e7e1ab56ca
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
45 changed files with 1046 additions and 982 deletions

View file

@ -12,18 +12,19 @@ Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
diff --git a/src/main/java/io/papermc/paper/math/Rotations.java b/src/main/java/io/papermc/paper/math/Rotations.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9fb7cfbad
index 0000000000000000000000000000000000000000..2a8e1aa29ab87c69a02f72615fbf1374714f54cf
--- /dev/null
+++ b/src/main/java/io/papermc/paper/math/Rotations.java
@@ -0,0 +1,100 @@
@@ -0,0 +1,101 @@
+package io.papermc.paper.math;
+
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Rotations is an immutable object that stores rotations
+ * in degrees on each axis (X, Y, Z).
+ */
+@NullMarked
+public interface Rotations {
+
+ /**
@ -39,7 +40,7 @@ index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9
+ * @param z the angle for the Z axis in degrees
+ * @return Rotations instance holding the provided rotations
+ */
+ static @NotNull Rotations ofDegrees(double x, double y, double z) {
+ static Rotations ofDegrees(final double x, final double y, final double z) {
+ return new RotationsImpl(x, y, z);
+ }
+
@ -71,7 +72,7 @@ index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9
+ * @param x the angle in degrees
+ * @return the resultant Rotations
+ */
+ @NotNull Rotations withX(double x);
+ Rotations withX(double x);
+
+ /**
+ * Returns a new Rotations instance which is the result
@ -80,7 +81,7 @@ index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9
+ * @param y the angle in degrees
+ * @return the resultant Rotations
+ */
+ @NotNull Rotations withY(double y);
+ Rotations withY(double y);
+
+ /**
+ * Returns a new Rotations instance which is the result
@ -89,7 +90,7 @@ index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9
+ * @param z the angle in degrees
+ * @return the resultant Rotations
+ */
+ @NotNull Rotations withZ(double z);
+ Rotations withZ(double z);
+
+ /**
+ * Returns a new Rotations instance which is the result of adding
@ -100,7 +101,7 @@ index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9
+ * @param z the angle to add to the Z axis in degrees
+ * @return the resultant Rotations
+ */
+ @NotNull Rotations add(double x, double y, double z);
+ Rotations add(double x, double y, double z);
+
+ /**
+ * Returns a new Rotations instance which is the result of subtracting
@ -111,40 +112,41 @@ index 0000000000000000000000000000000000000000..0ac1618113699ac50b9c35294bf23fb9
+ * @param z the angle to subtract from the Z axis in degrees
+ * @return the resultant Rotations
+ */
+ default @NotNull Rotations subtract(double x, double y, double z) {
+ return add(-x, -y, -z);
+ default Rotations subtract(final double x, final double y, final double z) {
+ return this.add(-x, -y, -z);
+ }
+
+}
diff --git a/src/main/java/io/papermc/paper/math/RotationsImpl.java b/src/main/java/io/papermc/paper/math/RotationsImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..53359ab4a6659bce895deef6a21cde848d3cadcd
index 0000000000000000000000000000000000000000..35b493b870240f2cb142ea0c3bc2a5b2a89af25b
--- /dev/null
+++ b/src/main/java/io/papermc/paper/math/RotationsImpl.java
@@ -0,0 +1,27 @@
@@ -0,0 +1,28 @@
+package io.papermc.paper.math;
+
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+@NullMarked
+record RotationsImpl(double x, double y, double z) implements Rotations {
+
+ @Override
+ public @NotNull RotationsImpl withX(double x) {
+ return new RotationsImpl(x, y, z);
+ public RotationsImpl withX(final double x) {
+ return new RotationsImpl(x, this.y, this.z);
+ }
+
+ @Override
+ public @NotNull RotationsImpl withY(double y) {
+ return new RotationsImpl(x, y, z);
+ public RotationsImpl withY(final double y) {
+ return new RotationsImpl(this.x, y, this.z);
+ }
+
+ @Override
+ public @NotNull RotationsImpl withZ(double z) {
+ return new RotationsImpl(x, y, z);
+ public RotationsImpl withZ(final double z) {
+ return new RotationsImpl(this.x, this.y, z);
+ }
+
+ @Override
+ public @NotNull RotationsImpl add(double x, double y, double z) {
+ public RotationsImpl add(final double x, final double y, final double z) {
+ return new RotationsImpl(this.x + x, this.y + y, this.z + z);
+ }
+