/**
* Give all the players an item
*
* @param itemstack An {@link ItemStack} to give to each player
* @param slot The slot number to put the item in
* @param backup An instance of {@link PlayerConsumer} that says what to do
* in case the player can't receive the item (null to just
* ignore)
*/
public void giveAll(final ItemStack itemstack, final int slot, final PlayerConsumer backup) {
applyAll(new PlayerConsumer() {
@Override
public void apply(Player player) {
PlayerInventory inv = player.getInventory();
if (slot == -1) {
HashMap<Integer, ItemStack> error = inv.addItem(itemstack);
if (error != null && !error.isEmpty())
backup.apply(player);
} else {
ItemStack i = inv.getItem(slot);
if (i == null)
inv.setItem(slot, itemstack);
else
backup.apply(player);
}
}
});
}
Minigame.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:MinigameManager
作者:
评论列表
文章目录