org.bukkit.configuration.file.FileConfiguration#getBoolean ( )源码实例Demo

下面列出了org.bukkit.configuration.file.FileConfiguration#getBoolean ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MineTinker   文件: ArmorListener.java
private void expCalculation(boolean isBlocking, ItemStack tool, EntityDamageEvent event, Player player) {
	//Armor should not get Exp when successfully blocking
	if(isBlocking && !ToolType.SHIELD.contains(tool.getType()) && ToolType.ARMOR.contains(tool.getType())) return;
	//Shield should not get Exp when not successfully blocking when getting attacked
	if(!isBlocking && player.equals(event.getEntity()) && ToolType.SHIELD.contains(tool.getType())) return;
	FileConfiguration config = MineTinker.getPlugin().getConfig();
	int amount = config.getInt("ExpPerEntityHit");

	if (config.getBoolean("EnableDamageExp")) {
		amount = (int) Math.round(event.getDamage());
	}

	if (config.getBoolean("DisableExpFromFalldamage", false)
			&& event.getCause() == EntityDamageEvent.DamageCause.FALL) {
		return;
	}

	modManager.addExp(player, tool, amount);
}
 
源代码2 项目: CombatLogX   文件: ListenerResurrect.java
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true)
public void beforeResurrect(EntityResurrectEvent e) {
    FileConfiguration config = this.expansion.getConfig("citizens-compatibility.yml");
    if(!config.getBoolean("npc-options.prevent-resurrect", true)) return;
    
    LivingEntity entity = e.getEntity();
    if(!entity.hasMetadata("NPC")) return;

    NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry();
    NPC npc = npcRegistry.getNPC(entity);

    NPCManager npcManager = this.expansion.getNPCManager();
    if(npcManager.isInvalid(npc)) return;
    
    e.setCancelled(true);
}
 
源代码3 项目: Carbon   文件: CommandListener.java
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
  FileConfiguration spigot = YamlConfiguration.loadConfiguration(new File(Bukkit.getServer().getWorldContainer(), "spigot.yml"));
  if (event.getMessage().equalsIgnoreCase("/reload") && event.getPlayer().hasPermission("bukkit.command.reload")) {
    // Restarts server if server is set up for it.
    if (spigot.getBoolean("settings.restart-on-crash")) {
      Bukkit.getLogger().severe("[Carbon] Restarting server due to reload command!");
      Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "restart");
    } else {
      // Call to server shutdown on disable.
      // Won't hurt if server already disables itself, but will prevent plugin unload/reload.
      Bukkit.getLogger().severe("[Carbon] Stopping server due to reload command!");
      Bukkit.shutdown();
    }
  }
  }
 
源代码4 项目: Civs   文件: GovernmentManager.java
private void loadGovType(FileConfiguration config, String name) {
    if (!config.getBoolean("enabled", false)) {
        return;
    }
    String govTypeString = config.getString("inherit", name);
    GovernmentType governmentType = GovernmentType.valueOf(govTypeString.toUpperCase());
    if (governmentType == GovernmentType.CYBERSYNACY) {
        new AIManager();
    }
    CVItem cvItem = CVItem.createCVItemFromString(config.getString("icon", "STONE"));

    ArrayList<GovTransition> transitions = processTransitionList(config.getConfigurationSection("transition"));
    Government government = new Government(name, governmentType,
            getBuffs(config.getConfigurationSection("buffs")), cvItem, transitions);
    governments.put(name.toUpperCase(), government);
}
 
源代码5 项目: Crazy-Crates   文件: CrazyCrates.java
private ItemStack getKey(FileConfiguration file) {
    String name = file.getString("Crate.PhysicalKey.Name");
    List<String> lore = file.getStringList("Crate.PhysicalKey.Lore");
    String id = file.getString("Crate.PhysicalKey.Item");
    boolean glowing = false;
    if (file.contains("Crate.PhysicalKey.Glowing")) {
        glowing = file.getBoolean("Crate.PhysicalKey.Glowing");
    }
    return new ItemBuilder().setMaterial(id).setName(name).setLore(lore).setGlowing(glowing).build();
}
 
