public void updateAllBans() { List<BanTable> list = getDatabase() .find(BanTable.class) .where() .in("type", (Object[]) BanType.getExpiringBans()) .isNotNull("expiry") .findList(); updateBans(list); }
public void importLegacy(CommandSender sender) { List<LegacyTable> legacies = getLegacy(); sender.sendMessage("Importing " + legacies.size() + " bans..."); List<String> consoleNames = new ArrayList<String>(); consoleNames.add("Tekkit"); consoleNames.add("server"); consoleNames.add("Server"); consoleNames.add("Served Time"); consoleNames.add("Console"); int i = 0; for (LegacyTable legacy : legacies) { BanTable ban = new BanTable(); PlayerTable player = getPlayer(legacy.getPlayer()); if (player == null) { // if (MinecraftServer.getServer().getUserCache().a(legacy.getPlayer()) != null) { // TODO // removeme! // OfflinePlayer tmp = plugin.getServer().getOfflinePlayer(legacy.getPlayer()); // if (tmp != null && tmp.getName() != null) { // sender.sendMessage("Added new player: " + tmp.getName()); // player = getPlayer(tmp); // } // } // if (player == null) { sender.sendMessage("Unknown player: " + legacy.getId() + ": " + legacy.getPlayer()); continue; // } } ban.setPlayer(player); PlayerTable admin = null; if (consoleNames.contains(legacy.getAdmin())) { // admin = null; } else { admin = getPlayer(legacy.getAdmin()); if (admin == null) { sender.sendMessage("Unknown admin: " + legacy.getId()); continue; } } ban.setAdmin(admin); ban.setReason(legacy.getReason()); ban.setTime(legacy.getTime()); ban.setExpiry(legacy.getExpiry()); try { ban.setType(BanType.valueOf(legacy.getType().toUpperCase())); } catch (IllegalArgumentException iae) { sender.sendMessage("Unknown type: " + legacy.getId()); continue; } getDatabase().save(ban); if (++i % 1000 == 0) sender.sendMessage("Imported " + i + "/" + legacies.size() + " ban records."); } sender.sendMessage( "Finished importing " + i + " ban records. Failed: " + (legacies.size() - i)); }