How Do I Add Data Values to a Give Command?

Discussion in 'Plugin Development' started by KvackPack, Jun 25, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    KvackPack

    I have some problems with my give command code. I tried to fix it with data values, but the Player.getInventory().addItem(item); ignores it. Do I have to make more splits instead of two.
    Right now it is /item [0] [1]
    [0]= item id,data
    [1]= amount
    Do I have to make 3 splits instead of two?
    /item [0] [1] [2]
    [0]=item
    [1]= data
    [2]=amount
    And make "," = " " so you can do=
    /Item wool,3 64
     
  2. Offline

    Lolmewn

    Material m = Material.getMaterial(itemID);
     
  3. Offline

    KvackPack

    Should I add it like this? :
    Code:
    if (isInt(data[0])){
                        ItemStack item = new ItemStack(Integer.parseInt(data[0]), stack);
                        Material m = Material.getMaterial(stack);
                        item.setData(new MaterialData(Integer.parseInt(data[0]),(byte)Integer.parseInt(data[1])));
                        Player.getInventory().addItem(item);
                        Player.sendMessage(ChatColor.DARK_RED + "Given " + itemnamelist.get(Integer.parseInt(split[0])).replace('_', ' ').toLowerCase() + " in your inventory");
                        return true;
                    }
     
Thread Status:
Not open for further replies.

Share This Page