Java Code Examples for org.bukkit.configuration.file.FileConfiguration#getStringList()

The following examples show how to use org.bukkit.configuration.file.FileConfiguration#getStringList() . 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: HookManager.java    From Survival-Games with GNU General Public License v3.0 6 votes vote down vote up
public void runHook(String hook, String... args){
	//System.out.println("RUNNING HOOK");
	FileConfiguration c = SettingsManager.getInstance().getConfig();
	//System.out.println(c.getStringList("hooks."+hook));

	for(String str: c.getStringList("hooks."+hook)){
		//System.out.println(str);
		String[] split = str.split("!");
		String p = MessageUtil.replaceVars(split[0], args);
		String[] commands = MessageUtil.replaceVars(split[1], args).split(";");
		if(checkConditions(split[2], args)){
			if(p.equalsIgnoreCase("console")||(split.length == 4 && Bukkit.getPlayer(p).hasPermission(split[3])) || (split.length == 3)){
				for(String s1:commands){
					//System.out.println(s1);
					String[] s2 = s1.split("#");
					//System.out.println("Executing "+s2[0]+" "+s2[1]);
					hooks.get(s2[0]).executehook(p, s2);
				}
			}
		}
	}
}
 
Example 2
Source File: Leaderboard.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
public void getSigns(LeaderType type) {
File leaderboardsFile = new File(SkyWarsReloaded.get().getDataFolder(), "leaderboards.yml");

   if (!leaderboardsFile.exists()) {
      SkyWarsReloaded.get().saveResource("leaderboards.yml", false);
   }

   if (leaderboardsFile.exists()) {
     	FileConfiguration storage = YamlConfiguration.loadConfiguration(leaderboardsFile);
     	for (int i = 1; i < 11; i++) {
     		List<String> locations = storage.getStringList(type.toString().toLowerCase() + ".signs." + i);
     		if (locations != null) {
     			ArrayList<Location> locs = new ArrayList<Location>();
     			for (String location: locations) {
     				Location loc = Util.get().stringToLocation(location);
     				locs.add(loc);
     			}
     			signs.get(type).put(i, locs);
     		}
     	}
   }
 	
 }
 
Example 3
Source File: ItemManager.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
public CivItem loadClassType(FileConfiguration config, String name) {
    //TODO load classestype properly
    CVItem icon = CVItem.createCVItemFromString(config.getString("icon", Material.CHEST.name()));
    ClassType civItem = new ClassType(
            config.getStringList("reqs"),
            name,
            icon,
            CVItem.createCVItemFromString(config.getString("shop-icon", config.getString("icon", Material.CHEST.name()))),
            config.getDouble("price", 0),
            config.getString("permission"),
            config.getStringList("children"),
            config.getStringList("groups"),
            config.getInt("mana-per-second", 1),
            config.getInt("max-mana", 100),
            config.getBoolean("is-in-shop", true),
            config.getInt("level", 1));

    itemTypes.put(name, civItem);
    return civItem;
}
 
Example 4
Source File: CrazyCrates.java    From Crazy-Crates with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: GroupManager.java    From PerWorldInventory with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads the groups defined in a 'worlds.yml' file into memory.
 *
 * @param config The contents of the configuration file.
 */
public void loadGroupsToMemory(FileConfiguration config) {
    groups.clear();

    for (String key : config.getConfigurationSection("groups.").getKeys(false)) {
        List<String> worlds;
        if (config.contains("groups." + key + ".worlds")) {
            worlds = config.getStringList("groups." + key + ".worlds");
        } else {
            worlds = config.getStringList("groups." + key);
            config.set("groups." + key, null);
            config.set("groups." + key + ".worlds", worlds);
            if (settings.getProperty(PwiProperties.SEPARATE_GAMEMODE_INVENTORIES)) {
                config.set("groups." + key + ".default-gamemode", "SURVIVAL");
            }
        }

        if (settings.getProperty(PwiProperties.MANAGE_GAMEMODES)) {
            GameMode gameMode = GameMode.SURVIVAL;
            if (config.getString("groups." + key + ".default-gamemode") != null) {
                gameMode = GameMode.valueOf(config.getString("groups." + key + ".default-gamemode").toUpperCase());
            }

            addGroup(key, worlds, gameMode);
        } else {
            addGroup(key, worlds);
        }

        setDefaultsFile(key);
    }
}
 
