CraftStorage.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:CaulCrafting 作者:
@SuppressWarnings("unchecked")
public ArrayList<CraftArray> getCrafts(){
    ArrayList<CraftArray> craftlist = new ArrayList<CraftArray>();
    try {
        File craftfile = new File(plugin.getDataFolder(), "crafts.yml");
        craftfile.createNewFile();
        FileConfiguration craftconfig = YamlConfiguration.loadConfiguration(craftfile);
        if(craftconfig.isSet("Crafts")) {
            for(String craftpath : craftconfig.getConfigurationSection("Crafts").getKeys(false)) {
                craftpath = "Crafts." + craftpath;
                ArrayList<ItemStack> config_craft = (ArrayList<ItemStack>) craftconfig.getList(craftpath + ".craft");
                ArrayList<ItemStack> config_resultitems = (ArrayList<ItemStack>) craftconfig.getList(craftpath + ".result.items");
                ArrayList<Integer> config_resultprobs = (ArrayList<Integer>) craftconfig.getIntegerList(craftpath + ".result.probs");
                HashMap<ItemStack,Integer> config_result = new HashMap<ItemStack, Integer>();
                for(ItemStack resultitem : config_resultitems) {
                    config_result.put(resultitem, config_resultprobs.get(config_resultitems.indexOf(resultitem)));
                }
                ArrayList<String> config_cmds = (ArrayList<String>) craftconfig.getStringList(craftpath + ".cmds");
                boolean config_redstonepower = craftconfig.getBoolean(craftpath + ".redstonepower");
                int config_experience = craftconfig.getInt(craftpath + ".experience");
                CraftArray specraft = new CraftArray(config_craft, config_result, config_cmds, config_redstonepower, config_experience);
                craftlist.add(specraft);
            }
            return craftlist;
        } else {
            return craftlist;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return craftlist;
    }
   }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号