NMSHandler.java 文件源码

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

项目:Shopkeepers 作者:
@Override
public boolean openTradeWindow(String title, List<ItemStack[]> recipes, Player player) {
    // create empty merchant:
    Merchant merchant = Bukkit.createMerchant(title);

    // create list of merchant recipes:
    List<MerchantRecipe> merchantRecipes = new ArrayList<MerchantRecipe>();
    for (ItemStack[] recipe : recipes) {
        // skip invalid recipes:
        if (recipe == null || recipe.length != 3 || Utils.isEmpty(recipe[0]) || Utils.isEmpty(recipe[2])) {
            continue;
        }

        // create and add merchant recipe:
        merchantRecipes.add(this.createMerchantRecipe(recipe[0], recipe[1], recipe[2]));
    }

    // set merchant's recipes:
    merchant.setRecipes(merchantRecipes);

    // increase 'talked-to-villager' statistic:
    player.incrementStatistic(Statistic.TALKED_TO_VILLAGER);

    // open merchant:
    return player.openMerchant(merchant, true) != null;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号