Example 6
Source File: Kit.java    From Survival-Games with GNU General Public License v3.0 5 votes vote down vote up
public void load(){
	FileConfiguration c = SettingsManager.getInstance().getKits();
	cost = c.getDouble("kits."+name+".cost", 0);
	
	icon = ItemReader.read(c.getString("kits."+name+".icon"));
	SurvivalGames.debug("[Kits] loading: " + icon);
	List<String>cont = c.getStringList("kits."+name+".contents");
	for(String s:cont){
		items.add(ItemReader.read(s));
	}
	
}
 
Example 7
Source File: ListenerPotions.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean isBlocked(PotionEffectType type) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    List<String> blockedPotionList = config.getStringList("blocked-potion-list");

    String typeName = type.getName();
    return blockedPotionList.contains(typeName);
}
 
Example 8
Source File: ItemManager.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public TownType loadTownType(FileConfiguration config, String name) throws NullPointerException {
    CVItem icon = CVItem.createCVItemFromString(config.getString("icon", Material.STONE.name()));
    HashMap<String, String> effects = new HashMap<>();
    List<String> configEffects = config.getStringList("effects");
    for (String effectString : configEffects) {
        if (effectString.contains(":")) {
            String[] effectSplit = effectString.split(":");
            effects.put(effectSplit[0], effectSplit[1]);
        } else {
            effects.put(effectString, null);
        }
    }
    int buildRadius = config.getInt("build-radius", 20);
    TownType townType = new TownType(
            name,
            icon,
            CVItem.createCVItemFromString(config.getString("shop-icon", config.getString("icon", Material.CHEST.name()))),
            config.getStringList("pre-reqs"),
            config.getInt("qty", 0),
            config.getInt("min",0),
            config.getInt("max", -1),
            config.getDouble("price", 0),
            config.getString("permission"),
            convertListToMap(config.getStringList("build-reqs")),
            convertListToMap(config.getStringList("limits")),
            effects,
            buildRadius,
            config.getInt("build-radius-y", buildRadius),
            config.getStringList("critical-build-reqs"),
            config.getInt("power", 200),
            config.getInt("max-power", 1000),
            config.getStringList("groups"),
            config.getString("child"),
            config.getInt("child-population", 0),
            config.getBoolean("is-in-shop", true),
            config.getInt("level", 1));
    townType.setDefaultGovType(config.getString("gov-type", ConfigManager.getInstance().getDefaultGovernmentType()));
    itemTypes.put(Util.getValidFileName(name).toLowerCase(), townType);
    return townType;
}
 
Example 9
Source File: CodeClimateConfigTest.java    From AuthMeReloaded with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void shouldHaveExistingClassesInExclusions() {
    // given / when
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(new File(CONFIG_FILE));
    List<String> excludePaths = configuration.getStringList("exclude_patterns");

    // then
    assertThat(excludePaths, not(empty()));
    removeTestsExclusionOrThrow(excludePaths);
    for (String path : excludePaths) {
        if (!new File(path).exists()) {
            fail("Path '" + path + "' does not exist!");
        }
    }
}
 
Example 10
Source File: Lang.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
private List<String> getStringList(FileConfiguration lang, String path, List<String> def){
	List<String> list = lang.getStringList(path);
	if (list.isEmpty()){
		list = def;
		lang.set(path, def);
	}

	// Translate color codes.
	for (int i = 0; i < list.size(); i++) {
		list.set(i, ChatColor.translateAlternateColorCodes('&', list.get(i)));
	}

	return list;
}
 
Example 11
Source File: ListenerCombatChecks.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean isInDisabledWorld(Player player) {
    if(player == null) return false;

    World world = player.getWorld();
    String worldName = world.getName();

    FileConfiguration config = this.plugin.getConfig("config.yml");
    List<String> disabledWorldList = config.getStringList("disabled-worlds");
    return disabledWorldList.contains(worldName);
}
 
