Skip to content

Commit

Permalink
Switch to jspecify annotations for OfflinePlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Jan 28, 2025
1 parent 2c9faae commit dbc383a
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions paper-api/src/main/java/org/bukkit/OfflinePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
import org.bukkit.entity.Player;
import org.bukkit.permissions.ServerOperator;
import org.bukkit.profile.PlayerProfile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Represents a reference to a player identity and the data belonging to a
* player that is stored on the disk and can, thus, be retrieved without the
* player needing to be online.
*/
@NullMarked
public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, io.papermc.paper.persistence.PersistentDataViewHolder { // Paper - Add Offline PDC API

/**
Expand Down Expand Up @@ -62,7 +63,6 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
* @return Player UUID
*/
@Override
@NotNull
public UUID getUniqueId();

/**
Expand All @@ -74,7 +74,6 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return the player's profile
*/
@NotNull
com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile(); // Paper

/**
Expand All @@ -91,7 +90,6 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
* @return Ban Entry
* @deprecated use {@link #ban(String, Date, String)}
*/
@NotNull
@Deprecated(since = "1.20.4")
public default BanEntry banPlayer(@Nullable String reason) {
return banPlayer(reason, null, null);
Expand All @@ -104,7 +102,6 @@ public default BanEntry banPlayer(@Nullable String reason) {
* @return Ban Entry
* @deprecated use {@link #ban(String, Date, String)}
*/
@NotNull
@Deprecated(since = "1.20.4")
public default BanEntry banPlayer(@Nullable String reason, @Nullable String source) {
return banPlayer(reason, null, source);
Expand All @@ -117,9 +114,8 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable String sour
* @return Ban Entry
* @deprecated use {@link #ban(String, Date, String)}
*/
@NotNull
@Deprecated(since = "1.20.4")
public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.Date expires) {
public default BanEntry banPlayer(@Nullable String reason, java.util.@Nullable Date expires) {
return banPlayer(reason, expires, null);
}

Expand All @@ -131,18 +127,16 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @return Ban Entry
* @deprecated use {@link #ban(String, Date, String)}
*/
@NotNull
@Deprecated(since = "1.20.4")
public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source) {
public default BanEntry banPlayer(@Nullable String reason, java.util.@Nullable Date expires, @Nullable String source) {
return banPlayer(reason, expires, source, true);
}

/**
* @deprecated use {@link #ban(String, Date, String)}
*/
@NotNull
@Deprecated(since = "1.20.4")
public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source, boolean kickIfOnline) {
public default BanEntry banPlayer(@Nullable String reason, java.util.@Nullable Date expires, @Nullable String source, boolean kickIfOnline) {
BanEntry banEntry = Bukkit.getServer().getBanList(BanList.Type.NAME).addBan(getName(), reason, expires, source);
if (kickIfOnline && isOnline()) {
getPlayer().kickPlayer(reason);
Expand Down Expand Up @@ -309,7 +303,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the statistic requires an
* additional parameter
*/
public void incrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException;
public void incrementStatistic(Statistic statistic) throws IllegalArgumentException;

/**
* Decrements the given statistic for this player.
Expand All @@ -322,7 +316,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the statistic requires an
* additional parameter
*/
public void decrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException;
public void decrementStatistic(Statistic statistic) throws IllegalArgumentException;

/**
* Increments the given statistic for this player.
Expand All @@ -334,7 +328,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the statistic requires an
* additional parameter
*/
public void incrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException;
public void incrementStatistic(Statistic statistic, int amount) throws IllegalArgumentException;

/**
* Decrements the given statistic for this player.
Expand All @@ -346,7 +340,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the statistic requires an
* additional parameter
*/
public void decrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException;
public void decrementStatistic(Statistic statistic, int amount) throws IllegalArgumentException;

/**
* Sets the given statistic for this player.
Expand All @@ -358,7 +352,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the statistic requires an
* additional parameter
*/
public void setStatistic(@NotNull Statistic statistic, int newValue) throws IllegalArgumentException;
public void setStatistic(Statistic statistic, int newValue) throws IllegalArgumentException;

/**
* Gets the value of the given statistic for this player.
Expand All @@ -369,7 +363,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the statistic requires an
* additional parameter
*/
public int getStatistic(@NotNull Statistic statistic) throws IllegalArgumentException;
public int getStatistic(Statistic statistic) throws IllegalArgumentException;

/**
* Increments the given statistic for this player for the given material.
Expand All @@ -384,7 +378,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException;
public void incrementStatistic(Statistic statistic, Material material) throws IllegalArgumentException;

/**
* Decrements the given statistic for this player for the given material.
Expand All @@ -399,7 +393,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException;
public void decrementStatistic(Statistic statistic, Material material) throws IllegalArgumentException;

/**
* Gets the value of the given statistic for this player.
Expand All @@ -412,7 +406,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public int getStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException;
public int getStatistic(Statistic statistic, Material material) throws IllegalArgumentException;

/**
* Increments the given statistic for this player for the given material.
Expand All @@ -426,7 +420,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException;
public void incrementStatistic(Statistic statistic, Material material, int amount) throws IllegalArgumentException;

/**
* Decrements the given statistic for this player for the given material.
Expand All @@ -440,7 +434,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException;
public void decrementStatistic(Statistic statistic, Material material, int amount) throws IllegalArgumentException;

/**
* Sets the given statistic for this player for the given material.
Expand All @@ -454,7 +448,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int newValue) throws IllegalArgumentException;
public void setStatistic(Statistic statistic, Material material, int newValue) throws IllegalArgumentException;

/**
* Increments the given statistic for this player for the given entity.
Expand All @@ -469,7 +463,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException;
public void incrementStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException;

/**
* Decrements the given statistic for this player for the given entity.
Expand All @@ -484,7 +478,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException;
public void decrementStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException;

/**
* Gets the value of the given statistic for this player.
Expand All @@ -497,7 +491,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException;
public int getStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException;

/**
* Increments the given statistic for this player for the given entity.
Expand All @@ -511,7 +505,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) throws IllegalArgumentException;
public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) throws IllegalArgumentException;

/**
* Decrements the given statistic for this player for the given entity.
Expand All @@ -525,7 +519,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount);
public void decrementStatistic(Statistic statistic, EntityType entityType, int amount);

/**
* Sets the given statistic for this player for the given entity.
Expand All @@ -539,7 +533,7 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @throws IllegalArgumentException if the given parameter is not valid
* for the statistic
*/
public void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue);
public void setStatistic(Statistic statistic, EntityType entityType, int newValue);

/**
* Gets the player's last death location.
Expand Down Expand Up @@ -571,6 +565,6 @@ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.D
* @see io.papermc.paper.persistence.PersistentDataViewHolder#getPersistentDataContainer()
*/
@Override
io.papermc.paper.persistence.@NotNull PersistentDataContainerView getPersistentDataContainer();
io.papermc.paper.persistence.PersistentDataContainerView getPersistentDataContainer();
// Paper end - add pdc to offline player
}

0 comments on commit dbc383a

Please sign in to comment.