源代码6 项目: SkyWarsReloaded   文件: DisableRegenEvent.java
public DisableRegenEvent(GameMap map, boolean b) {
	this.gMap = map;
	this.enabled = b;
	File dataDirectory = SkyWarsReloaded.get().getDataFolder();
       File mapDataDirectory = new File(dataDirectory, "mapsData");

       if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) {
       	return;
       }
       
       File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml");
    if (mapFile.exists()) {
    	eventName = "DisableRegenEvent";
    	slot = 18;
    	material = new ItemStack(Material.GOLDEN_APPLE, 1);
        FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile);
        this.min = fc.getInt("events." + eventName + ".minStart");
        this.max = fc.getInt("events." + eventName + ".maxStart");
        this.length = fc.getInt("events." + eventName + ".length");
        this.chance = fc.getInt("events." + eventName + ".chance");
        this.title = fc.getString("events." + eventName + ".title");
        this.subtitle = fc.getString("events." + eventName + ".subtitle");
        this.startMessage = fc.getString("events." + eventName + ".startMessage");
        this.endMessage = fc.getString("events." + eventName + ".endMessage");
        this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer");
        this.repeatable = fc.getBoolean("events." + eventName + ".repeatable");
    }
}
 
源代码7 项目: SkyWarsReloaded   文件: DeathMatchEvent.java
public DeathMatchEvent(GameMap map, boolean b) {
	this.gMap = map;
	this.enabled = b;
	File dataDirectory = SkyWarsReloaded.get().getDataFolder();
       File mapDataDirectory = new File(dataDirectory, "mapsData");

       if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) {
       	return;
       }
       
       File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml");
    if (mapFile.exists()) {
    	eventName = "DeathMatchEvent";
    	slot = 8;
    	material = new ItemStack(Material.DIAMOND_SWORD, 1);
        FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile);
        this.min = fc.getInt("events." + eventName + ".minStart");
        this.max = fc.getInt("events." + eventName + ".maxStart");
        this.length = fc.getInt("events." + eventName + ".length");
        this.chance = fc.getInt("events." + eventName + ".chance");
        this.title = fc.getString("events." + eventName + ".title");
        this.subtitle = fc.getString("events." + eventName + ".subtitle");
        this.startMessage = fc.getString("events." + eventName + ".startMessage");
        this.endMessage = fc.getString("events." + eventName + ".endMessage");
        this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer");
        this.repeatable = fc.getBoolean("events." + eventName + ".repeatable");
       }
}
 
源代码8 项目: CombatLogX   文件: ListenerBlocks.java
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
public void onBlockPlace(BlockPlaceEvent e) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("blocks.prevent-placing")) return;

    Player player = e.getPlayer();
    ICombatManager combatManager = this.plugin.getCombatManager();
    if(!combatManager.isInCombat(player)) return;

    e.setCancelled(true);
    sendMessageWithCooldown(player, "cheat-prevention.blocks.no-placing");
}
 
源代码9 项目: SkyWarsReloaded   文件: MobSpawnEvent.java
public MobSpawnEvent(GameMap map, boolean b) {
	this.gMap = map;
	this.enabled = b;
	File dataDirectory = SkyWarsReloaded.get().getDataFolder();
       File mapDataDirectory = new File(dataDirectory, "mapsData");

       if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) {
       	return;
       }
       
       File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml");
    if (mapFile.exists()) {
    	eventName = "MobSpawnEvent";
    	slot = 22;
    	material = SkyWarsReloaded.getNMS().getMaterial("MOB_SPAWNER");
        FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile);
        this.min = fc.getInt("events." + eventName + ".minStart");
        this.max = fc.getInt("events." + eventName + ".maxStart");
        this.length = fc.getInt("events." + eventName + ".length");
        this.chance = fc.getInt("events." + eventName + ".chance");
        this.title = fc.getString("events." + eventName + ".title");
        this.subtitle = fc.getString("events." + eventName + ".subtitle");
        this.startMessage = fc.getString("events." + eventName + ".startMessage");
        this.endMessage = fc.getString("events." + eventName + ".endMessage");
        this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer");
        this.repeatable = fc.getBoolean("events." + eventName + ".repeatable");
        this.minMobsPerPlayer = fc.getInt("events." + eventName + ".minMobsPerPlayer");
        this.maxMobsPerPlayer = fc.getInt("events." + eventName + ".maxMobsPerPlayer");
        this.mobs = fc.getStringList("events." + eventName + ".mobs");
    }
}
 