Example 12
Source File: WarehouseEffect.java    From Civs with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onChestPlace(BlockPlaceEvent event) {
    if (event.getBlock().getType() != Material.CHEST) {
        return;
    }

    Location l = Region.idToLocation(Region.blockLocationToString(event.getBlock().getLocation()));
    Region r = RegionManager.getInstance().getRegionAt(l);
    if (r == null) {
        return;
    }

    if (!r.getEffects().containsKey(KEY)) {
        return;
    }


    File dataFolder = new File(Civs.dataLocation, Constants.REGIONS);
    if (!dataFolder.exists()) {
        return;
    }
    File dataFile = new File(dataFolder, r.getId() + ".yml");
    if (!dataFile.exists()) {
        return;
    }
    FileConfiguration config = new YamlConfiguration();
    try {
        config.load(dataFile);
        List<String> locationList = config.getStringList(Constants.CHESTS);
        locationList.add(Region.locationToString(l));
        config.set(Constants.CHESTS, locationList);
        config.save(dataFile);
    } catch (Exception e) {
        Civs.logger.log(Level.WARNING, UNABLE_TO_SAVE_CHEST, r.getId());
        return;
    }

    if (!invs.containsKey(r)) {
        invs.put(r, new ArrayList<>());
    }
    CVInventory cvInventory = UnloadedInventoryHandler.getInstance().getChestInventory(event.getBlockPlaced().getLocation());
    invs.get(r).add(cvInventory);
}
 
Example 13
Source File: ResourceManagerGuildImpl.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<NovaGuild> load() {
	final List<NovaGuild> list = new ArrayList<>();

	for(File guildFile : getFiles()) {
		FileConfiguration configuration = loadConfiguration(guildFile);

		if(configuration != null) {
			NovaGuild.LoadingWrapper<String> loadingWrapper = new NovaGuildImpl.LoadingWrapperImpl<>(new AbstractConverter<String, NovaGuild>() {
				@Override
				public NovaGuild convert(String s) {
					return ((YamlStorageImpl) getStorage()).guildMap.get(s);
				}
			});

			List<String> alliesList = configuration.getStringList("allies");
			List<String> warsList = configuration.getStringList("enemies");

			NovaGuild guild = new NovaGuildImpl(UUID.fromString(configuration.getString("uuid")), loadingWrapper);

			guild.setAdded();
			guild.setName(configuration.getString("name"));
			guild.setTag(configuration.getString("tag"));
			guild.setLeaderName(configuration.getString("owner"));
			guild.setPoints(configuration.getInt("points"));
			guild.setLives(configuration.getInt("lives"));
			guild.setTimeCreated(configuration.getLong("born") / 1000);
			guild.setInactiveTime(NumberUtils.systemSeconds());
			guild.setSlots(Config.GUILD_SLOTS_START.getInt());

			//Loading wrapper
			loadingWrapper.setAllies(alliesList);
			loadingWrapper.setWars(warsList);

			//home
			String[] homeSplit = configuration.getString("home").split(",");
			World homeWorld = plugin.getServer().getWorld(homeSplit[0]);

			if(homeWorld == null) {
				LoggerUtils.error("Found invalid world: " + homeSplit[0] + " (guild: " + guild.getName() + ")");
				guild.unload();
				continue;
			}

			for(String member : configuration.getStringList("members")) {
				((YamlStorageImpl) getStorage()).playerGuildMap.put(member, guild);
			}

			((YamlStorageImpl) getStorage()).guildMap.put(guild.getName(), guild);
			Location homeLocation = new Location(homeWorld, Integer.parseInt(homeSplit[1]), Integer.parseInt(homeSplit[2]), Integer.parseInt(homeSplit[3]));
			guild.setHome(homeLocation);
			guild.setUnchanged();
			list.add(guild);
		}
	}

	return list;
}
 
