Put Data and quantity in ItemStack with variable

Discussion in 'Plugin Development' started by BuzzSmooth, Sep 8, 2015.

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

    BuzzSmooth

    I would like to put amount and in the object's data but I can not because there is a variable

    Code:
       new ItemStack(159, votesForDawn),

    Please write the correct code

    With their respective ID, amount and DATA

    THANKS
     
  2. Offline

    undeaD_D

  3. Offline

    BuzzSmooth

    Last edited by a moderator: Jun 11, 2016
  4. Offline

    undeaD_D

    @BuzzSmooth
    i know you can do it yourself ;)
    the link is all you need :)

    here you go:
    SPOONFEED (open)

    Code:
    //replace "[item amount]" and "[dye number]" to your liking
    new ItemStack(Material.HARDENED_CLAY, [item amount], (short) [dye number])
    
     
  5. Offline

    BuzzSmooth

    Code:
    new ItemStack(159, 1,(short) 1 votesForDawn),
    I need to link votesForDawn so it runs an action to give you click

    Code:
          Game game = gamePlayer.getGame();
            int votesForDawn = 0;
            int votesForNoon = 0;
            int votesForDusk = 0;
            int votesForMidnight = 0;
            for (GamePlayer gPlayer: game.getPlayers()) {
                if (gPlayer.getTimeVote() == 1) {
                    votesForDawn++;
                } else if (gPlayer.getTimeVote() == 2) {
                    votesForNoon++;
                } else if (gPlayer.getTimeVote() == 3) {
                    votesForDusk++;
                } else if (gPlayer.getTimeVote() == 4) {
                    votesForMidnight++;
                }
            }
           
            if (gamePlayer.getP() != null) {
                List<String> loreList = Lists.newLinkedList();
                SkyWarsReloaded.getIC().setOption(
                                gamePlayer.getP(),
                                10,
                                new ItemStack(159, 1,(short) votesForDawn),
                                new Messaging.MessageFormatter().format("menu.time-dawn"),
                                loreList.toArray(new String[loreList.size()]));
    This is the code completely, well above part

    Please help me! :(

    This code new ItemStack(159, 1, (short) ((short) 1 + (votesForDawn))), is fail

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  6. If you want to set the amount this sould work
    Code:
    new ItemStack(Material.STAINED_CLAY, votesForDawn);
    
    Or you want to change the color from the clay ?
    Code:
    new ItemStack(Material.STAINED_CLAY, 1, (short) (votesForDawn > 15 ? 15 : votesForDawn));
    
     
Thread Status:
Not open for further replies.

Share This Page