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

The following examples show how to use org.bukkit.configuration.Configuration#getInt() . 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: HeavySpleef.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
private void checkConfigVersions(Configuration config, Path dataFolder) {
	if (config.getInt("config-version") < DefaultConfig.CURRENT_CONFIG_VERSION) {
		Path configSource = dataFolder.resolve(ConfigType.DEFAULT_CONFIG.getDestinationFileName());
		Path configTarget = dataFolder.resolve("config_old.yml");
		
		try {
			Files.move(configSource, configTarget, StandardCopyOption.REPLACE_EXISTING);
			URL configResource = getClass().getResource(ConfigType.DEFAULT_CONFIG.getClasspathResourceName());
			
			copyResource(configResource, configSource.toFile());
			
			ConsoleCommandSender sender = Bukkit.getConsoleSender();
			sender.sendMessage(ChatColor.RED + "Due to a HeavySpleef update your old configuration has been renamed");
			sender.sendMessage(ChatColor.RED + "to config_old.yml and a new one has been generated. Make sure to");
			sender.sendMessage(ChatColor.RED + "apply your old changes to the new config");
		} catch (IOException e) {
			getLogger().log(Level.SEVERE, "Could not create updated configuration due to an IOException", e);
		}
	}
}
 
Example 4
Source File: BungeemodeAddon.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkCopyConfig() throws IOException {
	File file = new File(getDataFolder(), CONFIG_FILE_NAME);
	if (file.exists()) {
		Configuration config = YamlConfiguration.loadConfiguration(file);
		int version = config.getInt("config-version");
		
		if (version < BungeemodeConfig.CURRENT_CONFIG_VERSION) {
			Path dataFolderPath = getDataFolder().toPath();
			Files.move(file.toPath(), dataFolderPath.resolve("config_old.yml"), StandardCopyOption.REPLACE_EXISTING);
			return true;
		}
	} else {
		return true;
	}
	
	return false;
}
 
Example 5
Source File: ItemsFixModule.java    From ExploitFixer with GNU General Public License v3.0 5 votes vote down vote up
final public void reload(final Configuration configYml) {
	final String name = getName().toLowerCase();

	this.enabled = configYml.getBoolean(name + ".enabled", true);
	this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10);
	this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64);
	this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist"));
}
 
Example 6
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);
}
 
Example 7
Source File: ItemQualityColorizer.java    From EliteMobs with GNU General Public License v3.0 3 votes vote down vote up
private static int enchantMaxValueGetter(String boolString, String maxLevelString) {

        Configuration configuration = ConfigValues.itemsProceduralSettingsConfig;

        if (configuration.getBoolean(boolString)) {

            return configuration.getInt(maxLevelString);

        }

        return 0;

    }