From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 4 Jul 2023 11:27:18 -0700 Subject: [PATCH] Fix BanList API diff --git a/src/main/java/org/bukkit/BanList.java b/src/main/java/org/bukkit/BanList.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/BanList.java +++ b/src/main/java/org/bukkit/BanList.java @@ -0,0 +0,0 @@ public interface BanList { */ @Deprecated @Nullable - public BanEntry getBanEntry(@NotNull String target); + public > E getBanEntry(@NotNull String target); // Paper /** * Gets a {@link BanEntry} by target. @@ -0,0 +0,0 @@ public interface BanList { */ @Deprecated @Nullable - public BanEntry addBan(@NotNull String target, @Nullable String reason, @Nullable Date expires, @Nullable String source); + public > E addBan(@NotNull String target, @Nullable String reason, @Nullable Date expires, @Nullable String source); // Paper /** * Adds a ban to this list. If a previous ban exists, this will @@ -0,0 +0,0 @@ public interface BanList { * @return an immutable set containing every entry tracked by this list */ @NotNull - public Set> getEntries(); + public > Set getEntries(); // Paper /** * Gets if a {@link BanEntry} exists for the target, indicating an active diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/OfflinePlayer.java +++ b/src/main/java/org/bukkit/OfflinePlayer.java @@ -0,0 +0,0 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio * (updated) previous ban */ @Nullable - public BanEntry ban(@Nullable String reason, @Nullable Date expires, @Nullable String source); + public > E ban(@Nullable String reason, @Nullable Date expires, @Nullable String source); // Paper - fix ban list API /** * Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will @@ -0,0 +0,0 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio * (updated) previous ban */ @Nullable - public BanEntry ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source); + public > E ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source); // Paper - fix ban list API /** * Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will @@ -0,0 +0,0 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio * (updated) previous ban */ @Nullable - public BanEntry ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source); + public > E ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source); // Paper - fix ban list API /** * Checks if this player is whitelisted or not diff --git a/src/main/java/org/bukkit/ban/ProfileBanList.java b/src/main/java/org/bukkit/ban/ProfileBanList.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/ban/ProfileBanList.java +++ b/src/main/java/org/bukkit/ban/ProfileBanList.java @@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; /** * A {@link BanList} targeting player profile bans. */ -public interface ProfileBanList extends BanList { +public interface ProfileBanList extends BanList { // Paper /** * {@inheritDoc} @@ -0,0 +0,0 @@ public interface ProfileBanList extends BanList { * @return the entry for the newly created ban, or the entry for the * (updated) previous ban * @throws IllegalArgumentException if ProfilePlayer has an invalid UUID + * @deprecated use {@link #addBan(com.destroystokyo.paper.profile.PlayerProfile, String, Date, String)} */ @Nullable - public BanEntry addBan(@NotNull PlayerProfile target, @Nullable String reason, @Nullable Date expires, @Nullable String source); + // Paper start + @Deprecated + public > E addBan(@NotNull PlayerProfile target, @Nullable String reason, @Nullable Date expires, @Nullable String source); + /** + * @throws IllegalArgumentException if ProfilePlayer has an invalid UUID + */ + @Nullable BanEntry addBan(com.destroystokyo.paper.profile.@NotNull PlayerProfile target, @Nullable String reason, @Nullable Date expires, @Nullable String source); + + // the 5 methods below are added to maintain compat for the bukkit.PlayerProfile parameter type + /** + * @deprecated use {@link #getBanEntry(Object)} + */ + @Deprecated + @Nullable > E getBanEntry(@NotNull PlayerProfile target); + + /** + * @deprecated use {@link #isBanned(Object)} + */ + @Deprecated + boolean isBanned(@NotNull PlayerProfile target); + + /** + * @deprecated use {@link #pardon(Object)} + */ + @Deprecated + void pardon(@NotNull PlayerProfile target); + + /** + * @deprecated use {@link #addBan(Object, String, java.time.Instant, String)} + */ + @Deprecated + @Nullable > E addBan(@NotNull PlayerProfile target, @Nullable String reason, @Nullable java.time.Instant expires, @Nullable String source); + + /** + * @deprecated use {@link #addBan(Object, String, java.time.Duration, String)} + */ + @Deprecated + @Nullable > E addBan(@NotNull PlayerProfile target, @Nullable String reason, @Nullable java.time.Duration duration, @Nullable String source); + + // Paper end } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * (updated) previous ban */ @Nullable - public BanEntry ban(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer); + public > E ban(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer); // Paper - fix ban list API /** * Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * (updated) previous ban */ @Nullable - public BanEntry ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source, boolean kickPlayer); + public > E ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source, boolean kickPlayer); // Paper - fix ban list API /** * Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * (updated) previous ban */ @Nullable - public BanEntry ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source, boolean kickPlayer); + public > E ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source, boolean kickPlayer); // Paper - fix ban list API /** * Adds this user's current IP address to the {@link IpBanList}. If a previous ban exists, this will