Java Code Examples for org.bukkit.configuration.ConfigurationSection#getBoolean()

The following examples show how to use org.bukkit.configuration.ConfigurationSection#getBoolean() . 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: Spell.java    From Civs with GNU General Public License v3.0 7 votes vote down vote up
public boolean useAbilityFromListener(Player caster, int level, ConfigurationSection useSection, Object newTarget) {
    HashMap<String, Set<?>> mappedTargets = new HashMap<>();
    HashSet<LivingEntity> tempSet = new HashSet<>();
    tempSet.add(caster);
    mappedTargets.put("self", tempSet);
    HashSet<Object> tempTarget = new HashSet<>();
    tempTarget.add(newTarget);
    mappedTargets.put("target", tempTarget);
    SpellType spellType = (SpellType) ItemManager.getInstance().getItemType(type);

    ConfigurationSection targetSections = spellType.getConfig().getConfigurationSection("targets");
    for (String key : targetSections.getKeys(false)) {
        ConfigurationSection targetSection = targetSections.getConfigurationSection(key);
        String targetName = targetSection.getString("type", "nearby");
        Target abilityTarget = SpellType.getTarget(targetName, key, targetSection, level, caster, this);
        if (abilityTarget == null) {
            continue;
        }
        mappedTargets.put(key, abilityTarget.getTargets());
        if (targetSection.getBoolean("cancel-if-empty", false) && mappedTargets.get(key).isEmpty()) {
            return false;
        }
    }

    useAbility(mappedTargets, true, new HashMap<String, ConfigurationSection>());

    return useSection.getBoolean("cancel", false);
}
 
Example 2
Source File: AnniSign.java    From AnnihilationPro with MIT License 6 votes vote down vote up
public AnniSign(ConfigurationSection configSection)
{
	if(configSection == null)
		throw new NullPointerException();
	
	boolean signpost = configSection.getBoolean("isSignPost");
	//Location loc = ConfigManager.getLocation(configSection.getConfigurationSection("Location"));
	Loc loc = new Loc(configSection.getConfigurationSection("Location"));
	BlockFace facing = BlockFace.valueOf(configSection.getString("FacingDirection"));	
	obj = new FacingObject(facing, loc);
	this.signPost = signpost;
	String data = configSection.getString("Data");
	if(data.equalsIgnoreCase("Brewing"))
		type = SignType.Brewing;
	else if(data.equalsIgnoreCase("Weapon"))
		type = SignType.Weapon;
	else
		type = SignType.newTeamSign(AnniTeam.getTeamByName(data.split("-")[1]));
}
 
Example 3
Source File: CustomItem.java    From NBTEditor with GNU General Public License v3.0 6 votes vote down vote up
protected void applyConfig(ConfigurationSection section) {
	_enabled = section.getBoolean("enabled");
	_name = section.getString("name");

	ItemMeta meta = _item.getItemMeta();
	if (meta instanceof BookMeta) {
		((BookMeta) meta).setTitle(_name);
	} else {
		meta.setDisplayName(_name);
	}
	meta.setLore(section.getStringList("lore"));
	_item.setItemMeta(meta);

	List<String> allowedWorlds = section.getStringList("allowed-worlds");
	if (allowedWorlds == null || allowedWorlds.size() == 0) {
		List<String> blockedWorlds = section.getStringList("blocked-worlds");
		_blockedWorlds = (blockedWorlds.size() > 0 ? new HashSet<String>(blockedWorlds) : null);
		_allowedWorlds = null;
	} else {
		_allowedWorlds = new HashSet<String>(allowedWorlds);
	}
}
 
