Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic 2024-09-29 16:48:34 -07:00
parent fa97c59a4e
commit 29a25df60e
78 changed files with 757 additions and 883 deletions

View file

@ -43,24 +43,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import java.util.Set;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+import java.util.Set;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired once a profiles additional properties (such as textures) has been filled
+ */
+@NullMarked
+public class FillProfileEvent extends Event {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final PlayerProfile profile;
+ private final PlayerProfile profile;
+
+ @ApiStatus.Internal
+ public FillProfileEvent(@NotNull PlayerProfile profile) {
+ public FillProfileEvent(final PlayerProfile profile) {
+ super(!org.bukkit.Bukkit.isPrimaryThread());
+ this.profile = profile;
+ }
@ -68,7 +68,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @return The Profile that had properties filled
+ */
+ @NotNull
+ public PlayerProfile getPlayerProfile() {
+ return this.profile;
+ }
@ -76,21 +75,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * Same as .getPlayerProfile().getProperties()
+ *
+ * @see PlayerProfile#getProperties()
+ * @return The new properties on the profile.
+ * @see PlayerProfile#getProperties()
+ */
+ @NotNull
+ public Set<ProfileProperty> getProperties() {
+ return this.profile.getProperties();
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
@ -128,26 +124,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import java.util.Collection;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+import java.util.Collection;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Fired when the server is requesting to fill in properties of an incomplete profile, such as textures.
+ * <p>
+ * Allows plugins to pre-populate cached properties and avoid a call to the Mojang API
+ */
+@NullMarked
+public class PreFillProfileEvent extends Event {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final PlayerProfile profile;
+ private final PlayerProfile profile;
+
+ @ApiStatus.Internal
+ public PreFillProfileEvent(@NotNull PlayerProfile profile) {
+ public PreFillProfileEvent(final PlayerProfile profile) {
+ super(!org.bukkit.Bukkit.isPrimaryThread());
+ this.profile = profile;
+ }
@ -155,7 +151,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * @return The profile that needs its properties filled
+ */
+ @NotNull
+ public PlayerProfile getPlayerProfile() {
+ return this.profile;
+ }
@ -163,21 +158,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * Sets the properties on the profile, avoiding the call to the Mojang API
+ * Same as .getPlayerProfile().setProperties(properties);
+ *
+ * @see PlayerProfile#setProperties(Collection)
+ *
+ * @param properties The properties to set/append
+ * @see PlayerProfile#setProperties(Collection)
+ */
+ public void setProperties(@NotNull Collection<ProfileProperty> properties) {
+ public void setProperties(final Collection<ProfileProperty> properties) {
+ this.profile.setProperties(properties);
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }