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

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

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

Inventory.clear介绍

[英]Clears out the whole Inventory.
[中]清除所有库存。

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Override
public boolean clearContainerBlockContents(BlockVector3 pt) {
  Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
  if (block == null) {
    return false;
  }
  BlockState state = block.getState();
  if (!(state instanceof org.bukkit.inventory.InventoryHolder)) {
    return false;
  }
  org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
  Inventory inven = chest.getInventory();
  if (chest instanceof Chest) {
    inven = getBlockInventory((Chest) chest);
  }
  inven.clear();
  return true;
}

代码示例来源:origin: jiongjionger/NeverLag

public GUIMaker removeItem(int x, int y) {
    int slot = (y - 1) * 9 + x - 1;
    this.inv.clear(slot);
    return this;
  }
}

代码示例来源:origin: EngineHub/CommandHelper

@Override
public void clear() {
  i.clear();
}

代码示例来源:origin: EngineHub/CommandHelper

@Override
public void clear(int index) {
  i.clear(index);
}

代码示例来源:origin: catageek/ByteCart

@Override
public void clear() {
  this.inventory.clear();
}

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

@Override
public void clear(int index) {
  base.clear(index);
}

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

@Override
public void clear() {
  base.clear();
}

代码示例来源:origin: jiongjionger/NeverLag

public GUIMaker clearItem() {
  this.inv.clear();
  return this;
}

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

@Override
public void clear(int index) {
  base.clear(index);
}

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

@Override
public void clear() {
  base.clear();
}

代码示例来源:origin: me.lucko/helper

public void clearItems() {
  this.inventory.clear();
  this.slots.values().forEach(Slot::clearBindings);
}

代码示例来源:origin: lucko/helper

public void clearItems() {
  this.inventory.clear();
  this.slots.values().forEach(Slot::clearBindings);
}

代码示例来源:origin: lucko/helper

/**
 * Clears the item in this slot
 *
 * @return this slot
 */
@Nonnull
@Override
public Slot clearItem() {
  this.gui.getHandle().clear(this.id);
  return this;
}

代码示例来源:origin: me.lucko/helper

/**
 * Clears the item in this slot
 *
 * @return this slot
 */
@Nonnull
@Override
public Slot clearItem() {
  this.gui.getHandle().clear(this.id);
  return this;
}

代码示例来源:origin: garbagemule/MobArena

public RepairableContainer(BlockState state, boolean clear) {
  super(state);
  // Grab the inventory of the block
  Inventory inv = ((InventoryHolder) state).getInventory();
  ItemStack[] stacks = inv.getContents();
  // Manual copy is necessary due to "reduce to 0" bug in Bukkit
  contents = new ItemStack[stacks.length];
  for (int i = 0; i < contents.length; i++) {
    contents[i] = (stacks[i] != null) ? stacks[i].clone() : null;
  }
  
  // Clear the inventory if prompted
  if (clear) inv.clear();
}

代码示例来源:origin: TotalFreedom/TotalFreedomMod

private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
  {
    if (targetBlock.getType() == Material.DISPENSER)
    {
      final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory();
      dispenserInv.clear();
      dispenserInv.addItem(items);
    }
  }
}

代码示例来源:origin: garbagemule/MobArena

private void clearInv(Player p) {
  InventoryView view = p.getOpenInventory();
  if (view != null) {
    view.setCursor(new ItemStack(Material.AIR));
    view.getBottomInventory().clear();
    view.close();
  }
}

代码示例来源:origin: Co0sh/BetonQuest

@Override
public void run(String playerID) throws QuestRuntimeException {
  Block block = loc.getLocation(playerID).getBlock();
  InventoryHolder chest;
  try {
    chest = (InventoryHolder) block.getState();
  } catch (ClassCastException e) {
    throw new QuestRuntimeException("Trying to clears items in a chest, but there's no chest! Location: X"
        + block.getX() + " Y" + block.getY() + " Z" + block.getZ());
  }
  chest.getInventory().clear();
}

代码示例来源:origin: catageek/ByteCart

@Override
  public void destroyWanderer(Inventory inv) {
    int id = ((Vehicle) inv.getHolder()).getEntityId();
    Bukkit.getServer().getPluginManager().callEvent(new UpdaterRemoveEvent(id));
    updaterset.getMap().remove(id);
    inv.clear();
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

@EventHandler(ignoreCancelled = true)
  public void onRecipeClose(InventoryCloseEvent event) {
    Inventory top = event.getView().getTopInventory();
    InventoryType type = top.getType();
    if (type == InventoryType.CHEST) {
      Player p = (Player) event.getPlayer();
      UUID uuid = p.getUniqueId();
      if (plugin.getTrackerKeeper().getRecipeView().contains(uuid)) {
        plugin.getTrackerKeeper().getRecipeView().remove(uuid);
        event.getView().getTopInventory().clear();
        p.updateInventory();
      }
    }
  }
}

相关文章