/net/minecraft/server/BanEntry.java
https://bitbucket.org/agaricusb/mc-dev · Java · 132 lines · 111 code · 21 blank · 0 comment · 15 complexity · 40c01b6574fb794a340d69ed120f531b MD5 · raw file
- package net.minecraft.server;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import java.util.regex.Pattern;
- public class BanEntry {
- public static final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
- public static Logger b = Logger.getLogger("Minecraft");
- private final String c;
- private Date d = new Date();
- private String e = "(Unknown)";
- private Date f = null;
- private String g = "Banned by an operator.";
- public BanEntry(String s) {
- this.c = s;
- }
- public String getName() {
- return this.c;
- }
- public Date getCreated() {
- return this.d;
- }
- public void setCreated(Date date) {
- this.d = date != null ? date : new Date();
- }
- public String getSource() {
- return this.e;
- }
- public void setSource(String s) {
- this.e = s;
- }
- public Date getExpires() {
- return this.f;
- }
- public void setExpires(Date date) {
- this.f = date;
- }
- public boolean hasExpired() {
- return this.f == null ? false : this.f.before(new Date());
- }
- public String getReason() {
- return this.g;
- }
- public void setReason(String s) {
- this.g = s;
- }
- public String g() {
- StringBuilder stringbuilder = new StringBuilder();
- stringbuilder.append(this.getName());
- stringbuilder.append("|");
- stringbuilder.append(a.format(this.getCreated()));
- stringbuilder.append("|");
- stringbuilder.append(this.getSource());
- stringbuilder.append("|");
- stringbuilder.append(this.getExpires() == null ? "Forever" : a.format(this.getExpires()));
- stringbuilder.append("|");
- stringbuilder.append(this.getReason());
- return stringbuilder.toString();
- }
- public static BanEntry c(String s) {
- if (s.trim().length() < 2) {
- return null;
- } else {
- String[] astring = s.trim().split(Pattern.quote("|"), 5);
- BanEntry banentry = new BanEntry(astring[0].trim());
- byte b0 = 0;
- int i = astring.length;
- int j = b0 + 1;
- if (i <= j) {
- return banentry;
- } else {
- try {
- banentry.setCreated(a.parse(astring[j].trim()));
- } catch (ParseException parseexception) {
- b.log(Level.WARNING, "Could not read creation date format for ban entry \'" + banentry.getName() + "\' (was: \'" + astring[j] + "\')", parseexception);
- }
- i = astring.length;
- ++j;
- if (i <= j) {
- return banentry;
- } else {
- banentry.setSource(astring[j].trim());
- i = astring.length;
- ++j;
- if (i <= j) {
- return banentry;
- } else {
- try {
- String s1 = astring[j].trim();
- if (!s1.equalsIgnoreCase("Forever") && s1.length() > 0) {
- banentry.setExpires(a.parse(s1));
- }
- } catch (ParseException parseexception1) {
- b.log(Level.WARNING, "Could not read expiry date format for ban entry \'" + banentry.getName() + "\' (was: \'" + astring[j] + "\')", parseexception1);
- }
- i = astring.length;
- ++j;
- if (i <= j) {
- return banentry;
- } else {
- banentry.setReason(astring[j].trim());
- return banentry;
- }
- }
- }
- }
- }
- }
- }