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 29a25df60e
commit 0adf5876db
45 changed files with 782 additions and 718 deletions

View File

@@ -26,11 +26,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A scoreboard number format that replaces the score number with a chat component.
+ */
+@NullMarked
+public interface FixedFormat extends NumberFormat, ComponentLike {
+
+ /**
@@ -38,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the chat component
+ */
+ @NotNull Component component();
+ Component component();
+
+}
diff --git a/src/main/java/io/papermc/paper/scoreboard/numbers/FixedFormatImpl.java b/src/main/java/io/papermc/paper/scoreboard/numbers/FixedFormatImpl.java
@@ -50,12 +51,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package io.papermc.paper.scoreboard.numbers;
+
+import net.kyori.adventure.text.Component;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+record FixedFormatImpl(@NotNull Component component) implements FixedFormat {
+@NullMarked
+record FixedFormatImpl(Component component) implements FixedFormat {
+
+ @Override
+ public @NotNull Component asComponent() {
+ public Component asComponent() {
+ return this.component();
+ }
+}
@@ -70,11 +72,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.kyori.adventure.text.ComponentLike;
+import net.kyori.adventure.text.format.Style;
+import net.kyori.adventure.text.format.StyleBuilderApplicable;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Describes a scoreboard number format that applies custom formatting to scoreboard scores.
+ */
+@NullMarked
+public interface NumberFormat {
+
+ /**
@@ -82,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return a blank number format
+ */
+ static @NotNull NumberFormat blank() {
+ static NumberFormat blank() {
+ return BlankFormatImpl.INSTANCE;
+ }
+
@@ -91,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return an un-styled number format
+ */
+ static @NotNull StyledFormat noStyle() {
+ static StyledFormat noStyle() {
+ return StyledFormatImpl.NO_STYLE;
+ }
+
@@ -101,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param style the style to apply on the number
+ * @return a styled number format
+ */
+ static @NotNull StyledFormat styled(final @NotNull Style style) {
+ static StyledFormat styled(final Style style) {
+ return new StyledFormatImpl(style);
+ }
+
@@ -111,7 +114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param styleBuilderApplicables the style to apply on the number
+ * @return a styled number format
+ */
+ static @NotNull StyledFormat styled(final @NotNull StyleBuilderApplicable @NotNull... styleBuilderApplicables) {
+ static StyledFormat styled(final StyleBuilderApplicable... styleBuilderApplicables) {
+ return styled(Style.style(styleBuilderApplicables));
+ }
+
@@ -121,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param component the component to replace the number with
+ * @return a fixed number format
+ */
+ static @NotNull FixedFormat fixed(final @NotNull ComponentLike component) {
+ static FixedFormat fixed(final ComponentLike component) {
+ return new FixedFormatImpl(component.asComponent());
+ }
+}
@@ -135,11 +138,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import net.kyori.adventure.text.format.Style;
+import net.kyori.adventure.text.format.StyleBuilderApplicable;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A scoreboard number format that applies a custom formatting to the score number.
+ */
+@NullMarked
+public interface StyledFormat extends NumberFormat, StyleBuilderApplicable {
+
+ /**
@@ -147,7 +151,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the style to apply
+ */
+ @NotNull Style style();
+ Style style();
+
+}
diff --git a/src/main/java/io/papermc/paper/scoreboard/numbers/StyledFormatImpl.java b/src/main/java/io/papermc/paper/scoreboard/numbers/StyledFormatImpl.java
@@ -159,13 +163,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package io.papermc.paper.scoreboard.numbers;
+
+import net.kyori.adventure.text.format.Style;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+record StyledFormatImpl(@NotNull Style style) implements StyledFormat {
+@NullMarked
+record StyledFormatImpl(Style style) implements StyledFormat {
+ static final StyledFormat NO_STYLE = new StyledFormatImpl(Style.empty());
+
+ @Override
+ public void styleApply(final Style.@NotNull Builder style) {
+ public void styleApply(final Style.Builder style) {
+ style.merge(this.style);
+ }
+}