當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerInventory.getHelmet方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.PlayerInventory.getHelmet方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInventory.getHelmet方法的具體用法?Java PlayerInventory.getHelmet怎麽用?Java PlayerInventory.getHelmet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.PlayerInventory的用法示例。


在下文中一共展示了PlayerInventory.getHelmet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isApplicableFor

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public boolean isApplicableFor(Player player)
{
    PlayerInventory playerInventory = player.getInventory();
    ItemStack helmet = playerInventory.getHelmet();
    if ((helmet == null) || (helmet.getType() != Material.LEATHER_HELMET)) {
        return false;
    }
    ItemStack chestplate = playerInventory.getChestplate();
    if ((chestplate == null) || (chestplate.getType() != Material.LEATHER_CHESTPLATE)) {
        return false;
    }
    ItemStack leggings = playerInventory.getLeggings();
    if ((leggings == null) || (leggings.getType() != Material.LEATHER_LEGGINGS)) {
        return false;
    }
    ItemStack boots = playerInventory.getBoots();
    return (boots != null) && (boots.getType() == Material.LEATHER_BOOTS);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:19,代碼來源:ArcherClass.java

示例2: isApplicableFor

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@Override
public boolean isApplicableFor(Player player) {
    PlayerInventory playerInventory = player.getInventory();

    ItemStack helmet = playerInventory.getHelmet();
    if (helmet == null || helmet.getType() != Material.IRON_HELMET)
        return false;

    ItemStack chestplate = playerInventory.getChestplate();
    if (chestplate == null || chestplate.getType() != Material.IRON_CHESTPLATE)
        return false;

    ItemStack leggings = playerInventory.getLeggings();
    if (leggings == null || leggings.getType() != Material.IRON_LEGGINGS)
        return false;

    ItemStack boots = playerInventory.getBoots();
    return !(boots == null || boots.getType() != Material.IRON_BOOTS);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:20,代碼來源:MinerClass.java

示例3: isApplicableFor

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@Override
public boolean isApplicableFor(Player player) {
    PlayerInventory playerInventory = player.getInventory();

    ItemStack helmet = playerInventory.getHelmet();
    if (helmet == null || helmet.getType() != Material.IRON_HELMET || !helmet.getEnchantments().isEmpty())
        return false;

    ItemStack chestplate = playerInventory.getChestplate();
    if (chestplate == null || chestplate.getType() != Material.IRON_CHESTPLATE || !chestplate.getEnchantments().isEmpty())
        return false;

    ItemStack leggings = playerInventory.getLeggings();
    if (leggings == null || leggings.getType() != Material.IRON_LEGGINGS || !leggings.getEnchantments().isEmpty())
        return false;

    ItemStack boots = playerInventory.getBoots();
    return !(boots == null || boots.getType() != Material.IRON_BOOTS || !boots.getEnchantments().isEmpty());
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:20,代碼來源:AssassinClass.java

示例4: isApplicableFor

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@Override
public boolean isApplicableFor(Player player) {
    PlayerInventory playerInventory = player.getInventory();

    ItemStack helmet = playerInventory.getHelmet();
    if (helmet == null || helmet.getType() != Material.CHAINMAIL_HELMET) {
        return false;
    }

    ItemStack chestplate = playerInventory.getChestplate();
    if (chestplate == null || chestplate.getType() != Material.CHAINMAIL_CHESTPLATE) {
        return false;
    }

    ItemStack leggings = playerInventory.getLeggings();
    if (leggings == null || leggings.getType() != Material.CHAINMAIL_LEGGINGS) {
        return false;
    }

    ItemStack boots = playerInventory.getBoots();
    return !(boots == null || boots.getType() != Material.CHAINMAIL_BOOTS);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:23,代碼來源:RogueClass.java

示例5: onPlayerDeath

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event){
    Player player = event.getEntity();
    PlayerInventory inventory = player.getInventory();
    HashMap<Integer, ItemStack> itemsToKeep = new HashMap<>();
    if (inventory.getHelmet() != null) {
        if (inventory.getHelmet().getType().equals(type) && inventory.getHelmet().getDurability() == damageValue) {
            helmet.put(player, inventory.getHelmet());
        }
    }
    if (inventory.getChestplate() != null) {
        if (inventory.getChestplate().getType().equals(type) && inventory.getChestplate().getDurability() == damageValue) {
            chestplate.put(player, inventory.getChestplate());
        }
    }
    if (inventory.getLeggings() != null) {
        if (inventory.getLeggings().getType().equals(type) && inventory.getLeggings().getDurability() == damageValue) {
            leggings.put(player, inventory.getLeggings());
        }
    }
    if (inventory.getBoots() != null) {
        if (inventory.getBoots().getType().equals(type) && inventory.getBoots().getDurability() == damageValue) {
            boots.put(player, inventory.getBoots());
        }
    }
}
 
開發者ID:dentmaged,項目名稱:Cardinal-Plus,代碼行數:27,代碼來源:ArmorKeep.java

示例6: testInventory

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
/**This method checks the inventory of the player; as to
 * whether it's clear, or is polluted, or has armor pollution
 * @param p the player we're testing
 * @return InventoryResult result of this test
 */
public static IceBall.InventoryResult testInventory(Player p) {
	PlayerInventory pi = p.getInventory();
	if(pi.getHelmet() != null)
		return InventoryResult.ARMOR_POLLUTION;
	if(pi.getChestplate() != null)
		return InventoryResult.ARMOR_POLLUTION;
	if(pi.getLeggings() != null)
		return InventoryResult.ARMOR_POLLUTION;
	if(pi.getBoots() != null)
		return InventoryResult.ARMOR_POLLUTION;
	
	ItemStack is[] = pi.getContents();
	for(int i = 0; i < is.length; i++) {
		if(is[i] != null) {
			if(is[i].getType() != Material.AIR) {
				return InventoryResult.POLLUTED;
			}
		}
	}
	return InventoryResult.CLEAR;
}
 
開發者ID:CrystalCraftMC,項目名稱:IceBall,代碼行數:27,代碼來源:Utility.java

示例7: commandUse

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public boolean commandUse(CommandSender sender, String[] args) {
    Variables var = Necessities.getVar();
    if (sender instanceof Player) {
        Player p = (Player) sender;
        PlayerInventory inv = p.getInventory();
        ItemStack hand = inv.getItemInMainHand();
        ItemStack hat = inv.getHelmet();
        if (hand.getType() != Material.AIR) {
            inv.setHelmet(hand);
            inv.setItemInMainHand(hat);
            p.sendMessage(var.getMessages() + "Hat equipped.");
        } else {
            if (hat != null)
                inv.setItemInMainHand(hat);
            inv.setHelmet(new ItemStack(Material.AIR));
            p.sendMessage(var.getMessages() + "Hat removed.");
        }
    } else
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You do not have armor.");
    return true;
}
 
開發者ID:pupnewfster,項目名稱:Necessities,代碼行數:22,代碼來源:CmdBlockHat.java

示例8: clearEvil

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public void clearEvil() {
		for (Player player : Bukkit.getOnlinePlayers()) {
//			if (peacefulPlayer.contains(player) && player.getWorld().getName().equals("GriefFree")) {
			if (player.getWorld().getName().equals("GriefFree")) {
				PlayerInventory pinv = player.getInventory();
				if (pinv.getHelmet() == null && pinv.getChestplate() == null && pinv.getLeggings() == null && pinv.getBoots() != null && pinv.getBoots().getType() == Material.GOLD_BOOTS) {
					for (Entity e : player.getNearbyEntities(30, 30, 30)) {
						if (e instanceof LivingEntity) {
							if (e instanceof Monster) {
								e.remove();
							}
						}
					}
				}
			}
		}
	}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:18,代碼來源:PeacefulGriefFree.java

示例9: onPlayerRespawnEvent

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@EventHandler
public void onPlayerRespawnEvent(PlayerRespawnEvent event) {
	if (event.getPlayer().getName().equals("Esaych")) {
		PlayerInventory eInv = event.getPlayer().getInventory();
		if (eInv.getHelmet() != null)
			return;
		if (eInv.getChestplate() != null)
			return;
		if (eInv.getLeggings() != null)
			return;
		if (eInv.getBoots() != null)
			return;
		eInv.setHelmet(new ItemStack(Material.LEATHER_HELMET));
		eInv.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
		eInv.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
		eInv.setBoots(new ItemStack(Material.LEATHER_BOOTS));
		PlayerInventory inv = event.getPlayer().getInventory();
		colorize(inv.getHelmet(), 47, 0, 111);
		colorize(inv.getChestplate(), 47, 0, 111);
		colorize(inv.getLeggings(), 47, 0, 111);
		colorize(inv.getBoots(), 47, 0, 111);
	}
}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:24,代碼來源:CustomPlugin.java

示例10: playerInteractEvent

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void playerInteractEvent(PlayerInteractEvent e) {
	if (e.getAction() == Action.PHYSICAL)
		return;
	if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		final Player player = e.getPlayer();

		ArmourType newArmourType = ArmourType.matchType(e.getItem());

		if (newArmourType != null) {
			PlayerInventory inv = player.getInventory();
			if (newArmourType.equals(ArmourType.HELMET) && inv.getHelmet() == null
					|| newArmourType.equals(ArmourType.CHESTPLATE) && inv.getChestplate() == null
					|| newArmourType.equals(ArmourType.LEGGINGS) && inv.getLeggings() == null
					|| newArmourType.equals(ArmourType.BOOTS) && inv.getBoots() == null) {
				ArmourEquipEvent armourEquipEvent = new ArmourEquipEvent(e.getPlayer(), EquipMethod.HOTBAR,
						ArmourType.matchType(e.getItem()), null, e.getItem());
				Bukkit.getServer().getPluginManager().callEvent(armourEquipEvent);
				if (armourEquipEvent.isCancelled()) {
					e.setCancelled(true);
					player.updateInventory();
				}
			}
		}
	}
}
 
開發者ID:gvlfm78,項目名稱:BukkitOldCombatMechanics,代碼行數:28,代碼來源:ArmourListener.java

示例11: Kit

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public Kit(String name, PlayerInventory playerInventory) {
    this.name = name;
    this.displayed = ItemBuilder.builder().type(Material.DIAMOND_SWORD).name("&7&l" + name).lore(Arrays.asList("&aClick to send", "&aa duel request", "&awith this kit!")).build();
    
    Map<Integer, ItemStack> inventory = new HashMap<>();

    for (int i = 0; i < playerInventory.getSize(); i++) {
        ItemStack item = playerInventory.getContents()[i];

        if (item == null) {
            continue;
        }

        inventory.put(i, item.clone());
    }

    Map<Integer, ItemStack> armor = new HashMap<>();

    if (playerInventory.getHelmet() != null) {
        armor.put(1, playerInventory.getHelmet().clone());
    }

    if (playerInventory.getChestplate() != null) {
        armor.put(2, playerInventory.getChestplate().clone());
    }

    if (playerInventory.getLeggings() != null) {
        armor.put(3, playerInventory.getLeggings().clone());
    }

    if (playerInventory.getBoots() != null) {
        armor.put(4, playerInventory.getBoots().clone());
    }

    items.put(KitManager.Type.INVENTORY, inventory);
    items.put(KitManager.Type.ARMOR, armor);
}
 
開發者ID:RealizedMC,項目名稱:Duels,代碼行數:38,代碼來源:Kit.java

示例12: setStratingKit

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public void setStratingKit(PlayerInventory inventory, String arenaName) {
    Arena arena = arenas.get(arenaName);
    arena.startingKitInventory = Bukkit.createInventory(null, InventoryType.PLAYER);
    arena.startingKitInventory.setContents(inventory.getContents());
    arena.kitBoots = inventory.getBoots();
    arena.kitChestplate = inventory.getChestplate();
    arena.kitHelmet = inventory.getHelmet();
    arena.kitLeggings = inventory.getLeggings();
}
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:10,代碼來源:ArenaManager.java

示例13: onPlayerCloseInventoryEvent

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public void onPlayerCloseInventoryEvent(InventoryCloseEvent event) {
	Player player = (Player) event.getPlayer();
	if (player.getWorld().getName().equals("GriefFree")) {
		PlayerInventory pinv = player.getInventory();
		if (pinv.getHelmet() == null && pinv.getChestplate() == null && pinv.getLeggings() == null && pinv.getBoots() != null && pinv.getBoots().getType() == Material.GOLD_BOOTS) {
			for (Entity e : player.getNearbyEntities(30, 30, 30)) {
				if (e instanceof LivingEntity) {
					if (e instanceof Monster) {
						e.remove();
					}
				}
			}
		}
	}
}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:16,代碼來源:PeacefulGriefFree.java

示例14: scanPlayerArmor

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
public void scanPlayerArmor(Player player) {
	PlayerInventory playerInv = player.getInventory();
	ItemStack delete = new ItemStack (Material.AIR);
	ItemStack is = playerInv.getHelmet();
	if (is != null) {
		if (confiscatable(player, is)) {
			playerInv.setHelmet(delete);
			moveToChest(player, is);
			saveChestData();
		}
	}
	is = playerInv.getChestplate();
	if (is != null) {
		if (confiscatable(player, is)) {
			playerInv.setChestplate(delete);
			moveToChest(player, is);
			saveChestData();
		}
	}
	is = playerInv.getLeggings();
	if (is != null) {
		if (confiscatable(player, is)) {
			playerInv.setLeggings(delete);
			moveToChest(player, is);
			saveChestData();
		}
	}
	is = playerInv.getBoots();
	if (is != null) {
		if (confiscatable(player, is)) {
			playerInv.setBoots(delete);
			moveToChest(player, is);
			saveChestData();
		}
	}
}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:37,代碼來源:AutoConfiscate.java

示例15: onPlayerDeath

import org.bukkit.inventory.PlayerInventory; //導入方法依賴的package包/類
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    PlayerInventory inventory = player.getInventory();
    Map<Integer, ItemStack> itemsToKeep = new HashMap<>();
    if (inventory.getHelmet() != null) {
        if (inventory.getHelmet().getType().equals(type) && inventory.getHelmet().getDurability() == damageValue) {
            helmet.put(player, inventory.getHelmet());
            inventory.setHelmet(null);
        }
    }
    if (inventory.getChestplate() != null) {
        if (inventory.getChestplate().getType().equals(type) && inventory.getChestplate().getDurability() == damageValue) {
            chestplate.put(player, inventory.getChestplate());
            inventory.setChestplate(null);
        }
    }
    if (inventory.getLeggings() != null) {
        if (inventory.getLeggings().getType().equals(type) && inventory.getLeggings().getDurability() == damageValue) {
            leggings.put(player, inventory.getLeggings());
            inventory.setLeggings(null);
        }
    }
    if (inventory.getBoots() != null) {
        if (inventory.getBoots().getType().equals(type) && inventory.getBoots().getDurability() == damageValue) {
            boots.put(player, inventory.getBoots());
            inventory.setBoots(null);
        }
    }
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:31,代碼來源:ArmorKeep.java


注:本文中的org.bukkit.inventory.PlayerInventory.getHelmet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。