@Override public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) { Validate.notNull(target, "Ban target cannot be null"); IpBanEntry entry = new IpBanEntry(target, new Date(), StringUtils.isBlank(source) ? null : source, expires, StringUtils.isBlank(reason) ? null : reason); list.add(entry); try { list.save(); } catch (IOException ex) { MinecraftServer.getLogger().error("Failed to save banned-ips.json, " + ex.getMessage()); } return new CraftIpBanEntry(target, entry, list); }
@Override public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) { Validate.notNull(target, "Ban target cannot be null"); IpBanEntry entry = new IpBanEntry(target, new Date(), StringUtils.isBlank(source) ? null : source, expires, StringUtils.isBlank(reason) ? null : reason); list.add(entry); try { list.save(); } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-ips.json, {0}", ex.getMessage()); } return new CraftIpBanEntry(target, entry, list); }
public CraftIpBanEntry(String target, IpBanEntry entry, IpBanList list) { this.list = list; this.target = target; 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 void save() { IpBanEntry entry = new IpBanEntry(target, this.created, this.source, this.expiration, this.reason); this.list.add(entry); try { this.list.save(); } catch (IOException ex) { MinecraftServer.getLogger().error("Failed to save banned-ips.json, " + ex.getMessage()); } }
@Override public org.bukkit.BanEntry getBanEntry(String target) { Validate.notNull(target, "Target cannot be null"); IpBanEntry entry = (IpBanEntry) list.get(target); if (entry == null) { return null; } return new CraftIpBanEntry(target, entry, list); }
@Override public Set<org.bukkit.BanEntry> getBanEntries() { ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder(); for (String target : list.getEntries()) { builder.add(new CraftIpBanEntry(target, (IpBanEntry) list.get(target), list)); } return builder.build(); }
@Override public void save() { IpBanEntry entry = new IpBanEntry(target, this.created, this.source, this.expiration, this.reason); this.list.add(entry); try { this.list.save(); } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-ips.json, {0}", ex.getMessage()); } }