improve BanList types
This commit is contained in:
@@ -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> {
|
||||
}
|
||||
Reference in New Issue
Block a user