Example 4
Source File: GeneralSection.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
public GeneralSection(ConfigurationSection section) {
	String prefix = section.getString("spleef-prefix");
	if (prefix != null) {
		this.spleefPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, prefix);
	} else {
		this.spleefPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + ChatColor.BOLD + "Spleef" + ChatColor.DARK_GRAY + "]";
	}
	
	this.whitelistedCommands = section.getStringList("command-whitelist");
	String vipPrefix = section.getString("vip-prefix");
	if (vipPrefix != null) {
		this.vipPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, vipPrefix);
	} else {
		this.vipPrefix = ChatColor.RED.toString();
	}
	
	this.vipJoinFull = section.getBoolean("vip-join-full", true);
	this.pvpTimer = section.getInt("pvp-timer", 0);
	this.broadcastGameStart = section.getBoolean("broadcast-game-start", true);
	this.broadcastGameStartBlacklist = section.getStringList("broadcast-game-start-blacklist");
	this.winMessageToAll = section.getBoolean("win-message-to-all", true);
       this.warmupMode = section.getBoolean("warmup-mode", false);
       this.warmupTime = section.getInt("warmup-time", 10);
       this.adventureMode = section.getBoolean("adventure-mode", true);
}
 
Example 5
Source File: CooldownEffect.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
public CooldownEffect(Spell spell, String key, Object target, Entity origin, int level, ConfigurationSection section) {
    super(spell, key, target, origin, level, section);
    String configDamage = section.getString("cooldown", "5000");
    this.silent = section.getBoolean("silent", false);
    this.cooldown = (int) Math.round(Spell.getLevelAdjustedValue(configDamage, level, target, spell));
    String tempTarget = section.getString("target", "not-a-string");
    String abilityName = section.getString("ability", "not-a-string");
    if (!tempTarget.equals("not-a-string")) {
        this.target = tempTarget;
    } else {
        this.target = "self";
    }
    if (!abilityName.equals("not-a-string")) {
        this.abilityName = abilityName;
    } else {
        this.abilityName = "self";
    }
    this.config = section;
}
 
Example 6
Source File: WorldMatcher.java    From UHC with MIT License 6 votes vote down vote up
public WorldMatcher(ConfigurationSection section, List<String> worldsDefault, boolean isWhitelistDefault) {
    if (!section.contains(WORLDS_KEY)) {
        section.set(WORLDS_KEY, worldsDefault);
    }

    if (!section.contains(IS_WHITELIST_KEY)) {
        section.set(IS_WHITELIST_KEY, isWhitelistDefault);
    }

    worlds = ImmutableSet.copyOf(
            Iterables.filter(
                    Iterables.transform(section.getStringList(WORLDS_KEY), TO_LOWER_CASE),
                    Predicates.notNull()
            )
    );
    isWhitelist = section.getBoolean(IS_WHITELIST_KEY);
}
 
Example 7
Source File: DurabilityMaterial.java    From ObsidianDestroyer with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isEnabled(ConfigurationSection section) {
    if (section.contains("Durability")) {
        if (section.contains("Durability.Enabled") && section.contains("Durability.Amount")) {
            return section.getBoolean("Durability.Enabled") && section.getInt("Durability.Amount") > 0;
        }
    }
    return false;
}
 
Example 8
Source File: FallEffect.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public FallEffect(Spell spell, String key, Object target, Entity origin, int level, ConfigurationSection section) {
    super(spell, key, target, origin, level, section);
    String configDistance = section.getString("distance", "0");
    this.distance = Math.round(Spell.getLevelAdjustedValue(configDistance, level, target, spell));
    String tempTarget = section.getString("target", "not-a-string");
    this.setFall = section.getBoolean("set", false);
    this.silent = section.getBoolean("silent", false);
    if (!tempTarget.equals("not-a-string")) {
        this.target = tempTarget;
    } else {
        this.target = "self";
    }
}
 
Example 9
Source File: TeleportEffect.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public TeleportEffect(Spell spell, String key, Object target, Entity origin, int level, ConfigurationSection section) {
    super(spell, key, target, origin, level, section);
    String tempTarget = section.getString("target", "not-a-string");
    this.x = section.getDouble("x",0);
    this.y = section.getDouble("y",0);
    this.z = section.getDouble("z",0);
    this.setPos = section.getBoolean("set", false);
    this.other = section.getBoolean("other", false);
    if (!tempTarget.equals("not-a-string")) {
        this.target = tempTarget;
    } else {
        this.target = "self";
    }
}
 
