本文整理汇总了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);
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
}
}
}
}
}
示例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);
}
}
示例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();
}
}
}
}
}
示例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);
}
示例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();
}
示例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();
}
}
}
}
}
}
示例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();
}
}
}
示例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);
}
}
}