geforkt von Mirrors/Paper
improve BanList types
Dieser Commit ist enthalten in:
Ursprung
3ebc5bb92c
Commit
3073742fd7
30
paper-api/src/main/java/io/papermc/paper/ban/BanListType.java
Normale Datei
30
paper-api/src/main/java/io/papermc/paper/ban/BanListType.java
Normale Datei
@ -0,0 +1,30 @@
|
|||||||
|
package io.papermc.paper.ban;
|
||||||
|
|
||||||
|
import org.bukkit.BanList;
|
||||||
|
import org.bukkit.ban.IpBanList;
|
||||||
|
import org.bukkit.ban.ProfileBanList;
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a ban-type that a {@link BanList} may track.
|
||||||
|
* It enforces the correct return value at compile time.
|
||||||
|
*/
|
||||||
|
@NullMarked
|
||||||
|
public interface BanListType<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Banned IP addresses
|
||||||
|
*/
|
||||||
|
BanListType<IpBanList> IP = new BanListTypeImpl<>(IpBanList.class);
|
||||||
|
/**
|
||||||
|
* Banned player profiles
|
||||||
|
*/
|
||||||
|
BanListType<ProfileBanList> PROFILE = new BanListTypeImpl<>(ProfileBanList.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type class of the ban list used generically
|
||||||
|
*
|
||||||
|
* @return the type class
|
||||||
|
*/
|
||||||
|
Class<T> typeClass();
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.papermc.paper.ban;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
@NullMarked
|
||||||
|
record BanListTypeImpl<T>(Class<T> typeClass) implements BanListType<T> {
|
||||||
|
}
|
@ -16,7 +16,9 @@ public interface BanList<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a ban-type that a {@link BanList} may track.
|
* Represents a ban-type that a {@link BanList} may track.
|
||||||
|
* @deprecated use {@link io.papermc.paper.ban.BanListType} to enforce the correct return value at compile time.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since = "1.20.4") // Paper - BanList Type Improvements
|
||||||
public enum Type {
|
public enum Type {
|
||||||
/**
|
/**
|
||||||
* Banned player names
|
* Banned player names
|
||||||
|
@ -1663,11 +1663,27 @@ public final class Bukkit {
|
|||||||
* @param <T> The ban target
|
* @param <T> The ban target
|
||||||
*
|
*
|
||||||
* @return a ban list of the specified type
|
* @return a ban list of the specified type
|
||||||
|
* @deprecated use {@link #getBanList(io.papermc.paper.ban.BanListType)} to enforce the correct return value at compile time.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Deprecated(since = "1.20.4") // Paper - add BanListType (which has a generic)
|
||||||
public static <T extends BanList<?>> T getBanList(@NotNull BanList.Type type) {
|
public static <T extends BanList<?>> T getBanList(@NotNull BanList.Type type) {
|
||||||
return server.getBanList(type);
|
return server.getBanList(type);
|
||||||
}
|
}
|
||||||
|
// Paper start - add BanListType (which has a generic)
|
||||||
|
/**
|
||||||
|
* Gets a ban list for the supplied type.
|
||||||
|
*
|
||||||
|
* @param type the type of list to fetch, cannot be null
|
||||||
|
* @param <B> The ban target
|
||||||
|
*
|
||||||
|
* @return a ban list of the specified type
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static <B extends BanList<E>, E> B getBanList(final io.papermc.paper.ban.@NotNull BanListType<B> type) {
|
||||||
|
return server.getBanList(type);
|
||||||
|
}
|
||||||
|
// Paper end - add BanListType (which has a generic)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set containing all player operators.
|
* Gets a set containing all player operators.
|
||||||
|
@ -1425,10 +1425,25 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|||||||
* @param <T> The ban target
|
* @param <T> The ban target
|
||||||
*
|
*
|
||||||
* @return a ban list of the specified type
|
* @return a ban list of the specified type
|
||||||
|
* @deprecated use {@link #getBanList(io.papermc.paper.ban.BanListType)} to enforce the correct return value at compile time.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated // Paper - add BanListType (which has a generic)
|
||||||
@NotNull
|
@NotNull
|
||||||
public <T extends BanList<?>> T getBanList(@NotNull BanList.Type type);
|
public <T extends BanList<?>> T getBanList(@NotNull BanList.Type type);
|
||||||
|
|
||||||
|
// Paper start - add BanListType (which has a generic)
|
||||||
|
/**
|
||||||
|
* Gets a ban list for the supplied type.
|
||||||
|
*
|
||||||
|
* @param type the type of list to fetch, cannot be null
|
||||||
|
* @param <B> The ban target
|
||||||
|
*
|
||||||
|
* @return a ban list of the specified type
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
<B extends BanList<E>, E> B getBanList(@NotNull io.papermc.paper.ban.BanListType<B> type);
|
||||||
|
// Paper end - add BanListType (which has a generic)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set containing all player operators.
|
* Gets a set containing all player operators.
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren