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


Java Player.getInventory方法代码示例

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


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

示例1: isApplicableFor

import org.bukkit.entity.Player; //导入方法依赖的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

示例2: hasEnoughRessource

import org.bukkit.entity.Player; //导入方法依赖的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

示例3: isApplicableFor

import org.bukkit.entity.Player; //导入方法依赖的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

示例4: isApplicableFor

import org.bukkit.entity.Player; //导入方法依赖的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

示例5: isApplicableFor

import org.bukkit.entity.Player; //导入方法依赖的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

示例6: removeItem

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void removeItem(Material material, int amount) throws ShopException {
Player p = this.player;
Inventory inv = p.getInventory();
int j = inv.getSize();
for (int i = 0; i < j; i++) {
	if (inv.getItem(i) != null) {
		if (inv.getItem(i).getType() == material) {
			if (inv.getItem(i).getAmount() == amount) {
				inv.setItem(i, new ItemStack(Material.AIR));
			return;
			} else if (inv.getItem(i).getAmount() >= amount) {
				int newAmount = inv.getItem(i).getAmount() - amount;
				if (newAmount >= 0) {
					p.getInventory().getItem(i).setAmount(newAmount);
		        return;
				}
			}
		}
	} 
	}
throw new ShopException("Player "+p.getName()+" does not have enough items!");
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:23,代码来源:KingdomFactionsPlayer.java

示例7: limitWorkbenches

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void limitWorkbenches(Player player) {
  boolean workbench = false;
  Inventory inventory = player.getInventory();
  for (int slot = 0; slot < inventory.getSize(); ++slot) {
    ItemStack item = inventory.getItem(slot);
    if (item != null && item.getType().equals(Material.WORKBENCH)) {
      if (workbench) {
        inventory.setItem(slot, null);
      } else {
        workbench = true;
        item.setAmount(1);
        //TODO: Ensure that the amount of workbenches in the inventory updates on the client
      }
    }
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:17,代码来源:BenchBlitz.java

示例8: onPlayerInteract2

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract2(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Material material = inventory.getItemInHand().getType();
        if(material == Material.BOW) {
            DynamicAC.getManager().getBackend().logBowWindUp(player, System.currentTimeMillis());
        } else if(Utilities.isFood(material)) {
            DynamicAC.getManager().getBackend().logEatingStart(player);
        }
    }
    Block block = e.getClickedBlock();
    if(block != null) {
        Distance distance = new Distance(player.getLocation(), block.getLocation());
        DynamicAC.getManager().getBackend().checkLongReachBlock(player,distance.getXDifference(),distance
                .getYDifference(),distance.getZDifference());
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:20,代码来源:PlayerListener.java

示例9: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, String label, String[] arguments)
{
    if (!hasPermission(sender, "api.inventory.show"))
        return true;

    if(sender instanceof Player)
    {
        if(arguments.length != 0)
        {
            String playerName = arguments[0];
            Player player = Bukkit.getPlayer(playerName);

            if(player != null)
            {
                Inventory inventory = player.getInventory();
                ((Player) sender).closeInventory();
                ((Player) sender).openInventory(inventory);
            }
            else
            {
                sender.sendMessage(ChatColor.RED + "Le joueur spécifié n'est pas en ligne !");
            }
        }
        else
        {
            return false;
        }
    }

    return true;
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:33,代码来源:CommandInv.java

示例10: countModularized

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private static int countModularized(Player p, Function<ItemStack, Boolean> f) {
    Inventory i = p.getInventory();
    int count = 0;
    for (ItemStack item : i.getContents()) {
        if (f.apply(item))
            count += item.getAmount();
    }
    return count;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:10,代码来源:ShardManager.java

示例11: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run(PlayerInteractEvent evt) {
    Player player = evt.getPlayer();
    if (CooldownTicker.can(this, player) || evt.getItem().getItemMeta().getLore().contains("§6高速射击")) {
        Inventory inv = player.getInventory();
        if (!inv.contains(Material.SULPHUR)) {
            AzureAPI.log(player, "你没有弹药! 需要 " + ChatColor.RED + "火药" + ChatColor.GOLD + " 作为弹药");
            AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK);
            return;
        }
        int slot = inv.first(Material.SULPHUR);
        ItemStack ammo = inv.getItem(slot);
        int amount = ammo.getAmount();
        if (amount > 1) {
            ammo.setAmount(amount - 1);
            inv.setItem(slot, ammo);
        } else {
            inv.setItem(slot, null);
        }
        
        Location eye = player.getEyeLocation();
        Vector direction = eye.getDirection().multiply(2);
        Projectile projectile = player.getWorld().spawn(eye.add(direction), Fireball.class);
        projectile.setShooter(player);
        projectile.setVelocity(direction);
        AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
        
        CooldownTicker.cooldown(this, player, TimeUnit.SECONDS, 3);
    } else {
        AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK);
        AzureAPI.log(player, "冷却时间还没有结束呢!");
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:34,代码来源:ItemRedstoneCannon.java

示例12: addItems

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void addItems(Player p) {
    Inventory inv = p.getInventory();
    inv.addItem(Weapon.getPYTHON().toItemStack());
    inv.addItem(new AllItems().getPotion2());
    inv.addItem(new AllItems().getPotion2());
    inv.addItem(ItemMaker.setAmount(new Gun().toItemStack(), 25));
    inv.addItem(new ItemMaker(Material.COOKED_BEEF).setAmount(4).build());
    inv.addItem(new ItemMaker(Material.BLAZE_ROD).setAmount(2).setDisplayName(ChatColor.YELLOW + "Morfina").build());
    inv.addItem(new ItemMaker(Material.SAPLING).setDisplayName(ChatColor.AQUA + "Kit Médico").build());
    inv.addItem(new ItemMaker(Material.PAPER).setDisplayName(ChatColor.RED + "Vendajes").build());
    inv.addItem(new AllItems().getGanzua());
}
 
开发者ID:cadox8,项目名称:WC,代码行数:13,代码来源:WoodburyCMD.java

示例13: onHeld

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onHeld(PlayerItemHeldEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    if (e.getNewSlot() == 0) {
        return;
    }
    if (e.getNewSlot() >= 2 && e.getNewSlot() <= 4) {
        int slot = e.getNewSlot();
        Player p = e.getPlayer();
        PlayerInventory inv = p.getInventory();
        ItemStack item = inv.getItem(slot).clone();
        item.setAmount(1);
        if (SkillManager.getInstance().isSkillSelector(item)) {
            Skill skill = SkillManager.getInstance().getSkillBySelector(item);
            if(skill.getSkillType().equals(SkillType.ITEM)){
                inv.setItem(0, skill.getShow());
            }
            else{
                Class<?> skillClazz=skill.getClass();
                try {
                    Method method =skillClazz.getMethod("doUpgrade",Player.class);
                    if(method!=null){
                        method.invoke(SkillManager.getInstance().getSkillByName(skill.getName()),p);
                    }
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            inv.setItem(2, ItemManager.getForbidden(3));
            inv.setItem(3, ItemManager.getForbidden(4));
            inv.setItem(4, ItemManager.getForbidden(5));
        }
    }
    e.setCancelled(true);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:41,代码来源:InventoryListener.java

示例14: getItemInHand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static ItemStack getItemInHand(CommandSender se) {
    if (se instanceof Player) {
        Player p = (Player) se;
        if (p.getInventory() != null) {
            ItemStack i = p.getInventory().getItemInMainHand();
            if (i != null && i.getType() != Material.AIR) {
                return i;
            }
        }
        throw new NoItemInHandException(false);
    } else {
        throw new NotPlayerException();
    }
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:15,代码来源:CommandReceiver.java

示例15: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
@SuppressWarnings("all")
public void run(PlayerInteractEvent evt) {
    Player player = evt.getPlayer();
    if (ControlTicker.isTracking(player)) {
        AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK);
        AzureAPI.log(player, "上一次攻击任务尚未结束!");
        return;
    }
    
    Inventory inv = player.getInventory();
    Block block = evt.getClickedBlock();
    Comparator data = (Comparator) block.getState().getData();
    
    if (!inv.contains(Material.SULPHUR)) {
        AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK);
        AzureAPI.log(player, "你没有弹药! 需要 " + ChatColor.RED + "火药" + ChatColor.GOLD + " 作为弹药");
        return;
    }
    int slot = inv.first(Material.SULPHUR);
    ItemStack ammo = inv.getItem(slot);
    int amount = ammo.getAmount();
    if (amount > 1) {
        ammo.setAmount(amount - 1);
        inv.setItem(slot, ammo);
    } else {
        inv.setItem(slot, null);
    }
    
    int timeout = 6;
    ControlTicker.request(this, player, block, TimeUnit.SECONDS, timeout);
    
    AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK, true);
    AzureAPI.log(player, "攻击任务预定成功, 你有 " + ChatColor.GREEN + timeout + ChatColor.GOLD + " 秒时间设定弹道");
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:36,代码来源:StructureTurret.java


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