Package fr.neatmonster.nocheatplus.config

Examples of fr.neatmonster.nocheatplus.config.ConfigFile


    /**
     * Fetch settings from the current default config.
     */
    private void adjustSettings() {
        final ConfigFile config = ConfigManager.getConfigFile();
        doExpireData = config.getBoolean(ConfPaths.DATA_EXPIRATION_ACTIVE);
        durExpireData = config.getLong(ConfPaths.DATA_EXPIRATION_DURATION, 1, 1000000, 60) * 60000L; // in minutes
        deleteData = config.getBoolean(ConfPaths.DATA_EXPIRATION_DATA, true); // hidden.
        deleteHistory = config.getBoolean(ConfPaths.DATA_EXPIRATION_HISTORY);
    }
View Full Code Here


        Bukkit.getPluginManager().callEvent(new NCPReloadEvent());

        sender.sendMessage(TAG + "Configuration reloaded!");
        final String info = "[NoCheatPlus] Configuration reloaded.";
        if (!(sender instanceof ConsoleCommandSender)) Bukkit.getLogger().info(info);
        final ConfigFile config = ConfigManager.getConfigFile();
        if (config.getBoolean(ConfPaths.LOGGING_ACTIVE) && config.getBoolean(ConfPaths.LOGGING_BACKEND_FILE_ACTIVE)) StaticLogFile.fileLogger.info(info);
    }
View Full Code Here

            }
            // No sub command worked, print usage.
            return false;
        }

        final ConfigFile config = ConfigManager.getConfigFile();
        if (config.getBoolean(ConfPaths.PROTECT_PLUGINS_HIDE_ACTIVE)){
            // Prevent the NCP usage printout:
            // TODO: GetColoredString
            sender.sendMessage(ColorUtil.replaceColors(config.getString(ConfPaths.PROTECT_PLUGINS_HIDE_NOCOMMAND_MSG)));
            return true;
        }
        else{
            return false;
        }
View Full Code Here

  /**
   * 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 = "";
      for (int i = 0; i < motdS.length; i++){
        message = motdS[i].onPlayerJoin(message, player, allowAll);
      }
View Full Code Here

    protected void setupCommandProtection() {
        // TODO: Might re-check with plugins enabling during runtime (!).
        final List<CommandProtectionEntry> changedCommands = new LinkedList<CommandProtectionEntry>();
        // Read lists and messages from config.
        final ConfigFile config = ConfigManager.getConfigFile();
        // (Might add options to invert selection.)
        // "No permission".
        // TODO: Could/should set permission message to null here (server default), might use keyword "default".
        final List<String> noPerm = config.getStringList(ConfPaths.PROTECT_PLUGINS_HIDE_NOPERMISSION_CMDS);
        if (noPerm != null && !noPerm.isEmpty()){
            final String noPermMsg = ColorUtil.replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.PROTECT_PLUGINS_HIDE_NOPERMISSION_MSG));
            changedCommands.addAll(PermissionUtil.protectCommands(Permissions.FILTER_COMMAND, noPerm,  true, false, noPermMsg));
        }
        // "Unknown command", override the other option.
        final List<String> noCommand = config.getStringList(ConfPaths.PROTECT_PLUGINS_HIDE_NOCOMMAND_CMDS);
        if (noCommand != null && !noCommand.isEmpty()){
            final String noCommandMsg = ColorUtil.replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.PROTECT_PLUGINS_HIDE_NOCOMMAND_MSG));
            changedCommands.addAll(PermissionUtil.protectCommands(Permissions.FILTER_COMMAND, noCommand,  true, false, noCommandMsg));
        }
        // Add to changes history for undoing.
View Full Code Here

        ConfigManager.init(this);

        // Setup file logger.
        StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_BACKEND_FILE_FILENAME)));

        final ConfigFile config = ConfigManager.getConfigFile();

        useSubscriptions = config.getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS);

        // Initialize MCAccess.
        initMCAccess(config);

        // Initialize BlockProperties.
        initBlockProperties(config);

        // Initialize data manager.
        disableListeners.add(0, dataMan);
        dataMan.onEnable();

        // Allow entries to TickTask (just in case).
        TickTask.setLocked(false);

        // List the events listeners and register.
        manageListeners = config.getBoolean(ConfPaths.COMPATIBILITY_MANAGELISTENERS);
        if (manageListeners) {
            listenerManager.setRegisterDirectly(true);
            listenerManager.registerAllWithBukkit();
        }
        else{
            // Just for safety.
            listenerManager.setRegisterDirectly(false);
            listenerManager.clear();
        }

        @SetupOrder(priority = - 100)
        class ReloadHook implements INotifyReload{
            @Override
            public void onReload() {
                // Only for reloading, not INeedConfig.
                processReload();
            }
        }

        // Add the "low level" system components first.
        for (final Object obj : new Object[]{
                nameSetPerms,
                getCoreListener(),
                // Put ReloadListener first, because Checks could also listen to it.
                new ReloadHook(),
                NCPExemptionManager.getListener(),
                new ConsistencyChecker() {
                    @Override
                    public void checkConsistency(final Player[] onlinePlayers) {
                        NCPExemptionManager.checkConsistency(onlinePlayers);
                    }
                },
                dataMan,
        }){
            addComponent(obj);
            // Register sub-components (allow later added to use registries, if any).
            processQueuedSubComponentHolders();
        }

        // Register "higher level" components (check listeners).
        for (final Object obj : new Object[]{
                new BlockInteractListener(),
                new BlockBreakListener(),
                new BlockPlaceListener(),
                new ChatListener(),
                new CombinedListener(),
                // Do mind registration order: Combined must come before Fight.
                new FightListener(),
                new InventoryListener(),
                new MovingListener(),
        }){
            addComponent(obj);
            // Register sub-components (allow later added to use registries, if any).
            processQueuedSubComponentHolders();
        }

        // Register optional default components.
        final DefaultComponentFactory dcf = new DefaultComponentFactory();
        for (final Object obj : dcf.getAvailableComponentsOnEnable(this)){
            addComponent(obj);
            // Register sub-components to enable registries for optional components.
            processQueuedSubComponentHolders();
        }

        // Register the commands handler.
        final PluginCommand command = getCommand("nocheatplus");
        final NoCheatPlusCommand commandHandler = new NoCheatPlusCommand(this, notifyReload);
        command.setExecutor(commandHandler);
        // (CommandHandler is TabExecutor.)

        // Set up the tick task.
        TickTask.start(this);

        this.dataManTaskId  = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
            @Override
            public void run() {
                dataMan.checkExpiration();
            }
        }, 1207, 1207);

        // Set up consistency checking.
        scheduleConsistencyCheckers();

        //        if (config.getBoolean(ConfPaths.MISCELLANEOUS_CHECKFORUPDATES)){
        //            // Is a new update available?
        //          final int timeout = config.getInt(ConfPaths.MISCELLANEOUS_UPDATETIMEOUT, 4) * 1000;
        //          getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable() {
        //        @Override
        //        public void run() {
        //          updateAvailable = Updates.checkForUpdates(getDescription().getVersion(), timeout);
        //        }
        //      });
        //        }

        // Is the version the configuration was created with consistent with the current one?
        configProblems = Updates.isConfigUpToDate(config);
        if (configProblems != null && config.getBoolean(ConfPaths.CONFIGVERSION_NOTIFY)){
            // Could use custom prefix from logging, however ncp should be mentioned then.
            LogUtil.logWarning("[NoCheatPlus] " + configProblems);
        }

        // Care for already online players.
View Full Code Here

    /**
     * All action done on reload.
     */
    protected void processReload(){
        final ConfigFile config = ConfigManager.getConfigFile();
        configProblems = Updates.isConfigUpToDate(config);
        // TODO: Process registered ComponentFactory instances.
        // Set up MCAccess.
        initMCAccess(config);
        // Initialize BlockProperties
        initBlockProperties(config);
        // Reset Command protection.
        undoCommandChanges();
        if (config.getBoolean(ConfPaths.PROTECT_PLUGINS_HIDE_ACTIVE)) {
            setupCommandProtection();
        }
        // (Re-) schedule consistency checking.
        scheduleConsistencyCheckers();
        // Cache some things.
        useSubscriptions = config.getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS);
    }
