@Override public ConfigFile getDefaultConfig() { return ConfigManager.getConfigFile(); }
@Override public ConfigFile getConfig(String worldName) { return ConfigManager.getConfigFile(worldName); }
/** * (Synchronized version). * @return * @deprecated getConfigFile() is thread-safe now. */ @Deprecated public static synchronized ConfigFile getConfigFileSync() { return getConfigFile(); }
/** * (Synchronized version). * @param worldName * @return * @deprecated getConfigFile() is thread-safe now. */ @Deprecated public static synchronized ConfigFile getConfigFileSync(final String worldName) { return getConfigFile(worldName); }
private StreamID getRegistryStreamId() { // TODO: Select by config, or add Streams.REGISTRY for a new default. // For now prefer log file, unless extended status is set. return ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_EXTENDED_STATUS) ? Streams.STATUS : Streams.DEFAULT_FILE; }
protected abstract C newConfig(String key, ConfigFile configFile);
/** * Instantiates a new command action. * * @param name * the name * @param delay * the delay * @param repeat * the repeat * @param command * the command */ public CommandAction(final String name, final int delay, final int repeat, final String command) { // Log messages may have color codes now. super(name, delay, repeat, command); logDebug = ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_EXTENDED_COMMANDS_ACTIONS); }
@Override public void onReload() { aux.clear(); hoverTicksStep = Math.max(1, ConfigManager.getConfigFile().getInt(ConfPaths.MOVING_SURVIVALFLY_HOVER_STEP)); }
private static void checkLogEntry(final String tag) { // New entry. if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_EXTENDED_STATUS)) { StaticLog.logInfo("Try old health API: " + tag); } }
@Override public void onReload() { // Hard clear and re-do loggers. Might result in loss of content. // TODO: Register for "early onReload call", needs API addition. clear(0L, true); // Can not afford to wait. createDefaultLoggers(ConfigManager.getConfigFile()); }
/** * Set up the command protection with the "unknown command" message for the permission message (attempt to hide the command). * @param permissionBase * @param ignoredCommands * @param invertIgnored * @param ops * @return */ public static List<CommandProtectionEntry> protectCommands(String permissionBase, Collection<String> ignoredCommands, boolean invertIgnored, boolean ops) { return protectCommands(permissionBase, ignoredCommands, invertIgnored, ops, ColorUtil.replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.PROTECT_PLUGINS_HIDE_NOCOMMAND_MSG))); }
@Override public void run() { // Debug information about unknown blocks. // (Probably removed later.) ConfigFile config = ConfigManager.getConfigFile(); BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_DEBUG, config.getBoolean(ConfPaths.CHECKS_DEBUG, false))); } });
@Override public void onReload() { // Read some things from the global config file. ConfigFile config = ConfigManager.getConfigFile(); initFilters(config); text.onReload(); logins.onReload(); }
/** * This will create all default loggers as well. * @param plugin */ public BukkitLogManager(Plugin plugin) { super(new BukkitLogNodeDispatcher(plugin), Streams.defaultPrefix, Streams.INIT); this.plugin = plugin; ConfigFile config = ConfigManager.getConfigFile(); createDefaultLoggers(config); getLogNodeDispatcher().setMaxQueueSize(config.getInt(ConfPaths.LOGGING_MAXQUEUESIZE)); }
private void init() { // Set some things from the global config. final ConfigFile config = ConfigManager.getConfigFile(); final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI(); if (engine != null) { engine.clear(); api.removeComponent(engine); } engine = new LetterEngine(config); api.addComponent(engine); }
/** * Send block codes to the player according to allowed or disallowed client-mods or client-mod features. * @param player */ public static void motdOnJoin(final Player player) { final ConfigFile config = ConfigManager.getConfigFile(); if (!config.getBoolean(ConfPaths.PROTECT_CLIENTS_MOTD_ACTIVE)){ // No message is to be sent. return; } // TODO: Somebody test this all ! // TODO: add feature to check world specific (!). // Check if we allow all the client mods. final boolean allowAll = config.getBoolean(ConfPaths.PROTECT_CLIENTS_MOTD_ALLOWALL); String message = ""; final IPlayerData data = DataManager.getPlayerData(player); for (int i = 0; i < motdS.length; i++){ message = motdS[i].onPlayerJoin(message, player, data, allowAll); } if (!message.isEmpty()){ player.sendMessage(message); } }
private void scheduleConsistencyCheckers() { BukkitScheduler sched = getServer().getScheduler(); if (consistencyCheckerTaskId != -1) { sched.cancelTask(consistencyCheckerTaskId); } ConfigFile config = ConfigManager.getConfigFile(); if (!config.getBoolean(ConfPaths.DATA_CONSISTENCYCHECKS_CHECK, true)) { return; } // Schedule task in seconds. final long delay = 20L * config.getInt(ConfPaths.DATA_CONSISTENCYCHECKS_INTERVAL, 1, 3600, 10); consistencyCheckerTaskId = sched.scheduleSyncRepeatingTask(this, new Runnable() { @Override public void run() { runConsistencyChecks(); } }, delay, delay ); }
@Override protected void registerInitLogger() { synchronized (registryCOWLock) { if (!hasStream(Streams.INIT)) { createInitStream(); } else if (hasLogger(Streams.INIT.name)) { // Shallow check. return; } // Attach a new restrictive init logger. boolean bukkitLoggerAsynchronous = ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_BACKEND_CONSOLE_ASYNCHRONOUS); LoggerID initLoggerID = registerStringLogger(serverLogger, new LogOptions(Streams.INIT.name, bukkitLoggerAsynchronous ? CallContext.ANY_THREAD_DIRECT : CallContext.PRIMARY_THREAD_ONLY)); attachStringLogger(initLoggerID, Streams.INIT); } }
@Override public void execute(final ViolationData violationData) { // TODO: Consider permission caching or removing the feature? [Besides, check earlier?] final RegisteredPermission permissionSilent = violationData.getPermissionSilent(); // TODO: Store PlayerData in ViolationData ? Must query cache here. if (permissionSilent != null && DataManager.getPlayerData(violationData.player).hasPermission(permissionSilent, violationData.player)) { return; } final LogManager logManager = NCPAPIProvider.getNoCheatPlusAPI().getLogManager(); final String message = getMessage(violationData); final String messageNoColor = stripColor ? ColorUtil.removeColors(message) : null; final String messageWithColor = replaceColor ? ColorUtil.replaceColors(message) : null; final ConfigFile configFile = checkActive ? ConfigManager.getConfigFile() : null; for (int i = 0; i < configs.length; i ++) { final GenericLogActionConfig config = configs[i]; if (checkActive && config.configPathActive != null && !configFile.getBoolean(config.configPathActive)) { continue; } logManager.log(config.streamID, config.level, config.chatColor ? messageWithColor : messageNoColor); } }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerLogin(final PlayerLoginEvent event) { // (NORMAL to have chat checks come after this.) if (event.getResult() != Result.ALLOWED) { return; } final Player player = event.getPlayer(); // Check if login is denied (plus expiration check). // TODO: Store by id + HashMapLOW + AsyncPlayerPreLogin. if (checkDenyLoginsNames(player.getName())) { if (DataManager.getPlayerData(player).hasPermission(Permissions.BYPASS_DENY_LOGIN, player)) { return; } // TODO: Consider using the vanilla temporary ban feature instead (for an alternative?). // TODO: Display time for which the player is banned. event.setResult(Result.KICK_OTHER); // TODO: Some basic/language configuration object, possibly independent of checks. event.setKickMessage(ColorUtil.replaceColors(ConfigManager.getConfigFile(player.getWorld().getName()).getString(ConfPaths.STRINGS + ".msgtempdenylogin"))); } }