Example 10
Source File: SaneEconomyConfiguration.java    From SaneEconomy with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Load database host, port, username, password, and db name from a ConfigurationSection
 * @param config ConfigurationSection containing the right fields.
 * @return DatabaseCredentials with the information from the config.
 */
private DatabaseCredentials loadCredentials(ConfigurationSection config) {
    String databaseType = config.getString("type", "mysql");
    String backendHost = config.getString("host");
    int backendPort = config.getInt("port", 3306);
    String backendDb = config.getString("database");
    String backendUser = config.getString("username");
    String backendPass = config.getString("password");
    String tablePrefix = config.getString("table_prefix", "");
    boolean useSsl = config.getBoolean("use_ssl", false);

    return new DatabaseCredentials(
               databaseType, backendHost, backendPort, backendUser, backendPass, backendDb, tablePrefix, useSsl
           );
}
 
Example 11
Source File: ChallengeFactory.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static ChallengeDefaults createDefaults(ConfigurationSection section) {
    return new ChallengeDefaults(
            section.getInt("defaultResetInHours", 144),
            section.getBoolean("requiresPreviousRank", true),
            normalize(section.getString("repeatableColor", "&a")),
            normalize(section.getString("finishedColor", "&2")),
            normalize(section.getString("challengeColor", "&e")),
            section.getInt("rankLeeway", 1),
            section.getBoolean("enableEconomyPlugin", true),
            section.getBoolean("broadcastCompletion", true),
            section.getInt("radius", 10), section.getBoolean("showLockedChallengeName", true),
            section.getInt("repeatLimit", 0));
}
 
Example 12
Source File: UHC.java    From UHC with MIT License 4 votes vote down vote up
protected void setupTeamCommands() {
    final Optional<TeamModule> teamModuleOptional = registry.get(TeamModule.class);

    if (!teamModuleOptional.isPresent()) {
        getLogger().info("Skipping registering team commands as the team module is not loaded");
        setupCommand(
                dummyCommands.forModule("TeamModule"),
                "teams", "team", "noteam", "pmt", "randomteams", "clearteams", "tc", "teamrequest"
        );
        return;
    }

    final TeamModule teamModule = teamModuleOptional.get();

    setupCommand(new ListTeamsCommand(commandMessages("teams"), teamModule), "teams");
    setupCommand(new NoTeamCommand(commandMessages("noteam"), teamModule), "noteam");
    setupCommand(new TeamPMCommand(commandMessages("pmt"), teamModule), "pmt");
    setupCommand(new RandomTeamsCommand(commandMessages("randomteams"), teamModule), "randomteams");
    setupCommand(new ClearTeamsCommand(commandMessages("clearteams"), teamModule), "clearteams");
    setupCommand(new TeamCoordinatesCommand(commandMessages("tc"), teamModule), "tc");

    final SubcommandCommand team = new SubcommandCommand();
    team.registerSubcommand("teamup", new TeamupCommand(commandMessages("team.teamup"), teamModule));
    team.registerSubcommand("add", new TeamAddCommand(commandMessages("team.add"), teamModule));
    team.registerSubcommand("remove", new TeamRemoveCommand(commandMessages("team.remove"), teamModule));
    setupCommand(team , "team");

    final ConfigurationSection teamModuleConfig = teamModule.getConfig();
    if (!teamModuleConfig.isSet(RequestManager.AUTO_WHITELIST_KEY)) {
        teamModuleConfig.set(RequestManager.AUTO_WHITELIST_KEY, true);
    }
    final boolean autoWhitelistAcceptedTeams = teamModuleConfig.getBoolean(RequestManager.AUTO_WHITELIST_KEY);

    final MessageTemplates requestMessages = commandMessages("team.teamrequest");
    final RequestManager requestManager = new RequestManager(
            this,
            requestMessages,
            teamModule,
            20 * 120,
            autoWhitelistAcceptedTeams
    );

    final SubcommandCommand teamrequest = new SubcommandCommand();
    teamrequest.registerSubcommand(
            "accept",
            new RequestResponseCommand(requestMessages, requestManager, RequestManager.AcceptState.ACCEPT)
    );
    teamrequest.registerSubcommand(
            "deny",
            new RequestResponseCommand(requestMessages, requestManager, RequestManager.AcceptState.DENY)
    );
    teamrequest.registerSubcommand("request", new TeamRequestCommand(requestMessages, requestManager));
    teamrequest.registerSubcommand("list", new RequestListCommand(requestMessages, requestManager));
    setupCommand(teamrequest, "teamrequest");
}
 
