SPIGOT-6455, SPIGOT-7030, #1054: Improve ban API
By: Doc <nachito94@msn.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -96,6 +97,7 @@ import net.minecraft.world.level.border.IWorldBorderListener;
|
||||
import net.minecraft.world.level.saveddata.maps.MapIcon;
|
||||
import net.minecraft.world.level.saveddata.maps.WorldMap;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.BanEntry;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
@@ -112,6 +114,8 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.WorldBorder;
|
||||
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;
|
||||
@@ -1186,7 +1190,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return server.getBanList(BanList.Type.NAME).isBanned(getName());
|
||||
return ((ProfileBanList) server.getBanList(BanList.Type.PROFILE)).isBanned(getPlayerProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> ban(String reason, Date expires, String source) {
|
||||
return this.ban(reason, expires, source, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> ban(String reason, Date expires, String source, boolean kickPlayer) {
|
||||
BanEntry<PlayerProfile> banEntry = ((ProfileBanList) server.getBanList(BanList.Type.PROFILE)).addBan(getPlayerProfile(), reason, expires, source);
|
||||
if (kickPlayer) {
|
||||
this.kickPlayer(reason);
|
||||
}
|
||||
return banEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<InetSocketAddress> banIp(String reason, Date expires, String source, boolean kickPlayer) {
|
||||
Preconditions.checkArgument(getAddress() != null, "The Address of this Player is null");
|
||||
BanEntry<InetSocketAddress> banEntry = ((IpBanList) server.getBanList(BanList.Type.IP)).addBan(getAddress(), reason, expires, source);
|
||||
if (kickPlayer) {
|
||||
this.kickPlayer(reason);
|
||||
}
|
||||
return banEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user