Package org.bukkit.inventory

Examples of org.bukkit.inventory.ItemStack


    List<ItemStack> items = new ArrayList<ItemStack>();
    String[] itemsStrSplit = invString.split(";;");
    for (String itemStr : itemsStrSplit) {
      String[] itemStrSplit = itemStr.split(";");
      if (itemStrSplit.length == 4) {
        ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
        stack.setData(new MaterialData(stack.getTypeId(), Byte.parseByte(itemStrSplit[3])));
        short durability = (short) Integer.parseInt(itemStrSplit[2]);
        stack.setDurability(durability);
        items.add(stack);
      } else if (itemStrSplit.length == 3) {
        ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
        short durability = (short) Integer.parseInt(itemStrSplit[2]);
        stack.setDurability(durability);
        items.add(stack);
      } else {
        items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1])));
      }
    }
    return items;
  }
View Full Code Here


      String prefix = loadoutName + "." + slot + ".";
      int id = config.getInt(prefix + "id");
      int amount = config.getInt(prefix + "amount");
      short durability = (short)config.getInt(prefix + "durability");
     
      ItemStack stack = new ItemStack(id, amount, durability);
      stack.setDurability(durability);
     
      if (config.contains(prefix + "enchantments")) {
        List<String> enchantmentStringList = config.getStringList(prefix + "enchantments");
        for (String enchantmentString : enchantmentStringList) {
          String[] enchantmentStringSplit = enchantmentString.split(",");
          if (enchantmentStringSplit.length == 2) {
            int enchantId = Integer.parseInt(enchantmentStringSplit[0]);
            int level = Integer.parseInt(enchantmentStringSplit[1]);
            War.war.safelyEnchant(stack, Enchantment.getById(enchantId), level);
          }
        }
      }
      if (config.contains(prefix + "armorcolor")) {
        int rgb = config.getInt(prefix + "armorcolor");
        Color clr = Color.fromRGB(rgb);
        LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta();
        meta.setColor(clr);
        stack.setItemMeta(meta);
      }
      if (config.contains(prefix + "name")) {
        String itemName = config.getString(prefix + "name");
        ItemMeta meta = stack.getItemMeta();
        meta.setDisplayName(itemName);
        stack.setItemMeta(meta);
      }
      if (config.contains(prefix + "lore")) {
        List<String> itemLore = config.getStringList(prefix + "lore");
        ItemMeta meta = stack.getItemMeta();
        meta.setLore(itemLore);
        stack.setItemMeta(meta);
      }
      loadout.put(slot, stack);
    }
    String permission = config.getString(loadoutName + ".permission", "");
    return new Loadout(loadoutName, loadout, permission);
View Full Code Here

    ConfigurationSection loadoutSection = section.createSection(loadoutName);
   
    if (loadoutSection != null) {
      loadoutSection.set("slots", toIntList(loadout.keySet()));
      for (Integer slot : loadout.keySet()) {
        ItemStack stack = loadout.get(slot);
        loadoutSection.set(slot.toString(), stack);
      }
    }
  }
View Full Code Here

            Team victim = zone.getVictimTeamForFlagThief(player.getName());
            player.setItemInHand(null);
            player.getInventory().addItem(victim.getKind().getBlockData().toItemStack(2240));
          } else if (zone.isBombThief(player.getName())) {
            player.setItemInHand(null);
            player.getInventory().addItem(new ItemStack(Material.TNT, 2240));
          } else if (zone.isCakeThief(player.getName())) {
            player.setItemInHand(null);
            player.getInventory().addItem(new ItemStack(Material.CAKE_BLOCK, 2240));
          }
        }
      }
    }
  }