Example 13
Source File: GameVars.java    From AnnihilationPro with MIT License 4 votes vote down vote up
public static void loadGameVars(ConfigurationSection config)
	{
		if(config != null)
		{
			useMOTD = config.getBoolean("useMOTD");
			endOfGameCountdown = config.getInt("End-Of-Game-Countdown");
			String command = config.getString("EndGameCommand");
			if(command != null)
				endGameCommand = command.trim();
			//killOnLeave = config.getBoolean("Kill-On-Leave");
			ConfigurationSection gameVars = config.getConfigurationSection("GameVars");
			if(gameVars != null)
			{		
				ConfigurationSection auto = gameVars.getConfigurationSection("AutoStart");
				AutoStart = auto.getBoolean("On");//auto.set("On", false);
				PlayerstoStart = auto.getInt("PlayersToStart");//auto.set("PlayersToStart", 4);
				CountdowntoStart = auto.getInt("CountdownTime");
				
				ConfigurationSection mapload = gameVars.getConfigurationSection("MapLoading");
				Voting = mapload.getBoolean("Voting");//mapload.set("Voting", true);
				maxVotingMaps = mapload.getInt("Max-Maps-For-Voting");
				Map = mapload.getString("UseMap");//mapload.set("UseMap", "plugins/Annihilation/Worlds/Test");
				
				ConfigurationSection autorestart = gameVars.getConfigurationSection("AutoRestart");
				AutoReStart = autorestart.getBoolean("On");//autorestart.set("On", false);
				PlayersToRestart = autorestart.getInt("PlayersToAutoRestart");//autorestart.set("PlayersToAutoRestart", 0);
				CountdowntoRestart = autorestart.getInt("CountdownTime");
				
				ConfigurationSection balance = gameVars.getConfigurationSection("Team-Balancing");
				useTeamBalance = balance.getBoolean("On");//autorestart.set("On", false);
				balanceTolerance = balance.getInt("Tolerance");//autorestart.set("PlayersToAutoRestart", 0);

                ConfigurationSection antilog = gameVars.getConfigurationSection("Anti-Log-System");
                useAntiLog = antilog.getBoolean("On");//autorestart.set("On", false);
                npcTimeout = antilog.getInt("NPC-Time");//autorestart.set("PlayersToAutoRestart", 0);
			
				String gamemode = gameVars.getString("DefaultGameMode");
				if(gamemode != null)
				{
					try
					{
						defaultGamemode = GameMode.valueOf(gamemode.toUpperCase());
					}
					catch(Exception e)
					{
						defaultGamemode = GameMode.ADVENTURE;
					}
				}
			}
		}
		File worldFolder = new File(AnnihilationMain.getInstance().getDataFolder().getAbsolutePath()+"/Worlds");
		if(!worldFolder.exists())
			worldFolder.mkdir();
//		tempWorldPath = AnnihilationMain.getInstance().getDataFolder().getAbsolutePath()+"/TempWorld";
//		worldFolder = new File(tempWorldPath);
//		if(!worldFolder.exists())
//			worldFolder.mkdir();
	}
 
