aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0420-Fix-BanList-API.patch
blob: f0ff82bd87e344c0e342da26e4bbbe3d998a4a77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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 548f6d28c28d74bed8b58ee82875909354afe132..a77c0411a68a9bad33ddfb335b7a996a843e478c 100644
--- a/src/main/java/org/bukkit/BanList.java
+++ b/src/main/java/org/bukkit/BanList.java
@@ -48,7 +48,7 @@ public interface BanList<T> {
      */
     @Deprecated
     @Nullable
-    public BanEntry<T> getBanEntry(@NotNull String target);
+    public <E extends BanEntry<? super T>> E getBanEntry(@NotNull String target); // Paper
 
     /**
      * Gets a {@link BanEntry} by target.
@@ -77,7 +77,7 @@ public interface BanList<T> {
      */
     @Deprecated
     @Nullable
-    public BanEntry<T> addBan(@NotNull String target, @Nullable String reason, @Nullable Date expires, @Nullable String source);
+    public <E extends BanEntry<? super T>> 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
@@ -140,7 +140,7 @@ public interface BanList<T> {
      * @return an immutable set containing every entry tracked by this list
      */
     @NotNull
-    public Set<BanEntry<T>> getEntries();
+    public <E extends BanEntry<? super T>> Set<E> 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 774f9ec6a57d5d16a74ebe998e9ad800b1828029..9b84cb5abdf3db55cbc7ba19c8cd6955bf4fc5ec 100644
--- a/src/main/java/org/bukkit/OfflinePlayer.java
+++ b/src/main/java/org/bukkit/OfflinePlayer.java
@@ -135,7 +135,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
      *     (updated) previous ban
      */
     @Nullable
-    public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Date expires, @Nullable String source);
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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
@@ -149,7 +149,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
      *     (updated) previous ban
      */
     @Nullable
-    public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source);
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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
@@ -163,7 +163,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
      *     (updated) previous ban
      */
     @Nullable
-    public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source);
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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 e805e629cede1c4c0674282c930cb67852718c3e..5248cf08ef83c7304dd76c42a2f646bb81e0efae 100644
--- a/src/main/java/org/bukkit/ban/ProfileBanList.java
+++ b/src/main/java/org/bukkit/ban/ProfileBanList.java
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
 /**
  * A {@link BanList} targeting player profile bans.
  */
-public interface ProfileBanList extends BanList<PlayerProfile> {
+public interface ProfileBanList extends BanList<com.destroystokyo.paper.profile.PlayerProfile> { // Paper
 
     /**
      * {@inheritDoc}
@@ -23,8 +23,48 @@ public interface ProfileBanList extends BanList<PlayerProfile> {
      * @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<PlayerProfile> addBan(@NotNull PlayerProfile target, @Nullable String reason, @Nullable Date expires, @Nullable String source);
+    // Paper start
+    @Deprecated
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> E addBan(@NotNull PlayerProfile target, @Nullable String reason, @Nullable Date expires, @Nullable String source);
 
+    /**
+     * @throws IllegalArgumentException if ProfilePlayer has an invalid UUID
+     */
+    @Nullable BanEntry<com.destroystokyo.paper.profile.PlayerProfile> 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 extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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 extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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 extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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 1c25bdb3479da2d6e43782503c48e8ebda275e96..920424ba408730e63c0e42d24e327fb02c82c61c 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -298,7 +298,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
      *     (updated) previous ban
      */
     @Nullable
-    public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer);
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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
@@ -314,7 +314,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
      *     (updated) previous ban
      */
     @Nullable
-    public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source, boolean kickPlayer);
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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
@@ -330,7 +330,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
      *     (updated) previous ban
      */
     @Nullable
-    public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source, boolean kickPlayer);
+    public <E extends BanEntry<? super com.destroystokyo.paper.profile.PlayerProfile>> 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