Archiviert
13
0

Handle expired bans correctly. Fixes BUKKIT-5541

Dieser Commit ist enthalten in:
Travis Watkins 2014-04-17 11:03:51 -05:00
Ursprung 3e911dba54
Commit 98555224aa
2 geänderte Dateien mit 19 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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();