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


Java PlayerInventory.getArmorContents方法代码示例

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


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

示例1: onCommand

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
	Player player = (Player) sender;
	PlayerInventory inv = player.getInventory();
	ItemStack[][] contents = { inv.getContents(), inv.getArmorContents() };
	String world = player.getWorld().getName().split("_")[0];
	try {
		if(KitManager.getKit(world,args[0]) == null){
			KitManager.createKit(world,args[0], "temp", "temp", 1, (short) 0, contents);
			player.sendMessage(Util.parseColors("&7Kit &a" + args[0] + " &7created!"));
		} else {
			KitManager.setKit(world,args[0], contents);
			player.sendMessage(Util.parseColors("&7Kit &a" + args[0] + " &7modified!"));
		}
	} catch (Exception e) {
		player.sendMessage(ChatColor.RED + "Invalid arguments");
		player.sendMessage("/setkit <name>");
	}
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:20,代码来源:SetKit.java

示例2: InventoryToString

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static String InventoryToString (Inventory invInventory)
{
    String serialization = invInventory.getSize() + ";";
    for (int i = 0; i < invInventory.getSize(); i++)
    {
        ItemStack is = invInventory.getItem(i);
        if (is != null)
        {
        	String serializedItemStack = getSerializedItemStack(is);
            serialization += i + "#" + serializedItemStack + ";";
        }
    }
    
    if (invInventory instanceof PlayerInventory) {
    	serialization += "&[email protected]";
    	PlayerInventory pInv = (PlayerInventory)invInventory;
    	
    	for (ItemStack stack : pInv.getArmorContents()) {
    		if (stack != null) {
    			serialization += getSerializedItemStack(stack) + ";";
    		}
    	}
    }
    
    return serialization;
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:27,代码来源:InventorySerializer.java

示例3: playerInventoryToString

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static String playerInventoryToString(PlayerInventory inv) {
    StringBuilder builder = new StringBuilder();
    ItemStack[] armor = inv.getArmorContents();

    for (int i = 0; i < armor.length; i++) {
        if (i == 3) {
            if (armor[i] == null) {
                builder.append(itemStackToString(new ItemStack(Material.AIR)));
            } else {
                builder.append(itemStackToString(armor[3]));
            }
        } else {
            if (armor[i] == null) {
                builder.append(itemStackToString(new ItemStack(Material.AIR))).append(";");
            } else {
                builder.append(itemStackToString(armor[i])).append(";");
            }
        }
    }

    builder.append("|");

    for (int i = 0; i < inv.getContents().length; ++i) {
        builder.append(i).append("#").append(itemStackToString(inv.getContents()[i]))
                .append((i == inv.getContents().length - 1) ? "" : ";");
    }

    return builder.toString();
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:30,代码来源:InventoryUtils.java

示例4: isIventoryEmpty

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static boolean isIventoryEmpty(PlayerInventory playerInventory) {
    if (isIventoryEmpty((Inventory) playerInventory)) {
        for (ItemStack item : playerInventory.getArmorContents()) {
            if (item != null && item.getType() != Material.AIR) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:games647,项目名称:Java-Snippets,代码行数:12,代码来源:EmptyInventoryCheck.java

示例5: onPlayerShoot

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerShoot(EntityDamageByEntityEvent evt) {
	Player damager = null;
	
	if (evt.getDamager() instanceof Arrow) {
		Arrow arrow = (Arrow)evt.getDamager();
		if (arrow.getShooter() instanceof Player) {
			damager = (Player)arrow.getShooter();
		}
	}
	
	if (damager != null) {// && perkService.playerHasPerk((Player)damager, ArcherTree.LeatherExpertId)) {
		PlayerInventory inventory = damager.getInventory();
		ItemStack[] armorContents = inventory.getArmorContents();
		
		double damageBoost = 1;
		
		for(ItemStack armor : armorContents) {
			if (armor.getType().equals(Material.LEATHER_BOOTS)) {
				damageBoost += 0.10;
			} else if (armor.getType().equals(Material.LEATHER_CHESTPLATE)) {
				damageBoost += 0.10;
			} else if (armor.getType().equals(Material.LEATHER_HELMET)) {
				damageBoost += 0.10;
			} else if (armor.getType().equals(Material.LEATHER_LEGGINGS)) {
				damageBoost += 0.10;
			}
		}
		
		if (damageBoost == 0.4) {
			damageBoost = 0.5;
		}
		
		int baseDamage = evt.getDamage();
		int finalDamage = (int) (baseDamage * damageBoost); 
		evt.setDamage(finalDamage);
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:39,代码来源:LeatherExpertPerk.java

示例6: getRegenerationInterval

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private long getRegenerationInterval(Player p)
{
	long regenerationInterval = 12000; // Base is 10 seconds
	PlayerInventory inventory = p.getInventory();
	ItemStack[] armorContents = inventory.getArmorContents();

	for(ItemStack armor : armorContents) 
	{
		if (armor.getType().equals(Material.GOLD_BOOTS)) 
		{
			regenerationInterval -= 2000;
		} 
		else if (armor.getType().equals(Material.GOLD_CHESTPLATE)) 
		{
			regenerationInterval -= 2000;
		} 
		else if (armor.getType().equals(Material.GOLD_HELMET)) 
		{
			regenerationInterval -= 2000;
		}
		else if (armor.getType().equals(Material.GOLD_LEGGINGS)) 
		{
			regenerationInterval -= 2000;
		}
	}
	
	// Should be 4 seconds if all 4 gold pieces
	return regenerationInterval;
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:30,代码来源:FoodLevelRegenerationObserver.java

示例7: colorChestplate

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void colorChestplate()
{
	Color color;
	
	if(team == Team.RED)
		color = Color.RED;
	else if(team == Team.BLUE)
		color = Color.BLUE;
	else
		return;
	
	BPPlayer bpPlayer = getPlayer();
	Player player = bpPlayer.getPlayer();
	PlayerInventory inv = player.getInventory();
	ItemStack[] contents = inv.getArmorContents();
	ItemStack chestplate = contents[2];
	ItemMeta im = chestplate.getItemMeta();
	
	if(!(im instanceof LeatherArmorMeta))
		return;
	
	LeatherArmorMeta lam = (LeatherArmorMeta) im;
	
	lam.setColor(color);
	chestplate.setItemMeta(lam);
	inv.setArmorContents(contents);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:28,代码来源:CTFProperties.java

示例8: colorArmorByFlag

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void colorArmorByFlag(Player player, Team flagTeam)
{
	PlayerInventory inv = player.getInventory();
	ItemStack[] armor = inv.getArmorContents();
	for (ItemStack piece : armor)
	{
		Material mat = piece.getType();
		if (piece != null && BPArmor.getTypeId(mat) >= 0)
		{
			Color color = flagTeam.getColor();
			BPArmor.colorArmor(piece, color);
		}
	}
	inv.setArmorContents(armor);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:16,代码来源:FlagManager.java

示例9: enchantArmor

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static PlayerInventory enchantArmor(PlayerInventory inv, Object[]... enchObjs)
{
	ItemStack[] armor = inv.getArmorContents();
	for (int i = 0; i < 4; i++)
		enchantItem(armor[i], enchObjs);
	return inv;
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:8,代码来源:PlayerManager.java

示例10: colorArmor

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void colorArmor()
{
	Player player = getPlayer();
	PlayerInventory inv = player.getInventory();
	ItemStack[] armor = inv.getArmorContents();
	BPEquipment[] contents = getLobbyInventory().getContents();
	for (int i = 0; i < 4; i++)
	{
		if (!(contents[i] instanceof BPArmor) || armor[i] == null)
			continue;
		BPArmor bpArmor = ((BPArmor) contents[i]).clone();
		bpArmor.colorArmor(armor[i]);
	}
	inv.setArmorContents(armor);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:16,代码来源:BPPlayer.java

示例11: checkPvpProtectionNeeded

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void checkPvpProtectionNeeded(Player player)
{
    //if anti spawn camping feature is not enabled, do nothing
       if(!this.config_pvp_protectFreshSpawns) return;
       
    //if pvp is disabled, do nothing
	if(!this.config_pvp_enabledWorlds.contains(player.getWorld())) return;
	
	//if player is in creative mode, do nothing
	if(player.getGameMode() == GameMode.CREATIVE) return;
	
	//if the player has the damage any player permission enabled, do nothing
	if(player.hasPermission("griefprevention.nopvpimmunity")) return;
	
	//check inventory for well, anything
	PlayerInventory inventory = player.getInventory();
	ItemStack [] armorStacks = inventory.getArmorContents();
	
	//check armor slots, stop if any items are found
	for(int i = 0; i < armorStacks.length; i++)
	{
		if(!(armorStacks[i] == null || armorStacks[i].getType() == Material.AIR)) return;
	}
	
	//check other slots, stop if any items are found
	ItemStack [] generalStacks = inventory.getContents();
	for(int i = 0; i < generalStacks.length; i++)
	{
		if(!(generalStacks[i] == null || generalStacks[i].getType() == Material.AIR)) return;
	}
		
	//otherwise, apply immunity
	PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
	playerData.pvpImmune = true;
	
	//inform the player
	GriefPrevention.sendMessage(player, TextMode.Success, Messages.PvPImmunityStart);
}
 
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:39,代码来源:GriefPrevention.java

示例12: repairAll

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Repair all repairable items in an inventory. If the inventory
 * is a {@link org.bukkit.inventory.PlayerInventory}, the armor contents are also
 * repaired.
 *
 * @param inventory  The inventory with items to repair.
 */
public static void repairAll(Inventory inventory) {
    PreCon.notNull(inventory);

    ItemStack[] contents = inventory.getContents();
    repairAll(contents);

    if (inventory instanceof PlayerInventory) {
        PlayerInventory playerInventory = (PlayerInventory)inventory;

        ItemStack[] armor = playerInventory.getArmorContents();
        repairAll(armor);
    }
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:21,代码来源:InventoryUtils.java

示例13: PlayerBackup

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public PlayerBackup(PlayerInventory inv, float exp, int level) {
    this.items = inv.getContents();
    this.armorItems = inv.getArmorContents();
    this.exp = exp;
    this.level = level;
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:7,代码来源:PlayerBackup.java

示例14: fromPlayerInventory

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static PlayerInv fromPlayerInventory(PlayerInventory inv) {
    return new PlayerInv(inv.getContents(), inv.getArmorContents());
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:4,代码来源:PlayerInv.java


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