View Full Code Here

        Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
            @Override
            public void run() {
                // Debug information about unknown blocks.
                // (Probably removed later.)
                ConfigFile config = ConfigManager.getConfigFile();
                BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, config.getBoolean(ConfPaths.BLOCKBREAK_DEBUG, config.getBoolean(ConfPaths.CHECKS_DEBUG, false))));
            }
        });
    }
View Full Code Here

    protected 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();
            }
View Full Code Here

    /**
     * Run consistency checks for at most the configured duration. If not finished, a task will be scheduled to continue.
     */
    protected void runConsistencyChecks(){
        final long tStart = System.currentTimeMillis();
        final ConfigFile config = ConfigManager.getConfigFile();
        if (!config.getBoolean(ConfPaths.DATA_CONSISTENCYCHECKS_CHECK) || consistencyCheckers.isEmpty()){
            consistencyCheckerIndex = 0;
            return;
        }
        final long tEnd = tStart + config.getLong(ConfPaths.DATA_CONSISTENCYCHECKS_MAXTIME, 1, 50, 2);
        if (consistencyCheckerIndex >= consistencyCheckers.size()) consistencyCheckerIndex = 0;
        final Player[] onlinePlayers = getServer().getOnlinePlayers();
        // Loop
        while (consistencyCheckerIndex < consistencyCheckers.size()){
            final ConsistencyChecker checker = consistencyCheckers.get(consistencyCheckerIndex);
            try{
                checker.checkConsistency(onlinePlayers);
            }
            catch (Throwable t){
                LogUtil.logSevere("[NoCheatPlus] ConsistencyChecker(" + checker.getClass().getName() + ") encountered an exception:");
                LogUtil.logSevere(t);
            }
            consistencyCheckerIndex ++; // Do not remove :).
            final long now = System.currentTimeMillis();
            if (now < tStart || now >= tEnd){
                break;
            }
        }
        // (The index might be bigger than size by now.)

        final boolean debug = config.getBoolean(ConfPaths.LOGGING_DEBUG);

        // If not finished, schedule further checks.
        if (consistencyCheckerIndex < consistencyCheckers.size()){
            getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                @Override
View Full Code Here

TOP

Related Classes of fr.neatmonster.nocheatplus.config.ConfigFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.