Java Code Examples for org.bukkit.configuration.Configuration#getConfigurationSection()

The following examples show how to use org.bukkit.configuration.Configuration#getConfigurationSection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PacketsModule.java    From ExploitFixer with GNU General Public License v3.0 7 votes vote down vote up
final public void reload(final Configuration configYml) {
	final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers");
	final String name = "packets";

	this.name = "Packets";
	this.enabled = configYml.getBoolean(name + ".enabled");
	this.cancelVls = configYml.getDouble(name + ".cancel_vls");
	this.reduceVls = configYml.getDouble(name + ".reduce_vls");
	this.offline = configYml.getBoolean(name + ".offline");
	this.dataVls = configYml.getDouble(name + ".data.vls");
	this.dataBytes = configYml.getInt(name + ".data.bytes", 24000);
	this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268);
	this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47);
	this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200);
	this.windowClick = configYml.getDouble(name + ".window_click");
	this.blockPlaceVls = configYml.getDouble(name + ".block_place");
	this.blockDigVls = configYml.getDouble(name + ".block_dig");
	this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot");
	this.violations = new Violations(configYml.getConfigurationSection(name + ".violations"));

	for (final String key : configurationSection.getKeys(false))
		multipliers.put(key, configurationSection.getDouble(key));
}
 
Example 2
Source File: CustomPayloadModule.java    From ExploitFixer with GNU General Public License v3.0 6 votes vote down vote up
public void reload(final Configuration configYml) {
	final ConfigurationSection configurationSection = configYml
			.getConfigurationSection("custompayload.multipliers");
	final String name = getName().toLowerCase();

	this.enabled = configYml.getBoolean(name + ".enabled");
	this.cancelVls = configYml.getDouble(name + ".cancel_vls");
	this.reduceVls = configYml.getDouble(name + ".reduce_vls");
	this.bookVls = configYml.getDouble(name + ".book.vls");
	this.bookBytes = configYml.getInt(name + ".book.bytes");
	this.violations = new Violations(configYml.getConfigurationSection(name + ".violations"));
	this.channelVls = configYml.getDouble(name + ".channel.vls");
	this.channelAmount = configYml.getInt(name + ".channel.amount");
	this.dataVls = configYml.getDouble(name + ".data.vls");
	this.dataBytes = configYml.getInt(name + ".data.bytes");
	this.tagVls = configYml.getDouble(name + ".tag.vls");

	for (final String key : configurationSection.getKeys(false)) {
		multipliers.put(key, configurationSection.getDouble(key));
	}
}
 
Example 3
Source File: QuotaConfig.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Inject QuotaConfig(Configuration root) {
    this.config = root.getConfigurationSection("match-quotas");
    if(config == null) {
        quotas = new TreeSet<>();
    } else {
        quotas = new TreeSet<>(Collections2.transform(
            config.getKeys(false),
            new Function<String, Entry>() {
                @Override
                public Entry apply(@Nullable String key) {
                    return new Entry(config.getConfigurationSection(key));
                }
            }
        ));
    }
}
 
Example 4
Source File: FileRotationProviderFactory.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) {
    ConfigurationSection base = config.getConfigurationSection("rotation.providers.file");
    if(base == null) return Collections.emptySet();

    Set<RotationProviderInfo> providers = new HashSet<>();
    for(String name : base.getKeys(false)) {
        ConfigurationSection provider = base.getConfigurationSection(name);

        Path rotationFile = Paths.get(provider.getString("path"));
        if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile);

        int priority = provider.getInt("priority", 0);

        if(Files.isRegularFile(rotationFile)) {
            providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority));
        } else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) {
            // This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now
            mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile);
        }
    }

    return providers;
}
 
Example 5
Source File: SignLayoutConfiguration.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void inflateUnsafe(Configuration config, Object[] args) throws ParseException {
	List<String> lines = Lists.newArrayList();
	
	ConfigurationSection layoutSection = config.getConfigurationSection("layout");
	
	for (int i = 1; i <= SignLayout.LINE_COUNT; i++) {
		String line = layoutSection.getString(String.valueOf(i));
		lines.add(line);
	}
	
	layout = new SignLayout(lines);
	
	if (config.contains("options")) {
		options = config.getConfigurationSection("options");
	}
}
 
Example 6
Source File: DatabaseConfig.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void inflate(Configuration config, Object... args) {
	Validate.isTrue(args.length > 0, "args.length must be greater than 0");
	Validate.isTrue(args[0] instanceof File, "args[0] must be an instance of " + File.class.getCanonicalName());
	
	File baseDir = (File) args[0];
	
	ConfigurationSection moduleSection = config.getConfigurationSection("database-modules");
	this.statisticsEnabled = moduleSection.getBoolean("statistics.enabled");
	this.maxStatisticCacheSize = moduleSection.getInt("statistics.max-cache-size", DEFAULT_MAX_CACHE_SIZE);
	
	this.connections = Lists.newArrayList();
	ConfigurationSection connectionsSection = config.getConfigurationSection("persistence-connection");
	
	for (String key : connectionsSection.getKeys(false)) {
		connections.add(new DatabaseConnection(connectionsSection.getConfigurationSection(key), baseDir));
	}
}
 
