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

The following examples show how to use org.bukkit.configuration.file.YamlConfiguration#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: HelperProfilesPlugin.java    From helper with MIT License 6 votes vote down vote up
@Override
protected void enable() {
    SqlProvider sqlProvider = getService(SqlProvider.class);
    Sql sql;

    // load sql instance
    YamlConfiguration config = loadConfig("config.yml");
    if (config.getBoolean("use-global-credentials", true)) {
        sql = sqlProvider.getSql();
    } else {
        sql = sqlProvider.getSql(DatabaseCredentials.fromConfig(config));
    }

    // init the table
    String tableName = config.getString("table-name", "helper_profiles");
    int preloadAmount = config.getInt("preload-amount", 2000);

    // provide the ProfileRepository service
    provideService(ProfileRepository.class, bindModule(new HelperProfileRepository(sql, tableName, preloadAmount)));
}
 
Example 2
Source File: ListenerLogin.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
private void punish(Player player) {
    if(player == null) return;

    NPCManager npcManager = this.expansion.getNPCManager();
    YamlConfiguration data = npcManager.getData(player);
    if(!data.getBoolean("citizens-compatibility.punish-next-join")) return;
    
    Logger logger = this.expansion.getLogger();
    logger.info("Player Data Config: " + data.saveToString());
    
    npcManager.loadLocation(player);
    double health = npcManager.loadHealth(player);
    
    if(health > 0.0D) {
        npcManager.loadInventory(player);
        npcManager.loadTagStatus(player);
    }
    
    data.set("citizens-compatibility.punish-next-join", false);
    data.set("citizens-compatibility.last-location", null);
    data.set("citizens-compatibility.last-health", null);
    data.set("citizens-compatibility.last-inventory", null);
    data.set("citizens-compatibility.last-armor", null);
    npcManager.setData(player, data);
}
 
Example 3
Source File: ListenerNewbieProtection.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
private boolean isProtected(Player player) {
    if(player == null) return false;
    long firstJoinMillis = player.getFirstPlayed();
    if(firstJoinMillis == 0) return false;

    long systemMillis = System.currentTimeMillis();
    long subtract = (systemMillis - firstJoinMillis);

    FileConfiguration config = this.expansion.getConfig("newbie-helper.yml");
    long protectionTimeMillis = config.getLong("newbie-protection.protection-timer") * 1000L;
    if(subtract > protectionTimeMillis) {
        removeProtection(player);
        return false;
    }

    YamlConfiguration dataFile = this.plugin.getDataFile(player);
    if(!dataFile.isSet("newbie-helper.protected")) {
        dataFile.set("newbie-helper.protected", true);
        this.plugin.saveDataFile(player, dataFile);
    }
    return dataFile.getBoolean("newbie-helper.protected");
}
 
Example 4
Source File: ConnectionModule.java    From ExploitFixer with GNU General Public License v3.0 5 votes vote down vote up
public void reload(final Configuration configYml) {
	final YamlConfiguration configYml1 = (YamlConfiguration) configYml;

	this.uuidSpoofEnabled = configYml1.getBoolean("connection.uuidspoof");
	this.nullAddressEnabled = configYml1.getBoolean("connection.nulladdress");
	this.name = "UUID-Spoof";
	this.punishments = new HashSet<>(configYml1.getStringList("connection.punishments"));
}
 
Example 5
Source File: CommandsModule.java    From ExploitFixer with GNU General Public License v3.0 5 votes vote down vote up
public void reload(final Configuration configYml) {
	final YamlConfiguration configYml1 = (YamlConfiguration) configYml;

	this.name = "Commands";
	this.enabled = configYml1.getBoolean("commands.enabled");
	this.commands = configYml1.getStringList("commands.commands");
	this.punishments = configYml1.getStringList("commands.punishments");
}
 
Example 6
Source File: AttachmentYML.java    From QualityArmory with GNU General Public License v3.0 5 votes vote down vote up
public YamlConfiguration getBaseGunFile() {
	if(this.file==null)
		return null;
	File newGunFolder = new File(this.file.getParentFile().getParentFile(), "newGuns");
	for (File f : newGunFolder.listFiles()) {
		YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
		if (!config.contains("invalid") || !config.getBoolean("invalid"))
			if (config.contains("name")) {
				if (config.getString("name").equalsIgnoreCase(getBaseGun())) {
					return config;
				}
			}
	}
	return null;
}
 
Example 7
Source File: ListenerCustomDeath.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onJoin(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    YamlConfiguration playerData = this.plugin.getDataFile(player);
    if(!playerData.getBoolean("kill-on-join")) return;

    add(player);
    player.setHealth(0.0D);
}
 
Example 8
Source File: ListenerNewbieProtection.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private void removeProtection(Player player) {
    if(player == null) return;

    YamlConfiguration dataFile = this.plugin.getDataFile(player);
    if(!dataFile.getBoolean("newbie-helper.protected", true)) return;

    dataFile.set("newbie-helper.protected", false);
    this.plugin.saveDataFile(player, dataFile);

    String message = this.plugin.getLanguageMessageColoredWithPrefix("newbie-helper.protection-disabled.expired");
    this.plugin.sendMessage(player, message);
}
 
Example 9
Source File: ListenerPVP.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public boolean isPVPEnabled(Player player) {
    if(player == null) return false;

    YamlConfiguration playerData = this.plugin.getDataFile(player);
    return playerData.getBoolean("pvp", true);
}