From 98555224aaee83601bda2906aa53f05d91926c78 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Thu, 17 Apr 2014 11:03:51 -0500 Subject: Handle expired bans correctly. Fixes BUKKIT-5541 --- .../java/net/minecraft/server/ExpirableListEntry.java | 18 +++++++++++++++++- src/main/java/net/minecraft/server/PlayerList.java | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/net/minecraft/server/ExpirableListEntry.java b/src/main/java/net/minecraft/server/ExpirableListEntry.java index 7b41cab8..85819148 100644 --- a/src/main/java/net/minecraft/server/ExpirableListEntry.java +++ b/src/main/java/net/minecraft/server/ExpirableListEntry.java @@ -23,7 +23,7 @@ public abstract class ExpirableListEntry extends JsonListEntry { } protected ExpirableListEntry(Object object, JsonObject jsonobject) { - super(object, jsonobject); + super(checkExpiry(object, jsonobject), jsonobject); // CraftBukkit - check expiry Date date; @@ -75,5 +75,21 @@ public abstract class ExpirableListEntry extends JsonListEntry { public Date getCreated() { return this.b; } + + private static Object checkExpiry(Object object, JsonObject jsonobject) { + Date expires = null; + + try { + expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null; + } catch (ParseException ex) { + // Guess we don't have a date + } + + if (expires == null || expires.after(new Date())) { + return object; + } else { + return null; + } + } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java index 9a906710..1dbce5c5 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -353,7 +353,7 @@ public abstract class PlayerList { PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); String s; - if (this.j.isBanned(gameprofile)) { + if (this.j.isBanned(gameprofile) && !this.j.get(gameprofile).e()) { // Should be hasExpired GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.j.get(gameprofile); s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason(); @@ -366,7 +366,7 @@ public abstract class PlayerList { } else if (!this.isWhitelisted(gameprofile)) { // return "You are not white-listed on this server!"; event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!"); - } else if (this.k.isBanned(socketaddress)) { + } else if (this.k.isBanned(socketaddress) && !this.j.get(gameprofile).e()) { // Should be hasExpired IpBanEntry ipbanentry = this.k.get(socketaddress); s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason(); -- cgit v1.2.3