Example 7
Source File: InventoryEntryConfig.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
public final void inflateUnsafe(Configuration config, Object[] args) throws ParseException {
	ConfigurationSection layoutSection = config.getConfigurationSection("layout");
	String title;
	List<String> lore;
	
	if (layoutSection != null) {
		title = layoutSection.getString("title", DEFAULT_TITLE);
		lore = layoutSection.getStringList("lore");
		
		if (lore == null || lore.isEmpty()) {
			lore = DEFAULT_LORE;
		}
	} else {
		title = DEFAULT_TITLE;
		lore = DEFAULT_LORE;
	}
	
	layout = new InventoryEntryLayout(title, lore);
}
 
Example 8
Source File: StartConfig.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Inject StartConfig(Configuration root) {
    this.config = root.getConfigurationSection("start");
}
 
Example 9
Source File: Utils.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initialize the utilities class with constants.
 * @param pluginConfig The config of the plugin
 */
public static void initialize(YamlConfiguration pluginConfig) {
	config = pluginConfig;

	// Setup individual identifiers
	seconds = getSetAndDefaults("seconds");
	minutes = getSetAndDefaults("minutes");
	hours = getSetAndDefaults("hours");
	days = getSetAndDefaults("days");
	weeks = getSetAndDefaults("weeks");
	months = getSetAndDefaults("months");
	years = getSetAndDefaults("years");
	// Setup all time identifiers
	identifiers = new HashSet<>();
	identifiers.addAll(seconds);
	identifiers.addAll(minutes);
	identifiers.addAll(hours);
	identifiers.addAll(days);
	identifiers.addAll(weeks);
	identifiers.addAll(months);
	identifiers.addAll(years);

	suffixes = new HashMap<>();
	// This stuff should not be necessary, but it is, getConfigurationSection() does not do proper fallback to defaults!
	// TODO: Create a custom configuration that fixes this behavior
	ConfigurationSection suffixesSection = null;
	if(config.isSet("metricSymbols")) {
		suffixesSection = config.getConfigurationSection("metricSymbols");
	} else {
		Configuration defaults = config.getDefaults();
		if(defaults != null) {
			suffixesSection = defaults.getConfigurationSection("metricSymbols");
		}
	}
	if(suffixesSection != null) {
		for(String key : suffixesSection.getKeys(false)) {
			try {
				suffixes.put(Double.parseDouble(key), suffixesSection.getString(key));
			} catch(NumberFormatException e) {
				Log.warn("Key '" + key + "' in the metricSymbols section of config.yml is not a number!");
			}
		}
	}
}
 
Example 10
Source File: DefaultConfig.java    From HeavySpleef with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void inflate(Configuration config, Object... args) {
	ConfigurationSection generalSection = config.getConfigurationSection("general");
	this.generalSection = new GeneralSection(generalSection);
	
	ConfigurationSection queueSection = config.getConfigurationSection("queues");
	this.queueSection = new QueueSection(queueSection);
	
	defaultGameProperties = new EnumMap<GameProperty, Object>(GameProperty.class);
	ConfigurationSection propsSection = config.getConfigurationSection("default-game-properties");
	Set<String> keys = propsSection.getKeys(false);
	
	for (GameProperty property : GameProperty.values()) {
		for (String key : keys) {
			GameProperty mappedProperty = mapPropertyString(key);
			Object value;
			
			if (mappedProperty != null) {
				value = propsSection.get(key, mappedProperty.getDefaultValue());
			} else {
				value = property.getDefaultValue();
			}
			
			defaultGameProperties.put(mappedProperty, value);
		}
	}
	
	ConfigurationSection localizationSection = config.getConfigurationSection("localization");
	this.localization = new Localization(localizationSection);
	
	ConfigurationSection flagSection = config.getConfigurationSection("flags");
	this.flagSection = new FlagSection(flagSection);
	
	ConfigurationSection signSection = config.getConfigurationSection("signs");
	this.signSection = new SignSection(signSection);

       ConfigurationSection spectateSection = config.getConfigurationSection("spectate");
       this.spectateSection = new SpectateSection(spectateSection);

       ConfigurationSection lobbySection = config.getConfigurationSection("lobby");
       this.lobbySection = new LobbySection(lobbySection);
	
	ConfigurationSection updateSection = config.getConfigurationSection("update");
	this.updateSection = new UpdateSection(updateSection);
	
	this.configVersion = config.getInt("config-version", CURRENT_CONFIG_VERSION);
}