CraftUtils.java 文件源码

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

项目:Transport-Pipes 作者:
@EventHandler
public void onPrepareCraft(PrepareItemCraftEvent e) {

    Recipe r = e.getInventory().getRecipe();
    if (r == null || e.getViewers().size() != 1) {
        return;
    }

    Player viewer = (Player) e.getViewers().get(0);

    if (r.getResult() != null) {
        DuctDetails ductDetails = DuctItemUtils.getDuctDetailsOfItem(r.getResult());
        if (ductDetails != null) {
            if (!viewer.hasPermission(ductDetails.getCraftPermission())) {
                e.getInventory().setResult(null);
                return;
            }
        } else if (DuctItemUtils.getWrenchItem().isSimilar(r.getResult())) {
            if (!viewer.hasPermission("transportpipes.craft.wrench")) {
                e.getInventory().setResult(null);
                return;
            }
        }

        if (ductDetails != null && ductDetails.getDuctType() == DuctType.PIPE) {
            boolean prevent = false;
            for (int i = 1; i < 10; i++) {
                ItemStack is = e.getInventory().getItem(i);
                if (is != null && is.getType() == Material.SKULL_ITEM && is.getDurability() == SkullType.PLAYER.ordinal()) {
                    DuctDetails isDuctDetails = DuctItemUtils.getDuctDetailsOfItem(is);
                    prevent |= isDuctDetails == null;
                }
            }
            if (prevent) {
                e.getInventory().setResult(null);
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号