仅检测配置

时间:2018-04-20 16:17:24

标签: java bukkit

我有一个代码,用于检查配置中给定对象的制作项目数。只是它只检测对象1进行检查,然后没有检测到,就好像没有配方一样。

我将补充一点,当我评论这个功能时,工艺制作通常会逐一进行。那么问题是什么呢?

@Deprecated
@EventHandler
public void prepare(PrepareItemCraftEvent e) {
    for(String crafter : cfg.getConfig().getConfigurationSection("craftings").getKeys(false)) {
        ConfigurationSection s = cfg.getConfig().getConfigurationSection("craftings." + crafter);
        ItemStack its = new ItemStack(Material.getMaterial(s.getInt("item")), 1, (byte) s.getInt("data"));
        if(e.getInventory().getResult() !=null) {
            if(e.getInventory().getResult().getType().equals(its.getType())) {
                if(e.getInventory().getItem(1) != null) {
                    if(e.getInventory().getItem(1).getAmount() == s.getInt(".items.iloscA")
                            && e.getInventory().getItem(2).getAmount() == s.getInt("items.iloscB")
                            && e.getInventory().getItem(3).getAmount() == s.getInt("items.iloscC")
                            && e.getInventory().getItem(4).getAmount() == s.getInt("items.iloscD")
                            && e.getInventory().getItem(5).getAmount() == s.getInt("items.iloscE")
                            && e.getInventory().getItem(6).getAmount() == s.getInt("items.iloscF")
                            && e.getInventory().getItem(7).getAmount() == s.getInt("items.iloscG")
                            && e.getInventory().getItem(8).getAmount() == s.getInt("items.iloscH")
                            && e.getInventory().getItem(9).getAmount() == s.getInt("items.iloscI")) {
                        return;
                    }
                    else {
                        e.getInventory().setResult(new ItemStack(Material.AIR, 1));
                    }
                }
            }
        }
    }
}

config.yml

craftings: creeper: item: 383 data: 50 items: A: 289 dataA: 0 iloscA: 64 B: 19 dataB: 0 iloscB: 32 C: 289 dataC: 0 iloscC: 64 D: 12 dataD: 0 iloscD: 64 E: 344 dataE: 0 iloscE: 1 F: 12 dataF: 0 iloscF: 64 G: 289 dataG: 0 iloscG: 64 H: 19 dataH: 0 iloscH: 32 I: 289 dataI: 0 iloscI: 64 slime: item: 383 data: 55 items: A: 165 dataA: 0 iloscA: 4 B: 19 dataB: 0 iloscB: 32 C: 165 dataC: 0 iloscC: 4 D: 19 dataD: 0 iloscD: 32 E: 344 dataE: 0 iloscE: 1 F: 19 dataF: 0 iloscF: 32 G: 165 dataG: 0 iloscG: 4 H: 19 dataH: 0 iloscH: 32 I: 165 dataI: 0 iloscI: 4

0 个答案:

没有答案