BrewListener.java 文件源码

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

项目:NoStrengthII 作者:
/**
* Check if the given inventory contains the ingrediens for strength 2.
* 
* @param inv The inventory checking.
* @return True if it does, false otherwise.
*/
  public boolean containsStrengthOrGlowstone(BrewerInventory inv) {
    boolean glowstone = false;
    boolean potion = false;

    // loop thru all items in the inventory.
    for (ItemStack item : inv.getContents()) {
        // if the item is null, hop over it.
        if (item == null) {
            continue;
        }

        // the item is a glowstone, set that to true.
        if (item.getType() == Material.GLOWSTONE_DUST) {
            glowstone = true;
        }

        // from now we don't want to care if its not a potion.
        if (item.getType() != Material.POTION) {
            continue;
        }

        // if the potion has the durability of a strength potion, set potion to true.
    if (item.getDurability() == 8265 || item.getDurability() == 8201) {
        potion = true;
    }
    }

    // return true if it had glowstone AND a strenght potion
    return glowstone && potion;
  }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号