diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2014-04-17 11:03:51 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2014-04-17 11:03:51 -0500 |
commit | 98555224aaee83601bda2906aa53f05d91926c78 (patch) | |
tree | f7a829612b99a21efa67911eab2e010a78ea9a3e /src/main | |
parent | 3e911dba54ba2d6bc107adac7758efb75123e1f8 (diff) | |
download | craftbukkit-98555224aaee83601bda2906aa53f05d91926c78.tar craftbukkit-98555224aaee83601bda2906aa53f05d91926c78.tar.gz craftbukkit-98555224aaee83601bda2906aa53f05d91926c78.tar.lz craftbukkit-98555224aaee83601bda2906aa53f05d91926c78.tar.xz craftbukkit-98555224aaee83601bda2906aa53f05d91926c78.zip |
Handle expired bans correctly. Fixes BUKKIT-5541
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/ExpirableListEntry.java | 18 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/PlayerList.java | 4 |
2 files changed, 19 insertions, 3 deletions
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(); |