本文整理汇总了Java中org.bukkit.inventory.PlayerInventory.remove方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory.remove方法的具体用法?Java PlayerInventory.remove怎么用?Java PlayerInventory.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.PlayerInventory
的用法示例。
在下文中一共展示了PlayerInventory.remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemClick
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void onItemClick(ItemClickEvent event)
{
Player player = event.getPlayer();
PlayerInventory p = player.getInventory();
if(p.containsAtLeast(new ItemStack(Material.GOLD_INGOT), cost))
{
int total = 0;
for(ItemStack s : p.all(Material.GOLD_INGOT).values())
{
total += s.getAmount();
}
p.remove(Material.GOLD_INGOT);
if(total-cost > 0)
p.addItem(new ItemStack(Material.GOLD_INGOT,total-cost));
p.addItem(product);
player.sendMessage(Lang.PURCHASEDITEM.toString());
}
else player.sendMessage(Lang.COULDNOTPURCHASE.toString());
}
示例2: execute
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Remove the cost materials, either items or vault currency, from a player
*/
public boolean execute(Player player) {
if (hasMaterials(player)) {
if (exchangeMode == ExchangeMode.ITEM) {
PlayerInventory inventory = player.getInventory();
for (int i = itemAmount; i != 0; i--) {
if (inventory.getItem(inventory.first(itemMaterial)).getAmount() > 1) {
inventory.getItem(inventory.first(itemMaterial)).setAmount(inventory.getItem(inventory.first(itemMaterial)).getAmount() - 1);
} else {
inventory.remove(inventory.getItem(inventory.first(itemMaterial)));
return true;
}
}
// No return here - if something happens mid-iteration that
// causes the for loop to halt, we want a false return so we
// know something bad happened
} else if (exchangeMode == ExchangeMode.VAULT) {
economy.withdrawPlayer(player, vaultAmount);
return true;
}
}
return false;
}
示例3: removeFlagItems
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void removeFlagItems(GamePlayer player) {
PlayerInventory inventory = player.getBukkit().getInventory();
for (ItemStack item : new ArrayList<>(inventory.contents())) {
if (this.item.isSimilar(item)) {
inventory.remove(item);
}
}
}
示例4: giveItem
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void giveItem(int type, int amt) {
final PlayerInventory inv = player.getInventory();
final ItemStack newItem = new ItemStack(type, amt);
if (type == WorldEdit.getInstance().getConfiguration().wandItem) {
inv.remove(newItem);
}
final ItemStack item = player.getItemInHand();
player.setItemInHand(newItem);
if (item != null) {
inv.addItem(item);
}
player.updateInventory();
}
示例5: removeArmor
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Remove the armor for given player
*
* @param player The player
*/
public void removeArmor(Player player){
PlayerInventory inv = player.getInventory();
ItemStack[] armor = getContents(this.armor);
for(ItemStack item : armor){
if(inv.contains(item))
inv.remove(item);
}
}
示例6: removeAllTools
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private void removeAllTools(Player p) {
PlayerInventory i = p.getInventory();
for(ArmorStandTool t : ArmorStandTool.values()) {
i.remove(t.getItem());
}
}