当前位置: 首页>>代码示例>>Java>>正文


Java PlayerInventory.remove方法代码示例

本文整理汇总了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());
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:21,代码来源:ShopMenuItem.java

示例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;
}
 
开发者ID:RedPanda4552,项目名称:SimpleEgg,代码行数:29,代码来源:ExpenseHandler.java

示例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);
        }
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:Flag.java

示例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();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:15,代码来源:BukkitPlayer.java

示例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);
    }
}
 
开发者ID:Superioz,项目名称:CastleRush,代码行数:15,代码来源:ItemKit.java

示例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());
    }
}
 
开发者ID:St3venAU,项目名称:ArmorStandTools,代码行数:7,代码来源:Main.java


注:本文中的org.bukkit.inventory.PlayerInventory.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。