private void initializeThreads() { int startdelay = (int) (SettingUtil.getSettingDouble("start_delay_seconds") * 20); int savefrequency = SettingUtil.getSettingInt("save_interval_seconds") * 20; if (startdelay <= 0) startdelay = 1; if (savefrequency <= 0) savefrequency = 300; // data getServer() .getScheduler() .scheduleAsyncRepeatingTask( this, new Runnable() { @Override public void run() { DataManager.saveAllData(); } }, startdelay, savefrequency); getServer() .getScheduler() .scheduleAsyncRepeatingTask( this, new AsyncIPMatcherTask(), 50, TimeUnit.MINUTES.toMillis(getConfig().getInt("cache_interval_seconds", 10))); }
@Override public void onEnable() { inst = this; // Config getConfig().options().copyDefaults(true); saveConfig(); // Setup database Infractions.setDatabase(new LegacyDatabase()); Infractions.setDefaultOrigin( new Origin(Bukkit.getServerName(), Bukkit.getServerName(), OriginType.SERVER)); getLogger().info("Initializing."); // Handle data DataManager.initAllData(); LegacyData.asyncConvert(); LegacyData.asyncConvertIds(); loadCommands(); loadListeners(); loadMetrics(); initializeThreads(); Map<Integer, String> scores = Maps.newHashMap(); for (int i = 1; i < 6; i++) scores.put( i, ChatColor.translateAlternateColorCodes( '&', SettingUtil.getSettingString("chat_score_" + i))); CHAT_SCORES = ImmutableMap.copyOf(scores); if (SettingUtil.getSettingBoolean("update")) new Updater(this, 44721, getFile(), Updater.UpdateType.DEFAULT, true); message("enabled"); }
/** API */ public static String getLevelForChat(Player player) { if (player.hasPermission("infractions.ignore")) return SettingUtil.getSettingString("chat_score_ignore"); return getLevelForChat(player.getUniqueId()); }