當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。