improve BanList types (#10239)

This commit is contained in:
Yannick Lamprecht
2024-03-03 21:36:17 +01:00
parent 715e4018a4
commit 29009b5f04
2 changed files with 163 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yannick Lamprecht <yannicklamprecht@live.de>
Date: Sat, 10 Feb 2024 20:50:01 +0100
Subject: [PATCH] improve BanList types
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
};
}
+ // Paper start - add BanListType (which has a generic)
+ @SuppressWarnings("unchecked")
+ @Override
+ public <B extends BanList<E>, E> B getBanList(final io.papermc.paper.ban.BanListType<B> type) {
+ Preconditions.checkArgument(type != null, "BanList.BanType cannot be null");
+ if (type == io.papermc.paper.ban.BanListType.IP) {
+ return (B) new CraftIpBanList(this.playerList.getIpBans());
+ } else if (type == io.papermc.paper.ban.BanListType.PROFILE) {
+ return (B) new CraftProfileBanList(this.playerList.getBans());
+ } else {
+ throw new IllegalArgumentException("Unknown BanListType: " + type);
+ }
+ }
+ // Paper end - add BanListType (which has a generic)
+
@Override
public void setWhitelist(boolean value) {
this.playerList.setUsingWhiteList(value);