Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic 2024-09-29 16:48:34 -07:00
parent ea00be3aaa
commit ba3c29b92e
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
82 changed files with 977 additions and 1103 deletions

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Add villager reputation API
diff --git a/src/main/java/com/destroystokyo/paper/entity/villager/Reputation.java b/src/main/java/com/destroystokyo/paper/entity/villager/Reputation.java
new file mode 100644
index 0000000000000000000000000000000000000000..0a69e21b0b3001c9cc50951b4b8bd593f6fa74be
index 0000000000000000000000000000000000000000..f16294ef3148f8671389fa097e3e369a046e48cf
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/villager/Reputation.java
@@ -0,0 +1,57 @@
@@ -0,0 +1,58 @@
+package com.destroystokyo.paper.entity.villager;
+
+import com.google.common.base.Preconditions;
@ -17,20 +17,21 @@ index 0000000000000000000000000000000000000000..0a69e21b0b3001c9cc50951b4b8bd593
+import java.util.EnumMap;
+import java.util.Map;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A reputation score for a player on a villager.
+ */
+@NullMarked
+public final class Reputation {
+
+ @NotNull
+ private final Map<ReputationType, Integer> reputation;
+
+ public Reputation() {
+ this(new EnumMap<>(ReputationType.class));
+ }
+
+ public Reputation(@NotNull Map<ReputationType, Integer> reputation) {
+ public Reputation(Map<ReputationType, Integer> reputation) {
+ Preconditions.checkNotNull(reputation, "reputation cannot be null");
+ this.reputation = reputation;
+ }
@ -41,7 +42,7 @@ index 0000000000000000000000000000000000000000..0a69e21b0b3001c9cc50951b4b8bd593
+ * @param type The {@link ReputationType type} of reputation to get.
+ * @return The value of the {@link ReputationType type}.
+ */
+ public int getReputation(@NotNull ReputationType type) {
+ public int getReputation(ReputationType type) {
+ Preconditions.checkNotNull(type, "the reputation type cannot be null");
+ return this.reputation.getOrDefault(type, 0);
+ }
@ -52,7 +53,7 @@ index 0000000000000000000000000000000000000000..0a69e21b0b3001c9cc50951b4b8bd593
+ * @param type The {@link ReputationType type} of reputation to set.
+ * @param value The value of the {@link ReputationType type}.
+ */
+ public void setReputation(@NotNull ReputationType type, int value) {
+ public void setReputation(ReputationType type, int value) {
+ Preconditions.checkNotNull(type, "the reputation type cannot be null");
+ this.reputation.put(type, value);
+ }
@ -63,7 +64,7 @@ index 0000000000000000000000000000000000000000..0a69e21b0b3001c9cc50951b4b8bd593
+ * @param type The {@link ReputationType type} to check
+ * @return If there is a value for this {@link ReputationType type} set.
+ */
+ public boolean hasReputationSet(@NotNull ReputationType type) {
+ public boolean hasReputationSet(ReputationType type) {
+ return this.reputation.containsKey(type);
+ }
+}