Package org.bukkit.inventory

Examples of org.bukkit.inventory.PlayerInventory


  public Inventory getInventoryView(String name)
  {
    Player player = this.getPlayer();
    if (player == null) return null;

    PlayerInventory pInventory = player.getInventory();
    String inventoryName = name.length() > 32 ? name.substring(0, 32) : name;
    Inventory inventoryView = Bukkit.getServer().createInventory(null,
      pInventory.getSize() + 9, inventoryName);

    ItemStack[] oldContents = pInventory.getContents();
    ItemStack[] newContents = inventoryView.getContents();

    newContents[oldContents.length + SLOT_HELMET] = copyItem(pInventory.getHelmet());
    newContents[oldContents.length + SLOT_CHEST] = copyItem(pInventory.getChestplate());
    newContents[oldContents.length + SLOT_LEGS] = copyItem(pInventory.getLeggings());
    newContents[oldContents.length + SLOT_FEET] = copyItem(pInventory.getBoots());

    // SLOT 6: ACTIVE POTION EFFECTS
    if (player.getActivePotionEffects().size() > 0)
    {
      ItemStack potion = new Potion(PotionType.POISON).toItemStack(1);
View Full Code Here


  public void giveTo(AutoRefPlayer apl)
  {
    Player pl = apl.getPlayer();
    if (pl == null) return;

    PlayerInventory pinv = pl.getInventory();
    pinv.clear();

    // set armor slots
    pinv.setHelmet(getHelmet() == null ? null : cloneItem(apl, getHelmet()));
    pinv.setChestplate(getChest() == null ? null : cloneItem(apl, getChest()));
    pinv.setLeggings(getLeggings() == null ? null : cloneItem(apl, getLeggings()));
    pinv.setBoots(getBoots() == null ? null : cloneItem(apl, getBoots()));

    // give items (cloned, adjusted)
    for (ItemStack item : getGear())
      pinv.addItem(cloneItem(apl, item));

    // assign potion effects
    for (PotionEffect effect : getPotionEffects())
      pl.addPotionEffect(effect, true);
  }
View Full Code Here

    public static final int getArmorPoints(Player player) {
        int currentDurability = 0;
        int baseDurability = 0;
        int baseArmorPoints = 0;
        ItemStack[] itm = new ItemStack[4];
        PlayerInventory inv = player.getInventory();
        itm[0] = inv.getBoots();
        itm[1]= inv.getLeggings();
        itm[2] = inv.getChestplate();
        itm[3] = inv.getHelmet();
        for(int i = 0; i < 4; i++) {
        if(itm[i] == null) continue;
          int dur = itm[i].getDurability();
          int max = itm[i].getType().getMaxDurability();
          if(max <= 0) continue;
View Full Code Here

      @Override
      @Nullable
      public Slot get(final LivingEntity p) {
        if (!delayed) {
          if (e instanceof PlayerItemHeldEvent && ((PlayerItemHeldEvent) e).getPlayer() == p) {
            final PlayerInventory i = ((PlayerItemHeldEvent) e).getPlayer().getInventory();
            assert i != null;
            return new InventorySlot(i, getTime() >= 0 ? ((PlayerItemHeldEvent) e).getNewSlot() : ((PlayerItemHeldEvent) e).getPreviousSlot());
          } else if (e instanceof PlayerBucketEvent && ((PlayerBucketEvent) e).getPlayer() == p) {
            final PlayerInventory i = ((PlayerBucketEvent) e).getPlayer().getInventory();
            assert i != null;
            return new InventorySlot(i, ((PlayerBucketEvent) e).getPlayer().getInventory().getHeldItemSlot()) {
              @Override
              @Nullable
              public ItemStack getItem() {
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.PlayerInventory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.