源代码10 项目: MineTinker   文件: Directing.java
@Override
public void reload() {
	FileConfiguration config = getConfig();
	config.options().copyDefaults(true);

	config.addDefault("Allowed", true);
	config.addDefault("MaxLevel", 1);
	config.addDefault("SlotCost", 1);
	config.addDefault("WorksOnXP", true);
	config.addDefault("MinimumLevelToGetXP", 1); //Modifier-Level to give Player XP
	config.addDefault("WorkInPVP", true);
	config.addDefault("Color", "%GRAY%");

	config.addDefault("EnchantCost", 10);
	config.addDefault("Enchantable", false);

	config.addDefault("Recipe.Enabled", true);
	config.addDefault("Recipe.Top", "ECE");
	config.addDefault("Recipe.Middle", "CIC");
	config.addDefault("Recipe.Bottom", "ECE");

	Map<String, String> recipeMaterials = new HashMap<>();
	recipeMaterials.put("C", Material.COMPASS.name());
	recipeMaterials.put("E", Material.ENDER_PEARL.name());
	recipeMaterials.put("I", Material.IRON_BLOCK.name());

	config.addDefault("Recipe.Materials", recipeMaterials);

	ConfigurationManager.saveConfig(config);
	ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName());

	init(Material.COMPASS);

	this.workInPVP = config.getBoolean("WorkInPVP", true);
	this.workOnXP = config.getBoolean("WorksOnXP", true);
	this.minimumLevelForXP = config.getInt("MinimumLevelToGetXP", 1);
}
 
源代码11 项目: SkyWarsReloaded   文件: DoubleDamageEvent.java
public DoubleDamageEvent(GameMap map, boolean b) {
	this.gMap = map;
	this.enabled = b;
	File dataDirectory = SkyWarsReloaded.get().getDataFolder();
       File mapDataDirectory = new File(dataDirectory, "mapsData");

       if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) {
       	return;
       }
       
       File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml");
    if (mapFile.exists()) {
    	eventName = "DoubleDamageEvent";
    	slot = 15;
    	material = new ItemStack(Material.DIAMOND_AXE, 1);
        FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile);
        this.min = fc.getInt("events." + eventName + ".minStart");
        this.max = fc.getInt("events." + eventName + ".maxStart");
        this.length = fc.getInt("events." + eventName + ".length");
        this.chance = fc.getInt("events." + eventName + ".chance");
        this.title = fc.getString("events." + eventName + ".title");
        this.subtitle = fc.getString("events." + eventName + ".subtitle");
        this.startMessage = fc.getString("events." + eventName + ".startMessage");
        this.endMessage = fc.getString("events." + eventName + ".endMessage");
        this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer");
        this.repeatable = fc.getBoolean("events." + eventName + ".repeatable");
    }
}
 
源代码12 项目: Crazy-Crates   文件: CrazyCrates.java
/**
 * Load the crate preview of a crate.
 * @param crate The crate you wish to load the preview of.
 * @return An Inventory object of the preview.
 */
public Inventory loadPreview(Crate crate) {
    FileConfiguration file = crate.getFile();
    int slots = 9;
    for (int size = file.getConfigurationSection("Crate.Prizes").getKeys(false).size(); size > 9 && slots < crate.getMaxSlots(); size -= 9) {
        slots += 9;
    }
    Inventory inv = Bukkit.createInventory(null, slots, Methods.sanitizeColor(file.getString("Crate.Name")));
    for (String reward : file.getConfigurationSection("Crate.Prizes").getKeys(false)) {
        String id = file.getString("Crate.Prizes." + reward + ".DisplayItem", "Stone");
        String name = file.getString("Crate.Prizes." + reward + ".DisplayName", "");
        List<String> lore = file.getStringList("Crate.Prizes." + reward + ".Lore");
        HashMap<Enchantment, Integer> enchantments = new HashMap<>();
        String player = file.getString("Crate.Prizes." + reward + ".Player", "");
        boolean glowing = file.getBoolean("Crate.Prizes." + reward + ".Glowing");
        int amount = file.getInt("Crate.Prizes." + reward + ".DisplayAmount", 1);
        for (String enchantmentName : file.getStringList("Crate.Prizes." + reward + ".DisplayEnchantments")) {
            Enchantment enchantment = Methods.getEnchantment(enchantmentName.split(":")[0]);
            if (enchantment != null) {
                enchantments.put(enchantment, Integer.parseInt(enchantmentName.split(":")[1]));
            }
        }
        try {
            inv.setItem(inv.firstEmpty(), new ItemBuilder().setMaterial(id).setAmount(amount).setName(name).setLore(lore).setEnchantments(enchantments).setGlowing(glowing).setPlayer(player).build());
        } catch (Exception e) {
            inv.addItem(new ItemBuilder().setMaterial("RED_TERRACOTTA", "STAINED_CLAY:14").setName("&c&lERROR").setLore(Arrays.asList("&cThere is an error", "&cFor the reward: &c" + reward)).build());
        }
    }
    return inv;
}
 
