org.bukkit.inventory.Inventory.removeItem()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中org.bukkit.inventory.Inventory.removeItem()方法的一些代码示例,展示了Inventory.removeItem()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory.removeItem()方法的具体详情如下:
包路径:org.bukkit.inventory.Inventory
类名称:Inventory
方法名:removeItem

Inventory.removeItem介绍

[英]Removes the given ItemStacks from the inventory.

It will try to remove 'as much as possible' from the types and amounts you give as arguments.

The returned HashMap contains what it couldn't remove, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all the given ItemStacks are removed, it will return an empty HashMap.
[中]从库存中删除给定的ItemStack。
它将尝试从作为参数提供的类型和数量中删除“尽可能多”。
返回的HashMap包含它无法删除的内容,其中键是参数的索引,值是varargs参数索引处的ItemStack。如果删除了所有给定的ItemStack,它将返回一个空HashMap。

代码示例

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
  return base.removeItem(items);
}

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
  return base.removeItem(items);
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

/**
 * Removes an item from the inventory
 *
 * @param item      Item to remove
 * @param inventory Inventory
 * @return Number of items that couldn't be removed
 */
public static int remove(ItemStack item, Inventory inventory) {
  Map<Integer, ItemStack> leftovers = inventory.removeItem(item);
  if (!leftovers.isEmpty()) {
    leftovers.values().removeIf(left -> removeManually(left, inventory) == 0);
  }
  return countItems(leftovers);
}

代码示例来源:origin: stackoverflow.com

public class Room {

  private Inventory inventory = new Inventory();

  public void addItem(Item item) {
    inventory.addItem(item);
  }

  public void removeItem(Item item) {
    inventory.removeItem(item);
  }
}

代码示例来源:origin: MinecraftWars/Gringotts

for (ItemStack leftover : inventory.removeItem(stack).values()) {
  returned += leftover.getAmount();

代码示例来源:origin: TheBusyBiscuit/Slimefun4

if (InvUtils.fits(inv, adding)) {
  for (ItemStack removing: inputs.get(i)) {
    if (removing != null) inv.removeItem(removing);

代码示例来源:origin: TheBusyBiscuit/Slimefun4

if (d.getInventory().containsAtLeast(e.getItem(), 2)) d.getInventory().removeItem(new CustomItem(e.getItem(), 1));
  else {
    Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new BukkitRunnable() {
if (d.getInventory().containsAtLeast(e.getItem(), 2)) d.getInventory().removeItem(new CustomItem(e.getItem(), 1));
else {
  Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new BukkitRunnable() {

代码示例来源:origin: TheBusyBiscuit/Slimefun4

inv.removeItem(drink);
Backpacks.saveBackpack(inv, item);
break;

代码示例来源:origin: TheBusyBiscuit/Slimefun4

ItemStack removing = current.clone();
removing.setAmount(1);
inv.removeItem(removing);
inv.addItem(output);
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);

代码示例来源:origin: TheBusyBiscuit/Slimefun4

ItemStack removing = current.clone();
removing.setAmount(convert.getAmount());
inv.removeItem(removing);
inv.addItem(adding);
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1);;

代码示例来源:origin: TheBusyBiscuit/Slimefun4

ItemStack removing = current.clone();
removing.setAmount(1);
inv.removeItem(removing);
inv.addItem(adding);
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
ItemStack removing = current.clone();
removing.setAmount(4);
inv.removeItem(removing);
inv.addItem(adding);
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
ItemStack removing = current.clone();
removing.setAmount(1);
inv.removeItem(removing);
inv.addItem(adding);
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);

代码示例来源:origin: TheBusyBiscuit/Slimefun4

ItemStack removing = current.clone();
removing.setAmount(1);
inv.removeItem(removing);
inv.addItem(adding);
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);

代码示例来源:origin: TheBusyBiscuit/Slimefun4

ItemStack removing = current.clone();
removing.setAmount(convert.getAmount());
inv.removeItem(removing);
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_PISTON_EXTEND, 1, 1);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new BukkitRunnable() {

代码示例来源:origin: TheBusyBiscuit/Slimefun4

if (((Talisman) talisman).isConsumable()) p.getEnderChest().removeItem(((Talisman) talisman).upgrade());
for (PotionEffect effect: ((Talisman) talisman).getEffects()) {
  p.addPotionEffect(effect);

代码示例来源:origin: TheBusyBiscuit/Slimefun4

if (InvUtils.fits(inv, adding)) {
  for (ItemStack removing: inputs.get(i)) {
    if (removing != null) inv.removeItem(removing);

代码示例来源:origin: TheBusyBiscuit/Slimefun4

ItemStack removing = current.clone();
removing.setAmount(convert.getAmount());
inv.removeItem(removing);
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);

相关文章