Example 14
Source File: Config.java    From MCAuthenticator with GNU General Public License v3.0 4 votes vote down vote up
public Config(MCAuthenticator auth, ConfigurationSection section) throws SQLException, IOException {
    List<String> authenticators = section.getStringList("authenticators");
    this.authenticators = new HashSet<>();
    if (authenticators.contains("2fa")) {
        auth.getLogger().info("Using RFC6238 (Google Authenticator 2FA) based authentication.");
        String tempServerIP;
        tempServerIP = section.getString("2fa.serverIp", section.getString("serverIp"));
        if (tempServerIP == null) {
            auth.getLogger().info("Your serverIp within your MCAuthenticator configuration is not set! It defaults " +
                    "'MCAuthenticator', but you should consider changing it to your server name!");
            tempServerIP = "MCAuthenticator";
        }
        this.authenticators.add(new RFC6238(tempServerIP, auth));
    }
    if (authenticators.contains("yubikey")) {
        Integer clientId = section.getInt("yubikey.clientId");
        String clientSecret = section.getString("yubikey.clientSecret");
        auth.getLogger().info("Using Yubikey based authenticator.");
        if(clientSecret == null || (clientId == -1 && "secret".equals(clientSecret))) {
            auth.getLogger().warning("The Yubikey configuration appears to be the default configuration/not configured!" +
                    " In order for the Yubikey authentication to work, you must retrieve a client id and secret.");
            auth.getLogger().warning("These may be retrieved from here: https://upgrade.yubico.com/getapikey/");
        }
        this.authenticators.add(new Yubikey(clientId, clientSecret, auth));
    }

    String backing = section.getString("dataBacking.type", "single");
    switch (backing) {
        case "single":
            this.dataSource = new SingleFileUserDataSource(new File(auth.getDataFolder(), section.getString("dataBacking.file", "playerData.json")));
            break;
        case "directory":
            this.dataSource = new DirectoryUserDataSource(new File(auth.getDataFolder(), section.getString("dataBacking.directory", "playerData")));
            break;
        case "mysql":
            ConfigurationSection mysql = section.getConfigurationSection("dataBacking.mysql");
            this.dataSource = new MySQLUserDataSource(mysql.getString("url", "jdbc:mysql://localhost:3306/db"),
                    mysql.getString("username"),
                    mysql.getString("password"),
                    mysql.getInt("queryTimeout", 0));
            break;
        default:
            throw new IllegalArgumentException("The dataBacking type '" + backing + "' doesn't exist.");
    }

    auth.getLogger().info("Using data source: " + dataSource.toString());

    this.enforceSameIPAuth = section.getBoolean("forceSameIPAuthentication", false);

    this.inventoryTampering = section.getBoolean("inventoryTampering", true);

    if (section.getBoolean("bungee.enabled", false))
        this.bungeePluginChannel = section.getString("bungee.channel", "MCAuthenticator");
    else this.bungeePluginChannel = null;

    this.messages = new HashMap<>();
    ConfigurationSection msgCfg = section.getConfigurationSection("messages");
    for (String key : msgCfg.getKeys(false)) {
        if (key.equals("prefix")) {
            this.prefix = color(msgCfg.getString(key));
        }
        this.messages.put(key, color(msgCfg.getString(key)));
    }
}
 
Example 15
Source File: GenericBomb.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void applyConfig(ConfigurationSection section) {
	super.applyConfig(section);
	_fuse = section.getInt("fuse", 40);
	_triggerOnDrop = section.getBoolean("trigger-on-drop", false);
}
 
Example 16
Source File: TropicalGeneratorTool.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void applyConfig(ConfigurationSection section) {
	super.applyConfig(section);
	_count = section.getInt("count", _count);
	_dropItems = section.getBoolean("drop-items", _dropItems);
}
 
Example 17
Source File: AntiMatterBomb.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void applyConfig(ConfigurationSection section) {
	super.applyConfig(section);
	_cleanup = section.getBoolean("cleanup", true);
}
 