Example 14
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadGuns(QAMain main, File f) {
		if (f.getName().contains("yml")) {
			FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
			if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
				final String name = f2.getString("name");
				if(QAMain.verboseLoadingLogging)
				main.getLogger().info("-Loading Gun: " + name);

				Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
						: Material.DIAMOND_AXE;
				int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
				final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant);
				WeaponType weatype = f2.contains("guntype") ? WeaponType.valueOf(f2.getString("guntype"))
						: WeaponType.valueOf(f2.getString("weapontype"));
				final ItemStack[] materails = main.convertIngredients(f2.getStringList("craftingRequirements"));

				final String displayname = f2.contains("displayname")
						? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
						: (ChatColor.GOLD + name);
				final List<String> extraLore2 = f2.contains("lore") ? f2.getStringList("lore") : null;
				final List<String> extraLore = new ArrayList<String>();

				try {
					for (String lore : extraLore2) {
						extraLore.add(ChatColor.translateAlternateColorCodes('&', lore));
					}
				} catch (Error | Exception re52) {
				}
				if (weatype.isGun()) {
					Gun g = new Gun(name, ms);
					g.setDisplayname(displayname);
					g.setCustomLore(extraLore);
					g.setIngredients(materails);
					QAMain.gunRegister.put(ms, g);
					loadGunSettings(g, f2);
				}

			}
		}

}
 
