#1225: Add modern time API methods to ban API
By: Yannick Lamprecht <yannicklamprecht@live.de>
This commit is contained in:
@@ -4,6 +4,8 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import java.net.InetAddress;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import net.minecraft.server.players.IpBanEntry;
|
||||
@@ -52,6 +54,18 @@ public class CraftIpBanList implements org.bukkit.ban.IpBanList {
|
||||
return this.addBan(this.getIpFromAddress(target), reason, expires, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<InetAddress> addBan(InetAddress target, String reason, Instant expires, String source) {
|
||||
Date date = expires != null ? Date.from(expires) : null;
|
||||
return addBan(target, reason, date, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<InetAddress> addBan(InetAddress target, String reason, Duration duration, String source) {
|
||||
Instant instant = duration != null ? Instant.now().plus(duration) : null;
|
||||
return addBan(target, reason, instant, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<BanEntry> getBanEntries() {
|
||||
ImmutableSet.Builder<BanEntry> builder = ImmutableSet.builder();
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.ban;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -50,6 +52,18 @@ public class CraftProfileBanList implements ProfileBanList {
|
||||
return this.addBan(((CraftPlayerProfile) target).buildGameProfile(), reason, expires, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> addBan(PlayerProfile target, String reason, Instant expires, String source) {
|
||||
Date date = expires != null ? Date.from(expires) : null;
|
||||
return addBan(target, reason, date, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanEntry<PlayerProfile> addBan(PlayerProfile target, String reason, Duration duration, String source) {
|
||||
Instant instant = duration != null ? Instant.now().plus(duration) : null;
|
||||
return addBan(target, reason, instant, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<BanEntry> getBanEntries() {
|
||||
ImmutableSet.Builder<BanEntry> builder = ImmutableSet.builder();
|
||||
|
||||
Reference in New Issue
Block a user