@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.func_152687_a(entry); try { list.func_152678_f(); } catch (IOException ex) { MinecraftServer.getLogger().error("Failed to save banned-ips.json, " + ex.getMessage()); } return new CraftIpBanEntry(target, entry, list); }
protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) { IPBanEntry ipbanentry = new IPBanEntry(p_147210_2_, (Date)null, p_147210_1_.getName(), (Date)null, p_147210_3_); MinecraftServer.getServer().getConfigurationManager().getBannedIPs().addEntry(ipbanentry); List<EntityPlayerMP> list = MinecraftServer.getServer().getConfigurationManager().getPlayersMatchingAddress(p_147210_2_); String[] astring = new String[list.size()]; int i = 0; for (EntityPlayerMP entityplayermp : list) { entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned."); astring[i++] = entityplayermp.getName(); } if (list.isEmpty()) { notifyOperators(p_147210_1_, this, "commands.banip.success", new Object[] {p_147210_2_}); } else { notifyOperators(p_147210_1_, this, "commands.banip.success.players", new Object[] {p_147210_2_, joinNiceString(astring)}); } }
protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) { IPBanEntry ipbanentry = new IPBanEntry(p_147210_2_, (Date)null, p_147210_1_.getCommandSenderName(), (Date)null, p_147210_3_); MinecraftServer.getServer().getConfigurationManager().getBannedIPs().func_152687_a(ipbanentry); List list = MinecraftServer.getServer().getConfigurationManager().getPlayerList(p_147210_2_); String[] astring = new String[list.size()]; int i = 0; EntityPlayerMP entityplayermp; for (Iterator iterator = list.iterator(); iterator.hasNext(); astring[i++] = entityplayermp.getCommandSenderName()) { entityplayermp = (EntityPlayerMP)iterator.next(); entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned."); } if (list.isEmpty()) { func_152373_a(p_147210_1_, this, "commands.banip.success", new Object[] {p_147210_2_}); } else { func_152373_a(p_147210_1_, this, "commands.banip.success.players", new Object[] {p_147210_2_, joinNiceString(astring)}); } }
public CraftIpBanEntry(String target, IPBanEntry entry, BanList 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.getBanEndDate() != null ? new Date(entry.getBanEndDate().getTime()) : null; this.reason = entry.getBanReason(); }
@Override public void save() { IPBanEntry entry = new IPBanEntry(target, this.created, this.source, this.expiration, this.reason); this.list.func_152687_a(entry); try { this.list.func_152678_f(); } 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.func_152683_b(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.func_152685_a()) { builder.add(new CraftIpBanEntry(target, (IPBanEntry) list.func_152683_b(target), list)); } return builder.build(); }