Example 18
Source File: ConfigManager.java    From ObsidianDestroyer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Translates the materials.yml from memory into a map for quick access
 *
 * @return map of materials keys and material durability data
 */
public Map<String, DurabilityMaterial> getDurabilityMaterials() {
    final long time = System.currentTimeMillis();
    final ConfigurationSection section = materials.getConfigurationSection("HandledMaterials");
    int errorDuraCount = 0;
    int invalidDuraCount = 0;
    int disabledDuraCount = 0;
    Map<String, DurabilityMaterial> durabilityMaterials = new HashMap<>();
    for (String durabilityMaterial : section.getKeys(false)) {
        try {
            final ConfigurationSection materialSection = section.getConfigurationSection(durabilityMaterial);
            Material material = Material.matchMaterial(durabilityMaterial);
            if (material == null) {
                material = Material.matchMaterial(durabilityMaterial, true);
                if (material == null) {
                    if (DurabilityMaterial.isEnabled(materialSection)) {
                        ObsidianDestroyer.LOG.log(Level.WARNING, "Invalid Material Type: Unable to load ''{0}''", durabilityMaterial);
                    }
                    invalidDuraCount++;
                    continue;
                } else {
                    ObsidianDestroyer.LOG.log(Level.WARNING, "Semi-Valid Material Type: Loaded as ''{0}''", material.name());
                }
            }
            if (!Util.isSolid(material) && !materialSection.contains("HandleNonSolid") && !materialSection.getBoolean("HandleNonSolid")) {
                ObsidianDestroyer.LOG.log(Level.WARNING, "Non-Solid Material Type: Did not load ''{0}''", durabilityMaterial);
                invalidDuraCount++;
                continue;
            }
            final DurabilityMaterial durablock;
            if (materialSection.contains("MetaData")) {
                durablock = new DurabilityMaterial(material, materialSection.getInt("MetaData"), materialSection);
            } else {
                durablock = new DurabilityMaterial(material, materialSection);
            }
            if (durablock.getEnabled()) {
                if (getVerbose() || getDebug()) {
                    ObsidianDestroyer.LOG.log(Level.INFO, "Loaded durability of ''{0}'' for ''{1}''", new Object[]{durablock.getDurability(), durablock.toString()});
                }
                durabilityMaterials.put(durablock.toString(), durablock);
            } else if (getDebug()) {
                ObsidianDestroyer.debug("Disabled durability of '" + durablock.getDurability() + "' for '" + durablock.toString() + "'");
                disabledDuraCount++;
            }
        } catch (Exception e) {
            ObsidianDestroyer.LOG.log(Level.SEVERE, "Failed loading material ''{0}''", durabilityMaterial);
            errorDuraCount++;
        }
    }
    ObsidianDestroyer.LOG.log(Level.INFO, "Loaded and enabled ''{0}'' material durabilities from config in ''{1}'' ms.", new Object[]{durabilityMaterials.size(), (System.currentTimeMillis() - time)});
    ObsidianDestroyer.LOG.log(Level.INFO, "Material in Error: ''{0}''  Invalid: ''{1}''  Disabled: ''{2}''", new Object[]{errorDuraCount, invalidDuraCount, disabledDuraCount});
    return durabilityMaterials;
}
 
Example 19
Source File: VectorTransform.java    From EffectLib with MIT License 4 votes vote down vote up
public VectorTransform(ConfigurationSection configuration) {
    xTransform = Transforms.loadTransform(configuration, "x");
    yTransform = Transforms.loadTransform(configuration, "y");
    zTransform = Transforms.loadTransform(configuration, "z");
    orient = configuration.getBoolean("orient", true);
}
 
Example 20
Source File: QuickShopItemMatcherImpl.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
private void addIfEnable(ConfigurationSection itemMatcherConfig, String path, Matcher matcher) {
    if (itemMatcherConfig.getBoolean(path)) {
        matcherList.add(matcher);
    }
}