SPIGOT-6455, SPIGOT-7030, #750: Improve ban API

By: Doc <nachito94@msn.com>
This commit is contained in:
Bukkit/Spigot
2023-07-01 13:55:59 +10:00
parent ea46ef7a62
commit ba835793ed
9 changed files with 238 additions and 19 deletions

View File

@@ -2,7 +2,9 @@ package org.bukkit.entity;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import org.bukkit.BanEntry;
import org.bukkit.DyeColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
@@ -19,6 +21,8 @@ import org.bukkit.WeatherType;
import org.bukkit.WorldBorder;
import org.bukkit.advancement.Advancement;
import org.bukkit.advancement.AdvancementProgress;
import org.bukkit.ban.IpBanList;
import org.bukkit.ban.ProfileBanList;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
@@ -35,6 +39,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapView;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.profile.PlayerProfile;
import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -169,6 +174,38 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/
public void kickPlayer(@Nullable String message);
/**
* Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will
* update the entry.
*
* @param reason reason for the ban, null indicates implementation default
* @param expires date for the ban's expiration (unban), or null to imply
* forever
* @param source source of the ban, null indicates implementation default
* @param kickPlayer if the player need to be kick
*
* @return the entry for the newly created ban, or the entry for the
* (updated) previous ban
*/
@Nullable
public BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer);
/**
* Adds this user's current IP address to the {@link IpBanList}. If a previous ban exists, this will
* update the entry. If {@link #getAddress()} is null this method will throw an exception.
*
* @param reason reason for the ban, null indicates implementation default
* @param expires date for the ban's expiration (unban), or null to imply
* forever
* @param source source of the ban, null indicates implementation default
* @param kickPlayer if the player need to be kick
*
* @return the entry for the newly created ban, or the entry for the
* (updated) previous ban
*/
@Nullable
public BanEntry<InetSocketAddress> banIp(@Nullable String reason, @Nullable Date expires, @Nullable String source, boolean kickPlayer);
/**
* Says a message (or runs a command).
*