Add banning API and resolve associated command issues. Adds BUKKIT-3535.

Fixes BUKKIT-5371 and BUKKIT-4285

Prior to this commit, ban reasons were not supported by banning commands.
Additionally, the player(s) affected by the ban-ip command would not have
been removed from the server via a kick.

The Bukkit API lacked support for modifying various attributes associated
with bans, such as the reason and expiration date. This caused various plugins
to use external or other means to store a ban reason, making the built-in
banning system on the server partially useless.

Now the ban commands will accept reasons for the bans as well as kick the
player from the server once banned. That means that if an IP is banned
that all players using that IP will be removed from the server.

The API provided now supports editing the ban reason, creation date,
expiration date and source. The ban list has also been created to
provide this information more easily. Editing the data requires an
implementing plugin to manually save the information with the provided
method in BanEntry or BanList once changes have been made.

The addition of this API has deprecated the use of OfflinePlayer#setBanned()
as it has been replaced by BanList#addBan().
This commit is contained in:
mbax
2014-02-03 22:16:14 -07:00
committed by turt2live
parent 574f7a8c6c
commit 75427e084d
9 changed files with 216 additions and 13 deletions

View File

@@ -0,0 +1,66 @@
package org.bukkit;
import java.util.Date;
import java.util.Set;
/**
* A ban list, containing bans of type {@link org.bukkit.BanList.Type}
*/
public interface BanList {
/**
* Gets a {@link BanEntry} by target.
*
* @param target Entry parameter to search for
* @return BanEntry for the submitted query, or null if none found
*/
public BanEntry getBanEntry(String target);
/**
* Adds a ban to the ban list. If a previous ban exists, this will overwrite the previous
* entry.
*
* @param target The target of the ban
* @param reason Reason for the ban. If null, the implementation default is assumed
* @param expires Expiration Date of the ban. If null, "infinity" is assumed
* @param source Source of the ban. If null, the implementation default is assumed
* @return The BanEntry of the added ban
*/
public BanEntry addBan(String target, String reason, Date expires, String source);
/**
* Gets a set containing every {@link BanEntry} in the BanList.
*
* @return an immutable set containing every BanEntry tracked by the BanList
*/
public Set<BanEntry> getBanEntries();
/**
* Gets if a {@link BanEntry} exists for the target, indicating ban status
*
* @param target Entry target to lookup
* @return true if a {@link BanEntry} exists for the name, indicating ban status
*/
public boolean isBanned(String target);
/**
* Removes the specified target from the list, therefore indicating a "not banned" status.
*
* @param target The target to remove from the list
*/
public void pardon(String target);
/**
* Represents the various types a {@link BanList} may track.
*/
public enum Type {
/**
* Banned player names
*/
NAME,
/**
* Banned player IP addresses
*/
IP;
}
}