#1225: Add modern time API methods to ban API
By: Yannick Lamprecht <yannicklamprecht@live.de>
This commit is contained in:
@@ -14,6 +14,8 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
@@ -1199,6 +1201,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return this.ban(reason, expires, source, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> ban(String reason, Instant expires, String source) {
|
||||
return ban(reason, expires != null ? Date.from(expires) : null, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> ban(String reason, Duration duration, String source) {
|
||||
return ban(reason, duration != null ? Instant.now().plus(duration) : null, source);
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -1208,6 +1220,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return banEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> ban(String reason, Instant instant, String source, boolean kickPlayer) {
|
||||
return ban(reason, instant != null ? Date.from(instant) : null, source, kickPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> ban(String reason, Duration duration, String source, boolean kickPlayer) {
|
||||
return ban(reason, duration != null ? Instant.now().plus(duration) : null, source, kickPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<InetAddress> banIp(String reason, Date expires, String source, boolean kickPlayer) {
|
||||
Preconditions.checkArgument(getAddress() != null, "The Address of this Player is null");
|
||||
@@ -1218,6 +1240,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return banEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<InetAddress> banIp(String reason, Instant instant, String source, boolean kickPlayer) {
|
||||
return banIp(reason, instant != null ? Date.from(instant) : null, source, kickPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<InetAddress> banIp(String reason, Duration duration, String source, boolean kickPlayer) {
|
||||
return banIp(reason, duration != null ? Instant.now().plus(duration) : null, source, kickPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted() {
|
||||
return server.getHandle().getWhiteList().isWhiteListed(getProfile());
|
||||
|
||||
Reference in New Issue
Block a user