Deprecate extra ban methods with raw BanEntry (#9580)

This commit is contained in:
Jake Potrebic 2024-03-03 12:54:52 -08:00
parent 0c2d5b9b74
commit a2a55e2b27

View file

@ -16,14 +16,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
*/
public boolean isBanned();
+ // Paper start
+
+ /**
+ * Permanently Bans this player from the server
+ *
+ * @param reason Reason for Ban
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)}
+ */
+ @NotNull
+ @Deprecated
+ public default BanEntry banPlayer(@Nullable String reason) {
+ return banPlayer(reason, null, null);
+ }
@ -33,8 +34,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for Ban
+ * @param source Source of the ban, or null for default
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)}
+ */
+ @NotNull
+ @Deprecated
+ public default BanEntry banPlayer(@Nullable String reason, @Nullable String source) {
+ return banPlayer(reason, null, source);
+ }
@ -44,8 +47,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)}
+ */
+ @NotNull
+ @Deprecated
+ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.Date expires) {
+ return banPlayer(reason, expires, null);
+ }
@ -56,12 +61,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param expires When to expire the ban
+ * @param source Source of the ban or null for default
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)}
+ */
+ @NotNull
+ @Deprecated
+ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source) {
+ return banPlayer(reason, expires, source, true);
+ }
+
+ /**
+ * @deprecated use {@link #ban(String, Date, String)}
+ */
+ @NotNull
+ @Deprecated
+ public default BanEntry banPlayer(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source, boolean kickIfOnline) {
+ BanEntry banEntry = Bukkit.getServer().getBanList(BanList.Type.NAME).addBan(getName(), reason, expires, source);
+ if (kickIfOnline && isOnline()) {
@ -86,9 +98,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param reason Reason for ban
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ // For reference, Bukkit defines this as nullable, while they impl isn't, we'll follow API.
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerFull(@Nullable String reason) {
+ return banPlayerFull(reason, null, null);
+ }
@ -99,8 +113,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for ban
+ * @param source Source of ban, or null for default
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerFull(@Nullable String reason, @Nullable String source) {
+ return banPlayerFull(reason, null, source);
+ }
@ -111,8 +127,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerFull(@Nullable String reason, @Nullable java.util.Date expires) {
+ return banPlayerFull(reason, expires, null);
+ }
@ -124,8 +142,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param expires When to expire the ban
+ * @param source Source of the ban, or null for default
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerFull(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source) {
+ banPlayer(reason, expires, source);
+ return banPlayerIP(reason, expires, source, true);
@ -138,8 +158,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for ban
+ * @param kickPlayer Whether or not to kick the player afterwards
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, boolean kickPlayer) {
+ return banPlayerIP(reason, null, null, kickPlayer);
+ }
@ -151,8 +173,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param source Source of ban, or null for default
+ * @param kickPlayer Whether or not to kick the player afterwards
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, @Nullable String source, boolean kickPlayer) {
+ return banPlayerIP(reason, null, source, kickPlayer);
+ }
@ -164,8 +188,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param expires When to expire the ban
+ * @param kickPlayer Whether or not to kick the player afterwards
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, @Nullable java.util.Date expires, boolean kickPlayer) {
+ return banPlayerIP(reason, expires, null, kickPlayer);
+ }
@ -176,8 +202,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param reason Reason for ban
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason) {
+ return banPlayerIP(reason, null, null);
+ }
@ -188,8 +216,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for ban
+ * @param source Source of ban, or null for default
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, @Nullable String source) {
+ return banPlayerIP(reason, null, source);
+ }
@ -200,8 +230,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, @Nullable java.util.Date expires) {
+ return banPlayerIP(reason, expires, null);
+ }
@ -213,8 +245,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param expires When to expire the ban
+ * @param source Source of the ban or null for default
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source) {
+ return banPlayerIP(reason, expires, source, true);
+ }
@ -227,8 +261,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param source Source of the ban or null for default
+ * @param kickPlayer if the targeted player should be kicked
+ * @return Ban Entry
+ * @deprecated use {@link #ban(String, Date, String)} and {@link #banIp(String, Date, String, boolean)}
+ */
+ @Nullable
+ @Deprecated
+ public default org.bukkit.BanEntry banPlayerIP(@Nullable String reason, @Nullable java.util.Date expires, @Nullable String source, boolean kickPlayer) {
+ org.bukkit.BanEntry banEntry = org.bukkit.Bukkit.getServer().getBanList(org.bukkit.BanList.Type.IP).addBan(getAddress().getAddress().getHostAddress(), reason, expires, source);
+ if (kickPlayer && isOnline()) {