diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2014-04-10 20:04:38 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2014-04-11 22:28:35 -0500 |
commit | 8f771c737850130534b0fade70494f7ce3cbc8fd (patch) | |
tree | e4180121cdaf4f15b325aa059469b44975fca8a4 /src/main/java/net/minecraft/server/ExpirableListEntry.java | |
parent | 0df7555cecff17ffab68b8280dcf8471b10f020c (diff) | |
download | craftbukkit-8f771c737850130534b0fade70494f7ce3cbc8fd.tar craftbukkit-8f771c737850130534b0fade70494f7ce3cbc8fd.tar.gz craftbukkit-8f771c737850130534b0fade70494f7ce3cbc8fd.tar.lz craftbukkit-8f771c737850130534b0fade70494f7ce3cbc8fd.tar.xz craftbukkit-8f771c737850130534b0fade70494f7ce3cbc8fd.zip |
Update CraftBukkit to Minecraft 1.7.8
Diffstat (limited to 'src/main/java/net/minecraft/server/ExpirableListEntry.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ExpirableListEntry.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/ExpirableListEntry.java b/src/main/java/net/minecraft/server/ExpirableListEntry.java new file mode 100644 index 00000000..7b41cab8 --- /dev/null +++ b/src/main/java/net/minecraft/server/ExpirableListEntry.java @@ -0,0 +1,79 @@ +package net.minecraft.server; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import net.minecraft.util.com.google.gson.JsonObject; + +public abstract class ExpirableListEntry extends JsonListEntry { + + public static final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); + protected final Date b; + protected final String c; + protected final Date d; + protected final String e; + + public ExpirableListEntry(Object object, Date date, String s, Date date1, String s1) { + super(object); + this.b = date == null ? new Date() : date; + this.c = s == null ? "(Unknown)" : s; + this.d = date1; + this.e = s1 == null ? "Banned by an operator." : s1; + } + + protected ExpirableListEntry(Object object, JsonObject jsonobject) { + super(object, jsonobject); + + Date date; + + try { + date = jsonobject.has("created") ? a.parse(jsonobject.get("created").getAsString()) : new Date(); + } catch (ParseException parseexception) { + date = new Date(); + } + + this.b = date; + this.c = jsonobject.has("source") ? jsonobject.get("source").getAsString() : "(Unknown)"; + + Date date1; + + try { + date1 = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null; + } catch (ParseException parseexception1) { + date1 = null; + } + + this.d = date1; + this.e = jsonobject.has("reason") ? jsonobject.get("reason").getAsString() : "Banned by an operator."; + } + + public Date getExpires() { + return this.d; + } + + public String getReason() { + return this.e; + } + + boolean e() { + return this.d == null ? false : this.d.before(new Date()); + } + + protected void a(JsonObject jsonobject) { + jsonobject.addProperty("created", a.format(this.b)); + jsonobject.addProperty("source", this.c); + jsonobject.addProperty("expires", this.d == null ? "forever" : a.format(this.d)); + jsonobject.addProperty("reason", this.e); + } + + // CraftBukkit start + public String getSource() { + return this.c; + } + + public Date getCreated() { + return this.b; + } + // CraftBukkit end +} |