#884: Refinements to new ban API for improved compatibility and correctness

By: Doc <nachito94@msn.com>
This commit is contained in:
Bukkit/Spigot 2023-07-04 06:50:33 +10:00
parent ba835793ed
commit cc8a890979
5 changed files with 25 additions and 14 deletions

View File

@ -86,13 +86,23 @@ public interface BanList<T> {
@Nullable
public BanEntry<T> addBan(@NotNull T target, @Nullable String reason, @Nullable Date expires, @Nullable String source);
/**
* Gets a set containing every {@link BanEntry} in this list.
*
* @return an immutable set containing every entry tracked by this list
* @deprecated This return a generic class, prefer use {@link #getEntries()}
*/
@Deprecated
@NotNull
public Set<BanEntry> getBanEntries();
/**
* Gets a set containing every {@link BanEntry} in this list.
*
* @return an immutable set containing every entry tracked by this list
*/
@NotNull
public Set<BanEntry<T>> getBanEntries();
public Set<BanEntry<T>> getEntries();
/**
* Gets if a {@link BanEntry} exists for the target, indicating an active

View File

@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.net.InetAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@ -1208,7 +1208,7 @@ public final class Bukkit {
*
* @param address the IP address to ban
*
* @deprecated see {@link #banIP(InetSocketAddress)}
* @deprecated see {@link #banIP(InetAddress)}
*/
@Deprecated
public static void banIP(@NotNull String address) {
@ -1220,7 +1220,7 @@ public final class Bukkit {
*
* @param address the IP address to unban
*
* @deprecated see {@link #unbanIP(InetSocketAddress)}
* @deprecated see {@link #unbanIP(InetAddress)}
*/
@Deprecated
public static void unbanIP(@NotNull String address) {
@ -1232,7 +1232,7 @@ public final class Bukkit {
*
* @param address the IP address to ban
*/
public static void banIP(@NotNull InetSocketAddress address) {
public static void banIP(@NotNull InetAddress address) {
server.banIP(address);
}
@ -1241,7 +1241,7 @@ public final class Bukkit {
*
* @param address the IP address to unban
*/
public static void unbanIP(@NotNull InetSocketAddress address) {
public static void unbanIP(@NotNull InetAddress address) {
server.unbanIP(address);
}

View File

@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.net.InetAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@ -1028,7 +1028,7 @@ public interface Server extends PluginMessageRecipient {
*
* @param address the IP address to ban
*
* @deprecated see {@link #banIP(InetSocketAddress)}
* @deprecated see {@link #banIP(InetAddress)}
*/
@Deprecated
public void banIP(@NotNull String address);
@ -1038,7 +1038,7 @@ public interface Server extends PluginMessageRecipient {
*
* @param address the IP address to unban
*
* @deprecated see {@link #unbanIP(InetSocketAddress)}
* @deprecated see {@link #unbanIP(InetAddress)}
*/
@Deprecated
public void unbanIP(@NotNull String address);
@ -1048,14 +1048,14 @@ public interface Server extends PluginMessageRecipient {
*
* @param address the IP address to ban
*/
public void banIP(@NotNull InetSocketAddress address);
public void banIP(@NotNull InetAddress address);
/**
* Unbans the specified address from the server.
*
* @param address the IP address to unban
*/
public void unbanIP(@NotNull InetSocketAddress address);
public void unbanIP(@NotNull InetAddress address);
/**
* Gets a set containing all banned players.

View File

@ -1,11 +1,11 @@
package org.bukkit.ban;
import java.net.InetSocketAddress;
import java.net.InetAddress;
import org.bukkit.BanList;
/**
* A {@link BanList} targeting IP bans.
*/
public interface IpBanList extends BanList<InetSocketAddress> {
public interface IpBanList extends BanList<InetAddress> {
}

View File

@ -1,5 +1,6 @@
package org.bukkit.entity;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Date;
@ -204,7 +205,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* (updated) previous ban
*/
@Nullable
public BanEntry<InetSocketAddress> banIp(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer);
public BanEntry<InetAddress> banIp(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer);
/**
* Says a message (or runs a command).