View Full Code Here

      int xi = relative.getX() - minX, yi = relative.getY() - minY, zi = relative.getZ() - minZ;
      if (changes != null) {
        changes[xi][yi][zi] = true;
      }
      BlockState modify = relative.getState();
      ItemStack data = new ItemStack(Material.valueOf(query.getString("type")), 0, query.getShort("data"));
      if (modify.getType() != data.getType() || !modify.getData().equals(data.getData())) {
        // Update the type & data if it has changed
        modify.setType(data.getType());
        modify.setData(data.getData());
        modify.update(true, false); // No-physics update, preventing the need for deferring blocks
        modify = corner1.getRelative(x, y, z).getState(); // Grab a new instance
      }
      if (query.getString("metadata") == null || query.getString("metadata").isEmpty()) {
        continue;
View Full Code Here

    // Set the spawn
    int x = teamSpawn.getBlockX();
    int y = teamSpawn.getBlockY();
    int z = teamSpawn.getBlockZ();
   
    ItemStack light = this.warzone.getWarzoneMaterials().getLightBlock();

    TeamSpawnStyle style = this.getTeamConfig().resolveSpawnStyle();
    if (!style.equals(TeamSpawnStyle.INVISIBLE)) {
      // first ring
      this.setBlock(x + 1, y - 1, z + 1, this.kind);
      this.setBlock(x + 1, y - 1, z, this.kind);
      this.setBlock(x + 1, y - 1, z - 1, this.kind);
      this.setBlock(x, y - 1, z + 1, this.kind);
      BlockState lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
      lightBlock.setType(light.getType());
      lightBlock.setData(light.getData());
      lightBlock.update(true);
      this.setBlock(x, y - 1, z - 1, this.kind);
      this.setBlock(x - 1, y - 1, z + 1, this.kind);
      this.setBlock(x - 1, y - 1, z, this.kind);
      this.setBlock(x - 1, y - 1, z - 1, this.kind);
View Full Code Here

  // For future use
  public Map<String, Object> serialize() {
    Map<String, Object> config = new HashMap<String, Object>();
    config.put("slots", this.toIntList(contents.keySet()));
    for (Integer slot : contents.keySet()) {
      ItemStack stack = contents.get(slot);
      config.put(slot.toString(), stack.serialize());
    }
    config.put("permission", permission);
    return config;
  }
View Full Code Here

    teamDefaultConfig.put(TeamConfig.INVENTORYDROP, false);

    this.getDefaultInventories().clearLoadouts();
    HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
   
    ItemStack stoneSword = new ItemStack(Material.STONE_SWORD, 1, (byte) 8);
    stoneSword.setDurability((short) 8);
    defaultLoadout.put(0, stoneSword);
   
    ItemStack bow = new ItemStack(Material.BOW, 1, (byte) 8);
    bow.setDurability((short) 8);
    defaultLoadout.put(1, bow);
   
    ItemStack arrows = new ItemStack(Material.ARROW, 7);
    defaultLoadout.put(2, arrows);
   
    ItemStack stonePick = new ItemStack(Material.IRON_PICKAXE, 1, (byte) 8);
    stonePick.setDurability((short) 8);
    defaultLoadout.put(3, stonePick);
   
    ItemStack stoneSpade = new ItemStack(Material.STONE_SPADE, 1, (byte) 8);
    stoneSword.setDurability((short) 8);
    defaultLoadout.put(4, stoneSpade);
       
    this.getDefaultInventories().addLoadout("default", defaultLoadout);
   
    HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
    reward.put(0, new ItemStack(Material.CAKE, 1));
    this.getDefaultInventories().setReward(reward);
   
    this.getCommandWhitelist().add("who");
    this.getZoneMakerNames().add("tommytony");
    this.setKillstreakReward(new KillstreakReward());
View Full Code Here

          warzone.getDefaultInventories().setReward(reward);
          returnMessage.append(" game end reward updated.");
        }
        if (namedParams.containsKey("lobbymaterial")) {
          String whichBlocks = namedParams.get("lobbymaterial");
          ItemStack blockInHand = player.getItemInHand();
          boolean updatedLobbyMaterials = false;
         
          if (!blockInHand.getType().isBlock() && !blockInHand.getType().equals(Material.AIR)) {
            this.badMsg(player, "Can only use blocks or air as lobby material.");
          } else {
            if (whichBlocks.equals("floor")) {
              warzone.getLobbyMaterials().setFloorBlock(blockInHand);
              returnMessage.append(" lobby floor material set to " + blockInHand.getType());
              updatedLobbyMaterials = true;
            } else if (whichBlocks.equals("outline")) {
              warzone.getLobbyMaterials().setOutlineBlock(blockInHand);
              returnMessage.append(" lobby outline material set to " + blockInHand.getType());
              updatedLobbyMaterials = true;
            } else if (whichBlocks.equals("gate")) {
              warzone.getLobbyMaterials().setGateBlock(blockInHand);
              returnMessage.append(" lobby gate material set to " + blockInHand.getType());
              updatedLobbyMaterials = true;
            } else if (whichBlocks.equals("light")) {
              warzone.getLobbyMaterials().setLightBlock(blockInHand);
              returnMessage.append(" lobby light material set to " + blockInHand.getType());
              updatedLobbyMaterials = true;
            }
           
            if (updatedLobbyMaterials && warzone.getLobby() != null) {
              warzone.getLobby().getVolume().resetBlocks();
              warzone.getLobby().initialize();
            }
          }
        }
        if (namedParams.containsKey("material")) {
          String whichBlocks = namedParams.get("material");
          ItemStack blockInHand = player.getItemInHand();
          boolean updatedMaterials = false;
         
          if (!blockInHand.getType().isBlock()) {
            this.badMsg(player, "Can only use blocks as material.");
          } else {
            if (whichBlocks.equals("main")) {
              warzone.getWarzoneMaterials().setMainBlock(blockInHand);
              returnMessage.append(" main material set to " + blockInHand.getType());
              updatedMaterials = true;
            } else if (whichBlocks.equals("stand")) {
              warzone.getWarzoneMaterials().setStandBlock(blockInHand);
              returnMessage.append(" stand material set to " + blockInHand.getType());
              updatedMaterials = true;
            } else if (whichBlocks.equals("light")) {
              warzone.getWarzoneMaterials().setLightBlock(blockInHand);
              returnMessage.append(" light material set to " + blockInHand.getType());
              updatedMaterials = true;
            }
           
            if (updatedMaterials) {
              // reset all structures
View Full Code Here

    volume.setCornerTwo(corner2);
    ResultSet query = stmt.executeQuery("SELECT * FROM blocks");
    while (query.next()) {
      int x = query.getInt("x"), y = query.getInt("y"), z = query.getInt("z");
      BlockState modify = corner1.getRelative(x, y, z).getState();
      ItemStack data = new ItemStack(Material.valueOf(query.getString("type")), 0, query.getShort("data"));
      modify.setType(data.getType());
      modify.setData(data.getData());
      volume.getBlocks().add(modify);
    }
    query.close();
    stmt.close();
    databaseConnection.close();
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.ItemStack

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.