Example 15
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadMisc(QAMain main) {
	if (new File(main.getDataFolder(), "misc").exists()) {
		int items = 0;
		for (File f : new File(main.getDataFolder(), "misc").listFiles()) {
			try {
				if (f.getName().contains("yml")) {
					FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
					if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
						final String name = f2.getString("name");
						if (QAMain.verboseLoadingLogging)
							main.getLogger().info("-Loading Misc: " + name);

						Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
								: Material.DIAMOND_AXE;
						int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
						final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant);
						final ItemStack[] materails = main
								.convertIngredients(f2.getStringList("craftingRequirements"));
						final String displayname = f2.contains("displayname")
								? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
								: (ChatColor.WHITE + name);
						final List<String> rawLore = f2.contains("lore") ? f2.getStringList("lore") : null;
						final List<String> lore = new ArrayList<String>();
						try {
							for (String lore2 : rawLore) {
								lore.add(ChatColor.translateAlternateColorCodes('&', lore2));
							}
						} catch (Error | Exception re52) {
						}

						final int price = f2.contains("price") ? f2.getInt("price") : 100;

						int damage = f2.contains("damage") ? f2.getInt("damage") : 1;
						// int durib = f2.contains("durability") ? f2.getInt("durability") : 1000;

						WeaponType wt = WeaponType.getByName(f2.getString("MiscType"));

						double radius = f2.contains("radius") ? f2.getDouble("radius") : 0;
						items++;

						CustomBaseObject base = null;


						String soundEquip =  f2.contains("sound_equip")? f2.getString("sound_equip"):null;
						String soundHit =  f2.contains("sound_meleehit")? f2.getString("sound_meleehit"):null;

						if (wt == WeaponType.MEDKIT)
							QAMain.miscRegister.put(ms, base=new MedKit(ms, name, displayname, materails, price));
						if (wt == WeaponType.MELEE) {
							QAMain.miscRegister.put(ms,
									base = new MeleeItems(ms, name, displayname, materails, price, damage));
							base.setSoundOnEquip(soundEquip);
							base.setSoundOnHit(soundHit);
							base.setCustomLore(lore);
						}
						if (wt == WeaponType.GRENADES)
							QAMain.miscRegister.put(ms,
									base=new Grenade(materails, price, damage, radius, name, displayname, lore, ms));
						if (wt == WeaponType.SMOKE_GRENADES)
							QAMain.miscRegister.put(ms, base=new SmokeGrenades(materails, price, damage, radius, name,
									displayname, lore, ms));
						if (wt == WeaponType.INCENDARY_GRENADES)
							QAMain.miscRegister.put(ms, base=new IncendaryGrenades(materails, price, damage, radius,
									name, displayname, lore, ms));
						if (wt == WeaponType.FLASHBANGS)
							QAMain.miscRegister.put(ms,
									base=new Flashbang(materails, price, damage, radius, name, displayname, lore, ms));

						if(base!=null) {
							base.setCustomLore(lore);
							base.setIngredients(materails);
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if(!QAMain.verboseLoadingLogging)
			main.getLogger().info("-Loaded "+items+" Misc.");
	}
}
 
Example 16
Source File: ListenerUntagger.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
private boolean isKickReasonIgnored(String string) {
    FileConfiguration config = this.plugin.getConfig("config.yml");
    List<String> kickReasonIgnoreList = config.getStringList("punishments.on-kick-ignore-list");
    return kickReasonIgnoreList.stream().anyMatch(string::contains);
}
 
Example 17
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 4 votes vote down vote up
public static void loadAmmo(QAMain main) {

		if (new File(main.getDataFolder(), "ammo").exists()) {
			int items = 0;
			for (File f : new File(main.getDataFolder(), "ammo").listFiles()) {
				try {
					if (f.getName().contains("yml")) {
						FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
						if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) {
							Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material"))
									: Material.DIAMOND_AXE;
							int variant = f2.contains("variant") ? f2.getInt("variant") : 0;
							final String name = f2.getString("name");
							if(QAMain.verboseLoadingLogging)
							main.getLogger().info("-Loading AmmoType: " + name);

							String extraData = null;
							if (f2.contains("skull_owner")) {
								extraData = f2.getString("skull_owner");
							}
							String ed2 = null;
							if (f2.contains("skull_owner_custom_url")
									&& !f2.getString("skull_owner_custom_url").equals(Ammo.NO_SKIN_STRING)) {
								ed2 = f2.getString("skull_owner_custom_url");
							}

							final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant, extraData,
									ed2);
							final ItemStack[] materails = main
									.convertIngredients(f2.getStringList("craftingRequirements"));
							final String displayname = f2.contains("displayname")
									? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname"))
									: (ChatColor.WHITE + name);
							final List<String> extraLore2 = f2.contains("lore") ? f2.getStringList("lore") : null;
							final List<String> extraLore = new ArrayList<String>();
							try {
								for (String lore : extraLore2) {
									extraLore.add(ChatColor.translateAlternateColorCodes('&', lore));
								}
							} catch (Error | Exception re52) {
							}

							final double price = f2.contains("price") ? f2.getDouble("price") : 100;

							int amountA = f2.getInt("maxAmount");

							double piercing = f2.getDouble("piercingSeverity");

							Ammo da = new Ammo(name, displayname, extraLore, ms, amountA, false, 1, price, materails,
									piercing);

							da.setCustomLore(extraLore);

							QAMain.ammoRegister.put(ms, da);
							items++;

							if (extraData != null) {
								da.setSkullOwner(extraData);
							}
							if (ed2 != null) {
								da.setCustomSkin(ed2);
							}
							if (f2.contains("craftingReturnAmount")) {
								da.setCraftingReturn(f2.getInt("craftingReturnAmount"));
							}

						}
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			if(!QAMain.verboseLoadingLogging)
				main.getLogger().info("-Loaded "+items+" Ammo types.");


		}
	}
 
Example 18
Source File: ChestRatioStorageOLD.java    From Survival-Games with GNU General Public License v3.0 4 votes vote down vote up
public void setup(){

		FileConfiguration conf = SettingsManager.getInstance().getChest();

		for(int a = 1; a<5;a++){
			ArrayList<ItemStack> lvl = new ArrayList<ItemStack>();
			List<String>list = conf.getStringList("chest.lvl"+a);

			for(int b = 0; b<list.size();b++){
				ItemStack i = ItemReader.read(list.get(b));
				

				lvl.add(i);

			}

			lvlstore.put(a, lvl);

		}

		ratio = conf.getInt("chest.ratio") + 1;

	}
 
Example 19
Source File: Drilling.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void reload() {
	FileConfiguration config = getConfig();
	config.options().copyDefaults(true);

	config.addDefault("Allowed", true);
	config.addDefault("Color", "%GREEN%");
	config.addDefault("Toggleable", true);
	config.addDefault("MaxLevel", 4);
	config.addDefault("SlotCost", 1);

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

	config.addDefault("Recipe.Enabled", true);
	config.addDefault("Recipe.Top", " D ");
	config.addDefault("Recipe.Middle", "DGD");
	config.addDefault("Recipe.Bottom", "GHG");

	Map<String, String> recipeMaterials = new HashMap<>();
	recipeMaterials.put("D", Material.DIAMOND.name());
	recipeMaterials.put("G", Material.GOLD_BLOCK.name());
	recipeMaterials.put("H", Material.HOPPER.name());

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

	List<String> blacklistTemp = new ArrayList<>();

	blacklistTemp.add(Material.AIR.name());
	blacklistTemp.add(Material.BEDROCK.name());
	blacklistTemp.add(Material.WATER.name());
	blacklistTemp.add(Material.BUBBLE_COLUMN.name());
	blacklistTemp.add(Material.LAVA.name());
	blacklistTemp.add(Material.END_PORTAL.name());
	blacklistTemp.add(Material.END_CRYSTAL.name());
	blacklistTemp.add(Material.END_PORTAL_FRAME.name());
	blacklistTemp.add(Material.NETHER_PORTAL.name());

	config.addDefault("Blacklist", blacklistTemp);
	config.addDefault("TreatAsWhitelist", false);

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

	init(Material.HOPPER);

	this.toggleable = config.getBoolean("Toggleable", true);
	this.treatAsWhitelist = config.getBoolean("TreatAsWhitelist", false);

	blacklist = new ArrayList<>();

	List<String> blacklistConfig = config.getStringList("Blacklist");

	for (String mat : blacklistConfig) {
		try {
			Material material = Material.valueOf(mat);

			if (blacklist == null) {
				continue;
			}

			blacklist.add(material);
		} catch (IllegalArgumentException e) {
			MineTinker.getPlugin().getLogger()
					.warning("Illegal material name found when loading Drilling blacklist: " + mat);
		}
	}
}
 
Example 20
Source File: LevelManager.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
public void loadProjEffects() {
    projEffectList.clear();
    File particleFile = new File(SkyWarsReloaded.get().getDataFolder(), "projectileeffects.yml");

    if (!particleFile.exists()) {
    	SkyWarsReloaded.get().saveResource("projectileeffects.yml", false);
    }

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

        if (storage.getConfigurationSection("effects") != null) {
        	for (String key: storage.getConfigurationSection("effects").getKeys(false)) {
        		String name = storage.getString("effects." + key + ".displayname");
            	String material = storage.getString("effects." + key + ".icon");
            	int level = storage.getInt("effects." + key + ".level");
            	int cost = storage.getInt("effects." + key + ".cost");
            	List<String> particles = storage.getStringList("effects." + key + ".particles");
            	
            	List<ParticleEffect> effects = new ArrayList<ParticleEffect>();
            	if (particles != null) {
            		for (String part: particles) {
                		final String[] parts = part.split(":");
                        if (parts.length == 6 
                        		&& SkyWarsReloaded.getNMS().isValueParticle(parts[0].toUpperCase()) 
                        		&& Util.get().isFloat(parts[1])
                				&& Util.get().isFloat(parts[2])
                				&& Util.get().isFloat(parts[3])
                        		&& Util.get().isInteger(parts[4]) 
                        		&& Util.get().isInteger(parts[5])) {
                        	effects.add(new ParticleEffect(parts[0].toUpperCase(), Float.valueOf(parts[1]), Float.valueOf(parts[2]), Float.valueOf(parts[3]), Integer.valueOf(parts[4]), Integer.valueOf(parts[5])));
                        } else {
                        	SkyWarsReloaded.get().getLogger().info("The particle effect " + key + " has an invalid particle effect");
                        }
                	}
            	}                	
    
            	Material mat = Material.matchMaterial(material);
            	if (mat != null) {
            		projEffectList.add(new ParticleItem(key, effects, name, mat, level, cost));
                }
        	}
        }
    }
    
    Collections.<ParticleItem>sort(projEffectList);
}