源代码13 项目: CombatLogX   文件: ListenerDamage.java
private boolean doesNotTagPlayer(EntityDamageEvent.DamageCause cause) {
    if(cause == null) return true;

    FileConfiguration config = this.expansion.getConfig("damage-tagger.yml");
    boolean allDamage = config.getBoolean("all-damage");
    if(allDamage) return false;

    String causeName = cause.name().toLowerCase().replace("_", "-");
    String configPath = "damage-type." + causeName;
    return !config.getBoolean(configPath, false);
}
 
源代码14 项目: CombatLogX   文件: NPCManager.java
public void loadTagStatus(Player player) {
    if(player == null) return;

    FileConfiguration config = this.expansion.getConfig("citizens-compatibility.yml");
    if(!config.getBoolean("retag-player-on-login", true)) return;

    ICombatLogX plugin = this.expansion.getPlugin();
    ICombatManager combatManager = plugin.getCombatManager();
    combatManager.tag(player, null, TagType.UNKNOWN, TagReason.UNKNOWN);
}
 
源代码15 项目: CombatLogX   文件: ListenerMobCombat.java
private Entity linkPet(Entity original) {
    if(original == null) return null;
    
    FileConfiguration config = this.expansion.getPlugin().getConfig("config.yml");
    if(!config.getBoolean("link-pets")) return original;
    
    if(original instanceof Tameable) {
        Tameable pet = (Tameable) original;
        AnimalTamer owner = pet.getOwner();
        if(owner instanceof Entity) return (Entity) owner;
    }
    
    return original;
}
 
源代码16 项目: BedwarsRel   文件: BedwarsRel.java
public boolean getBooleanConfig(String key, boolean defaultBool) {
  FileConfiguration config = this.getConfig();
  if (config.contains(key) && config.isBoolean(key)) {
    return config.getBoolean(key);
  }
  return defaultBool;
}
 
源代码17 项目: CombatLogX   文件: ListenerBlocks.java
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
public void onInteract(PlayerInteractEvent e) {
    Action action = e.getAction();
    if(action != Action.RIGHT_CLICK_BLOCK) return;

    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("blocks.prevent-interaction")) return;

    Player player = e.getPlayer();
    ICombatManager combatManager = this.plugin.getCombatManager();
    if(!combatManager.isInCombat(player)) return;

    e.setCancelled(true);
    sendMessageWithCooldown(player, "cheat-prevention.blocks.no-interaction");
}
 
源代码18 项目: CombatLogX   文件: ListenerNewItemPickup.java
@EventHandler(priority= EventPriority.HIGH, ignoreCancelled=true)
public void onPickupItem(EntityPickupItemEvent e) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("items.prevent-item-pickup")) return;

    LivingEntity entity = e.getEntity();
    if(!(entity instanceof Player)) return;

    Player player = (Player) entity;
    ICombatManager combatManager = this.plugin.getCombatManager();
    if(!combatManager.isInCombat(player)) return;

    e.setCancelled(true);
    sendMessage(player);
}
 
