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


Java PlayerInventory.contains方法代码示例

本文整理汇总了Java中org.bukkit.inventory.PlayerInventory.contains方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory.contains方法的具体用法?Java PlayerInventory.contains怎么用?Java PlayerInventory.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.PlayerInventory的用法示例。


在下文中一共展示了PlayerInventory.contains方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasEnoughRessource

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private boolean hasEnoughRessource(Player player, VillagerTrade trade) {
	if (trade instanceof XPVillagerTrade) {
		return XPManager.hasEnoughXP(bedwars.getName(), player,
				((XPVillagerTrade) trade).getXP());
	} else {
		ItemStack item1 = trade.getItem1();
		ItemStack item2 = trade.getItem2();
		PlayerInventory inventory = player.getInventory();

		if (item2 != null) {
			if ((!inventory.contains(item1.getType(), item1.getAmount()))
					|| (!inventory.contains(item2.getType(),
							item2.getAmount()))) {
				return false;
			}
		} else if (!inventory.contains(item1.getType(), item1.getAmount())) {
			return false;
		}

		return true;
	}
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:23,代码来源:XPItemShop.java

示例2: hasEnoughRessource

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private boolean hasEnoughRessource(Player player, VillagerTrade trade) {
  ItemStack item1 = trade.getItem1();
  ItemStack item2 = trade.getItem2();
  PlayerInventory inventory = player.getInventory();

  if (item2 != null) {
    if (!inventory.contains(item1.getType(), item1.getAmount())
        || !inventory.contains(item2.getType(), item2.getAmount())) {
      return false;
    }
  } else {
    if (!inventory.contains(item1.getType(), item1.getAmount())) {
      return false;
    }
  }

  return true;
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:19,代码来源:NewItemShop.java

示例3: processShroomThumb

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Process the Shroom Thumb ability.
 *
 * @param blockState The {@link BlockState} to check ability activation for
 * @return true if the ability was successful, false otherwise
 */
public boolean processShroomThumb(BlockState blockState) {
    Player player = getPlayer();
    PlayerInventory playerInventory = player.getInventory();

    if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
        player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
        return false;
    }

    if (!playerInventory.contains(Material.RED_MUSHROOM)) {
        player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
        return false;
    }

    playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
    playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
    player.updateInventory();

    if (!SkillUtils.activationSuccessful(SecondaryAbility.SHROOM_THUMB, getPlayer(), getSkillLevel(), activationChance)) {
        player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
        return false;
    }

    return Herbalism.convertShroomThumb(blockState);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:32,代码来源:HerbalismManager.java

示例4: execute

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void execute() throws KingdomFactionsException {

	PlayerInventory i = getPlayer().getInventory();
	
	if(i.contains(WreckingBallModule.getInstance().getWreckingBall())) {
		getPlayer().sendMessage(Messages.getInstance().getPrefix() + ChatColor.RED + "Je hebt al een WreckingBall!");
		return;
	}
	getPlayer().addItem(WreckingBallModule.getInstance().getWreckingBall());
	getPlayer().sendMessage(Messages.getInstance().getPrefix() + "Je hebt een WreckingBall gekregen! Dit item is alleen voor Staffleden, het is niet toegestaan om dit item te delen met spelers.");
	return;
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:14,代码来源:WreckingBallCommand.java

示例5: onCommand

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
        return true;
    }

    PlayerInventory inventory = ((Player) sender).getInventory();

    if (inventory.contains(ClaimHandler.SUBCLAIM_WAND)) {
        sender.sendMessage(ChatColor.RED + "You already have a subclaim wand in your inventory.");
        return true;
    }

    if (inventory.contains(ClaimHandler.CLAIM_WAND)) {
        sender.sendMessage(ChatColor.RED + "You cannot have a subclaim wand whilst you have a claiming wand in your inventory.");
        return true;
    }

    if (!inventory.addItem(ClaimHandler.SUBCLAIM_WAND).isEmpty()) {
        sender.sendMessage(ChatColor.RED + "Your inventory is full.");
        return true;
    }

    sender.sendMessage(ChatColor.YELLOW + "Subclaim wand added to inventory. Read the item to understand how to create a subclaim.");
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:FactionSubclaimStartArgument.java

示例6: setSoftFor

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Set items to this player if his inv doesnt contains the items
 *
 * @param player The player
 */
public void setSoftFor(Player player){
    PlayerInventory inv = player.getInventory();

    for(ItemStack item : getContents(content)){
        if(item == null || item.getType() == Material.AIR){
            continue;
        }

        if(!inv.contains(item.getType()))
            inv.addItem(item);
    }

    this.setArmor(player);
}
 
开发者ID:Superioz,项目名称:CastleRush,代码行数:20,代码来源:ItemKit.java

示例7: setArmor

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Set the kit armor for given player
 *
 * @param player The player
 */
public void setArmor(Player player){
    PlayerInventory inv = player.getInventory();
    ItemStack[] armor = getContents(this.armor);

    if(!inv.contains(armor[3]))
        inv.setHelmet(armor[3]);
    if(!inv.contains(armor[2]))
        inv.setChestplate(armor[2]);
    if(!inv.contains(armor[1]))
        inv.setLeggings(armor[1]);
    if(!inv.contains(armor[0]))
        inv.setBoots(armor[0]);
}
 
开发者ID:Superioz,项目名称:CastleRush,代码行数:19,代码来源:ItemKit.java

示例8: 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

示例9: onCommand

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String label,  String[] args){
	
	Player player = null;
	if (!(sender instanceof Player))
		Resources.privateMsg(sender, "Only a player can execute this command");
	else{
		//Permissions
		if (!sender.hasPermission("LetItRain.zeus"))
			return true;
		
		
		player = (Player)sender;
		PlayerInventory inv = player.getInventory();
		Material mat = Material.getMaterial(LetItRain.itemZeus);
		ItemStack item = new ItemStack(mat);
		if (!inv.contains(mat) && inv.firstEmpty() != -1){                	
			inv.addItem(item);
			String outputMsg = LetItRain.dZeusMsg;
			outputMsg = outputMsg.replaceAll(Pattern.quote("[player]"), player.getName());
			if(!outputMsg.isEmpty()){
				Resources.broadcast(outputMsg);
			}
		}
	}
	return true;
}
 
开发者ID:Bathlamos,项目名称:Let-It-Rain,代码行数:28,代码来源:Zeus.java

示例10: save

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Save Emeralds in the team treasure.
 * @param amount
 * @return
 */
public boolean save(int amount) {
    Player player = toOnlinePlayer();
    if (amount < 0) {
        Messages.sendMessage(Messages.color(amount) + " is not a valid amount of emeralds to store in the team treasure.", Messages.messageType.INGAME, player);
        return false;
    } else {
        int amountToSave = amount;
        PlayerInventory playerInventory = player.getInventory();
        if (playerInventory.contains(Material.EMERALD, amount)) {
            do {
                int index = playerInventory.first(Material.EMERALD);
                ItemStack itemStack = playerInventory.getItem(index);
                if (itemStack.getAmount() > amount) {
                    itemStack.setAmount(itemStack.getAmount() - amount);
                    playerInventory.setItem(index, itemStack);
                    amount = 0;
                } else {
                    amount -= itemStack.getAmount();
                    itemStack.setAmount(0);
                    playerInventory.setItem(index, itemStack);
                }
            } while (amount != 0);
            _team.earnMoney(amountToSave);
            player.updateInventory();
        } else {
            Messages.sendMessage("Sorry, you do not have " + Messages.color(amount) + " emerald(s) in your inventory !", Messages.messageType.INGAME, player);
            return false;
        }
    }
    _team.sendMessage(Messages.color(_name) + " saved " + Messages.color(amount) + " emerald(s) in the team treasure !");
    Messages.sendMessage("The treasure value is now " + Messages.color(_team.get_money()) + ".", Messages.messageType.INGAME, player);
    return true;
}
 
开发者ID:lolopasdugato,项目名称:MCWarClan,代码行数:39,代码来源:MCWarClanPlayer.java

示例11: onCommand

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
        return true;
    }

    Player player = (Player) sender;
    UUID uuid = player.getUniqueId();

    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(uuid);

    if (playerFaction == null) {
        sender.sendMessage(ChatColor.RED + "You are not in a faction.");
        return true;
    }

    if (playerFaction.isRaidable()) {
        sender.sendMessage(ChatColor.RED + "You cannot claim land for your faction while raidable.");
        return true;
    }

    PlayerInventory inventory = player.getInventory();

    if (inventory.contains(ClaimHandler.CLAIM_WAND)) {
        sender.sendMessage(ChatColor.RED + "You already have a claiming wand in your inventory.");
        return true;
    }

    if (inventory.contains(ClaimHandler.SUBCLAIM_WAND)) {
        sender.sendMessage(ChatColor.RED + "You cannot have a claiming wand whilst you have a subclaim wand in your inventory.");
        return true;
    }

    if (!inventory.addItem(ClaimHandler.CLAIM_WAND).isEmpty()) {
        sender.sendMessage(ChatColor.RED + "Your inventory is full.");
        return true;
    }

    sender.sendMessage(ChatColor.YELLOW + "Claiming wand added to inventory, read the item to understand how to claim. You can also" + 
    ChatColor.YELLOW + " use " + ChatColor.AQUA + '/' + label + " claimchunk" + ChatColor.YELLOW + '.');

    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:45,代码来源:FactionClaimArgument.java


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