super(worldData); final ConfigFile data = worldData.getRawConfiguration(); dropLimit = data.getInt(ConfPaths.INVENTORY_DROP_LIMIT); dropTimeFrame = data.getLong(ConfPaths.INVENTORY_DROP_TIMEFRAME); dropActions = data.getOptimizedActionList(ConfPaths.INVENTORY_DROP_ACTIONS, Permissions.INVENTORY_DROP); fastClickSpareCreative = data.getBoolean(ConfPaths.INVENTORY_FASTCLICK_SPARECREATIVE); fastClickTweaks1_5 = data.getBoolean(ConfPaths.INVENTORY_FASTCLICK_TWEAKS1_5); fastClickShortTermLimit = (float) data.getDouble(ConfPaths.INVENTORY_FASTCLICK_LIMIT_SHORTTERM); fastClickNormalLimit = (float) data.getDouble(ConfPaths.INVENTORY_FASTCLICK_LIMIT_NORMAL); fastClickActions = data.getOptimizedActionList(ConfPaths.INVENTORY_FASTCLICK_ACTIONS, Permissions.INVENTORY_FASTCLICK); fastConsumeDuration = (long) (1000.0 * data.getDouble(ConfPaths.INVENTORY_FASTCONSUME_DURATION)); fastConsumeWhitelist = data.getBoolean(ConfPaths.INVENTORY_FASTCONSUME_WHITELIST); data.readMaterialFromList(ConfPaths.INVENTORY_FASTCONSUME_ITEMS, fastConsumeItems); fastConsumeActions = data.getOptimizedActionList(ConfPaths.INVENTORY_FASTCONSUME_ACTIONS, Permissions.INVENTORY_FASTCONSUME); gutenbergActions = data.getOptimizedActionList(ConfPaths.INVENTORY_GUTENBERG_ACTIONS, Permissions.INVENTORY_GUTENBERG); instantBowStrict = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_STRICT); instantBowDelay = data.getInt(ConfPaths.INVENTORY_INSTANTBOW_DELAY); instantBowImprobableFeedOnly = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_IMPROBABLE_FEEDONLY); instantBowImprobableWeight = (float) data.getDouble(ConfPaths.INVENTORY_INSTANTBOW_IMPROBABLE_WEIGHT); instantBowActions = data.getOptimizedActionList(ConfPaths.INVENTORY_INSTANTBOW_ACTIONS, Permissions.INVENTORY_INSTANTBOW); instantEatActions = data.getOptimizedActionList(ConfPaths.INVENTORY_INSTANTEAT_ACTIONS, Permissions.INVENTORY_INSTANTEAT); openClose = data.getBoolean(ConfPaths.INVENTORY_OPEN_CLOSE); openCancelOther = data.getBoolean(ConfPaths.INVENTORY_OPEN_CANCELOTHER);
public MetaDataListCheck(final ConfigFile config, final String pathActive, final String pathKeys) { this(config.getBoolean(pathActive) ? config.getStringList(pathKeys) : null); }
public void setActionFactory(final ActionFactoryFactory actionFactoryFactory) { setActionFactory(actionFactoryFactory.newActionFactory(((MemorySection) this.get(ConfPaths.STRINGS)).getValues(false))); }
/** * Returns this object. * @param config * @param prefix Prefix for direct addition of config path. * @return This object. */ public DigestedWordsSettings applyConfig(ConfigFile config, String prefix){ this.sort = config.getBoolean(prefix + "sort", this.sort); this.compress = config.getBoolean(prefix + "compress", this.compress); this.split = config.getBoolean(prefix + "split", this.split); this.weight = (float) config.getDouble(prefix + "weight", this.weight); this.minWordSize = config.getInt(prefix + "minwordsize", this.minWordSize); this.maxWordSize = config.getInt(prefix + "maxwordsize", this.maxWordSize); return this; } }
public SimilarWordsBKLSettings applyConfig(ConfigFile config, String prefix){ super.applyConfig(config, prefix); this.range = config.getInt(prefix + "range", this.range); this.maxSize = config.getInt(prefix + "size", this.maxSize); this.maxSeek= config.getInt(prefix + "seek", this.maxSeek); this.durExpire = (long) (config.getDouble(prefix + "time", (float) this.durExpire / 1000f) * 1000f); return this; } }
ignoreCreative = config.getBoolean(ConfPaths.MOVING_CREATIVEFLY_IGNORECREATIVE); ignoreAllowFlight = config.getBoolean(ConfPaths.MOVING_CREATIVEFLY_IGNOREALLOWFLIGHT); ConfPaths.MOVING_CREATIVEFLY_MODEL + "elytra.", new ModelFlying(null, defaultModel).verticalAscendGliding(true).lock()); creativeFlyActions = config.getOptimizedActionList(ConfPaths.MOVING_CREATIVEFLY_ACTIONS, Permissions.MOVING_CREATIVEFLY); morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL); morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX)); morePacketsEPSBuckets = 2 * Math.max(1, Math.min(60, config.getInt(ConfPaths.MOVING_MOREPACKETS_SECONDS))); morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM); morePacketsBurstDirect = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT); morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM); morePacketsSetBackAge = config.getInt(ConfPaths.MOVING_MOREPACKETS_SETBACKAGE); morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS); noFallDealDamage = config.getBoolean(ConfPaths.MOVING_NOFALL_DEALDAMAGE); noFallSkipAllowFlight = config.getBoolean(ConfPaths.MOVING_NOFALL_SKIPALLOWFLIGHT); noFallViolationReset = config.getBoolean(ConfPaths.MOVING_NOFALL_RESETONVL); noFallTpReset = config.getBoolean(ConfPaths.MOVING_NOFALL_RESETONTP); noFallVehicleReset = config.getBoolean(ConfPaths.MOVING_NOFALL_RESETONVEHICLE); noFallAntiCriticals = config.getBoolean(ConfPaths.MOVING_NOFALL_ANTICRITICALS); noFallActions = config.getOptimizedActionList(ConfPaths.MOVING_NOFALL_ACTIONS, Permissions.MOVING_NOFALL); passableActions = config.getOptimizedActionList(ConfPaths.MOVING_PASSABLE_ACTIONS, Permissions.MOVING_PASSABLE); passableUntrackedTeleportCheck = config.getBoolean(ConfPaths.MOVING_PASSABLE_UNTRACKED_TELEPORT_ACTIVE); passableUntrackedCommandCheck = config.getBoolean(ConfPaths.MOVING_PASSABLE_UNTRACKED_CMD_ACTIVE); passableUntrackedCommandTryTeleport = config.getBoolean(ConfPaths.MOVING_PASSABLE_UNTRACKED_CMD_TRYTELEPORT);
final int maxBuildContained = defaultConfig.getMaxLastChangedBuildNumber(); final ConfigFile globalConfig = new ConfigFile(); globalConfig.setDefaults(defaultConfig); globalConfig.options().copyDefaults(true); if (globalFile.exists()){ try { globalConfig.load(globalFile); if (globalConfig.getBoolean(ConfPaths.SAVEBACKCONFIG)){ boolean overrideCreated = false; if (!globalConfig.contains(ConfPaths.CONFIGVERSION_CREATED)){ if (!overrideCreated && globalConfig.getInt(ConfPaths.CONFIGVERSION_CREATED, 0) >= 0 && ConfigManager.isConfigUpToDate(globalConfig, 0) == null) { globalConfig.set(ConfPaths.CONFIGVERSION_SAVED, maxBuildContained); if (overrideCreated) { globalConfig.set(ConfPaths.CONFIGVERSION_CREATED, maxBuildContained); globalConfig.save(globalFile); globalConfig.options().header("This configuration was auto-generated by NoCheatPlus."); globalConfig.options().copyHeader(true); try { globalConfig.set(ConfPaths.CONFIGVERSION_CREATED, maxBuildContained); globalConfig.set(ConfPaths.CONFIGVERSION_SAVED, maxBuildContained); globalConfig.save(globalFile); } catch (final Exception e) {
public AllViolationsConfig(ConfigFile config) { allToTrace = config.getBoolean(ConfPaths.LOGGING_EXTENDED_ALLVIOLATIONS_BACKEND_TRACE); allToNotify = config.getBoolean(ConfPaths.LOGGING_EXTENDED_ALLVIOLATIONS_BACKEND_NOTIFY); debug = config.getBoolean(ConfPaths.LOGGING_EXTENDED_ALLVIOLATIONS_DEBUG); debugOnly = config.getBoolean(ConfPaths.LOGGING_EXTENDED_ALLVIOLATIONS_DEBUGONLY) || debug && !allToTrace && !allToNotify; }
bedLeaveActions = config.getOptimizedActionList(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, Permissions.COMBINED_BEDLEAVE); enderPearlCheck = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_CHECK); enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK); improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL); improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE); invulnerableCheck = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_CHECK); invulnerableInitialTicksJoin = config.getInt(ConfPaths.COMBINED_INVULNERABLE_INITIALTICKS_JOIN); boolean error = false; for (final String input : config.getStringList(ConfPaths.COMBINED_INVULNERABLE_IGNORE)){ final String normInput = input.trim().toUpperCase(); try{ final ConfigurationSection sec = config.getConfigurationSection(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS); for (final String input : sec.getKeys(false)){ final int modifier = sec.getInt(input, 0); invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS); invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE); munchHausenActions = config.getOptimizedActionList(ConfPaths.COMBINED_MUNCHHAUSEN_ACTIONS, Permissions.COMBINED_MUNCHHAUSEN); yawRate = config.getInt(ConfPaths.COMBINED_YAWRATE_RATE); yawRateImprobable = config.getBoolean(ConfPaths.COMBINED_YAWRATE_IMPROBABLE); yawRatePenaltyFactor = (float) config.getDouble(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR); yawRatePenaltyMin = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MIN);
/** * Set instance members based on the given configuration. This is meant to * work after reloading the configuration too. * * @param config */ private void setInstanceMembers(final ConfigFile config) { configProblemsChat = ConfigManager.isConfigUpToDate(config, config.getInt(ConfPaths.CONFIGVERSION_NOTIFYMAXPATHS)); configProblemsFile = configProblemsChat == null ? null : ConfigManager.isConfigUpToDate(config, -1); clearExemptionsOnJoin = config.getBoolean(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_JOIN); clearExemptionsOnLeave = config.getBoolean(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_LEAVE); NCPExemptionManager.setExemptionSettings(new ExemptionSettings(config)); }
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 = BridgeMisc.getOnlinePlayers(); if (config.getBoolean(ConfPaths.LOGGING_EXTENDED_STATUS)) { logManager.info(Streams.STATUS, "Interrupted consistency checking until next tick.");
if (config.getBoolean(ConfPaths.PROTECT_PLUGINS_HIDE_ACTIVE)){ sender.sendMessage(ColorUtil.replaceColors(config.getString(ConfPaths.PROTECT_PLUGINS_HIDE_NOCOMMAND_MSG))); return true;
/** * Instantiates a new block interact configuration. * * @param data * the data */ public BlockInteractConfig(final IWorldData worldData) { super(worldData); final ConfigFile data = worldData.getRawConfiguration(); directionActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_DIRECTION_ACTIONS, Permissions.BLOCKINTERACT_DIRECTION); reachActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_REACH_ACTIONS, Permissions.BLOCKINTERACT_REACH); speedInterval = data.getLong(ConfPaths.BLOCKINTERACT_SPEED_INTERVAL); speedLimit = data.getInt(ConfPaths.BLOCKINTERACT_SPEED_LIMIT); speedActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_SPEED_ACTIONS, Permissions.BLOCKINTERACT_SPEED); visibleActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_VISIBLE_ACTIONS, Permissions.BLOCKINTERACT_VISIBLE); }
private void setupCommandProtection() { // TODO: Might re-check with plugins enabling during runtime (!). // 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)); // Setup and add changes to history for undoing. changedCommands.addAll(PermissionUtil.protectCommands( Permissions.FILTER_COMMAND.getLowerCaseStringRepresentation(), 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)); // Setup and add changes to history for undoing. changedCommands.addAll(PermissionUtil.protectCommands( Permissions.FILTER_COMMAND.getLowerCaseStringRepresentation(), noCommand, true, false, noCommandMsg)); } }
/** * Get a new ConfigFile instance with all paths removed (recursively by prefix). * @param config * @param removePaths * @return */ public static ConfigFile removePaths(final ConfigFile config, final Collection<String> removePaths) { final SimpleCharPrefixTree prefixes = new SimpleCharPrefixTree(); for (final String path : removePaths) { prefixes.feed(path); } final ConfigFile newConfig = new ConfigFile(); for (final Entry<String, Object> entry : config.getValues(true).entrySet()) { final String path = entry.getKey(); final Object value = entry.getValue(); // TODO: To support moving entire sections, this needs to be changed. if (value instanceof ConfigurationSection) { continue; } if (!prefixes.hasPrefix(path)) { newConfig.set(path, value); } } return newConfig; }
/** * Run all warning checks and alter the configuration file if necessary (GlobalConfig, Deprecated, Moved). * @param file * @param configName */ public static void processPaths(File file, String configName, boolean isWorldConfig) { ConfigFile config = new ConfigFile(); try { config.load(file); ConfigFile newConfig = processPaths(config, configName, isWorldConfig); if (newConfig != null) { config = newConfig; try{ config.save(file); } catch(Throwable t) { // Do log this one. StaticLog.logSevere("Failed to save configuration (" + configName + ") with changes: " + t.getClass().getSimpleName()); StaticLog.logSevere(t); } } } catch (FileNotFoundException e) { } catch (IOException e) { } catch (InvalidConfigurationException e) { } }
Object created_o = globalConfig.get(ConfPaths.CONFIGVERSION_CREATED); int buildCreated = -1; if (created_o != null && created_o instanceof Integer) { final int maxBuildContained = defaultConfig.getMaxLastChangedBuildNumber(); final Map<String, Integer> lastChangedBuildNumbers = defaultConfig.getLastChangedBuildNumbers(); final Object defaultValue = defaultConfig.get(path); if (defaultValue instanceof ConfigurationSection) { problems.add(path + (maxPaths >= 0 ? "" : (" - Changed with build " + defaultBuild + ", can not handle entire configuration sections yet. "))); continue; final Object currentValue = globalConfig.get(path); if (currentValue == null || defaultValue == null) {
@Override public void onReload() { aux.clear(); hoverTicksStep = Math.max(1, ConfigManager.getConfigFile().getInt(ConfPaths.MOVING_SURVIVALFLY_HOVER_STEP)); }
/** * 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 setActionFactory() { setActionFactory(NCPAPIProvider.getNoCheatPlusAPI().getActionFactoryFactory()); }