源代码19 项目: MineTinker   文件: Scotopic.java
@Override
public void reload() {
	FileConfiguration config = getConfig();
	config.options().copyDefaults(true);

	config.addDefault("Allowed", true);
	config.addDefault("Color", "%YELLOW%");
	config.addDefault("MaxLevel", 3);
	config.addDefault("SlotCost", 2);
	config.addDefault("RequiredLightLevel", 6);
	config.addDefault("CooldownInSeconds", 120); //in seconds
	config.addDefault("DurationPerLevel", 100); //in ticks
	config.addDefault("CooldownReductionPerLevel", 0.65);
	config.addDefault("GivesImmunityToBlindness", true);

	config.addDefault("EnchantCost", 10);
	config.addDefault("Enchantable", false);

	config.addDefault("Recipe.Enabled", true);
	config.addDefault("Recipe.Top", "S S");
	config.addDefault("Recipe.Middle", " F ");
	config.addDefault("Recipe.Bottom", "S S");

	Map<String, String> recipeMaterials = new HashMap<>();
	recipeMaterials.put("S", Material.SPIDER_EYE.name());
	recipeMaterials.put("F", Material.FERMENTED_SPIDER_EYE.name());

	config.addDefault("Recipe.Materials", recipeMaterials);

	ConfigurationManager.saveConfig(config);
	ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName());

	init(Material.FERMENTED_SPIDER_EYE);
	this.requiredLightLevel = config.getInt("RequiredLightLevel", 6);
	this.durationPerLevel = config.getInt("DurationPerLevel", 100);
	this.cooldownInSeconds = config.getInt("CooldownInSeconds", 120);
	this.cooldownReductionPerLevel = config.getDouble("CooldownReductionPerLevel", 0.65);
	this.givesImmunity = config.getBoolean("GivesImmunityToEffect", true);

	this.description = this.description
			.replaceAll("%amount", String.valueOf(this.durationPerLevel / 20.0))
			.replaceAll("%light", String.valueOf(this.requiredLightLevel))
			.replaceAll("%cmax", String.valueOf(this.cooldownInSeconds))
			.replaceAll("%cmin", String.valueOf(Math.round(this.cooldownInSeconds * Math.pow(1.0 - this.cooldownReductionPerLevel, this.getMaxLvl() - 1))));
}
 
源代码20 项目: SkyWarsReloaded   文件: LevelManager.java
public void loadKillSounds() {
    killSoundList.clear();
    File soundFile = new File(SkyWarsReloaded.get().getDataFolder(), "killsounds.yml");

    if (!soundFile.exists()) {
    	if (SkyWarsReloaded.getNMS().getVersion() < 8) {
            	SkyWarsReloaded.get().saveResource("killsounds18.yml", false);
            	File sf = new File(SkyWarsReloaded.get().getDataFolder(), "killsounds18.yml");
            	if (sf.exists()) {
            		sf.renameTo(new File(SkyWarsReloaded.get().getDataFolder(), "killsounds.yml"));
            	}
    	} else {
        	SkyWarsReloaded.get().saveResource("killsounds.yml", false);
    	}
    }

    if (soundFile.exists()) {
        FileConfiguration storage = YamlConfiguration.loadConfiguration(soundFile);

        if (storage.getConfigurationSection("sounds") != null) {
        	for (String key: storage.getConfigurationSection("sounds").getKeys(false)) {
        		String sound = storage.getString("sounds." + key + ".sound");
            	String name = storage.getString("sounds." + key + ".displayName");
            	int volume = storage.getInt("sounds." + key + ".volume");
            	int pitch = storage.getInt("sounds." + key + ".pitch");
            	String material = storage.getString("sounds." + key + ".icon");
            	int level = storage.getInt("sounds." + key + ".level");
            	int cost = storage.getInt("sounds." + key + ".cost");
            	boolean isCustom = storage.getBoolean("sounds." + key + ".isCustomSound");
            	
            	Material mat = Material.matchMaterial(material);
            	if (mat != null) {
            		if (!isCustom) {
            			try {
            				Sound s = Sound.valueOf(sound);
            				if (s != null) {
            					killSoundList.add(new SoundItem(key, sound, name, level, cost, volume, pitch, mat, isCustom));
            				}
            			} catch (IllegalArgumentException e) {
            				SkyWarsReloaded.get().getServer().getLogger().info(sound + " is not a valid sound in killsounds.yml");
            			}
            		} else {
            			killSoundList.add(new SoundItem(key, sound, name, level, cost, volume, pitch, mat, isCustom));
            		}
            			
                } else {
                	SkyWarsReloaded.get().getServer().getLogger().info(mat + " is not a valid Material in killsounds.yml");
                }
        	}
        }
    }
    
    Collections.<SoundItem>sort(killSoundList);
}