2014-02-05 04:52:50 +01:00
|
|
|
package org.bukkit.craftbukkit;
|
|
|
|
|
2014-04-11 03:04:38 +02:00
|
|
|
import net.minecraft.server.IpBanEntry;
|
|
|
|
import net.minecraft.server.IpBanList;
|
2014-02-05 04:52:50 +01:00
|
|
|
|
2014-04-11 03:04:38 +02:00
|
|
|
import java.util.Date;
|
2014-02-05 04:52:50 +01:00
|
|
|
|
2014-04-11 03:04:38 +02:00
|
|
|
public final class CraftIpBanEntry implements org.bukkit.BanEntry {
|
|
|
|
private final IpBanList list;
|
|
|
|
private final String target;
|
2014-02-05 04:52:50 +01:00
|
|
|
private Date created;
|
|
|
|
private String source;
|
|
|
|
private Date expiration;
|
|
|
|
private String reason;
|
|
|
|
|
2014-04-11 03:04:38 +02:00
|
|
|
public CraftIpBanEntry(String target, IpBanEntry entry, IpBanList list) {
|
2014-02-05 04:52:50 +01:00
|
|
|
this.list = list;
|
2014-04-11 03:04:38 +02:00
|
|
|
this.target = target;
|
2014-02-05 04:52:50 +01:00
|
|
|
this.created = entry.getCreated() != null ? new Date(entry.getCreated().getTime()) : null;
|
|
|
|
this.source = entry.getSource();
|
|
|
|
this.expiration = entry.getExpires() != null ? new Date(entry.getExpires().getTime()) : null;
|
|
|
|
this.reason = entry.getReason();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getTarget() {
|
2014-04-11 03:04:38 +02:00
|
|
|
return this.target;
|
2014-02-05 04:52:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Date getCreated() {
|
|
|
|
return this.created == null ? null : (Date) this.created.clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setCreated(Date created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getSource() {
|
|
|
|
return this.source;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setSource(String source) {
|
|
|
|
this.source = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Date getExpiration() {
|
|
|
|
return this.expiration == null ? null : (Date) this.expiration.clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setExpiration(Date expiration) {
|
|
|
|
if (expiration != null && expiration.getTime() == new Date(0, 0, 0, 0, 0, 0).getTime()) {
|
|
|
|
expiration = null; // Forces "forever"
|
|
|
|
}
|
|
|
|
|
|
|
|
this.expiration = expiration;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getReason() {
|
|
|
|
return this.reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setReason(String reason) {
|
|
|
|
this.reason = reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void save() {
|
2014-04-11 03:04:38 +02:00
|
|
|
IpBanEntry entry = new IpBanEntry(target, this.created, this.source, this.expiration, this.reason);
|
2014-02-05 04:52:50 +01:00
|
|
|
this.list.add(entry);
|
|
|
|
this.list.save();
|
|
|
|
}
|
|
|
|
}
|