Solved Solved

Discussion in 'Plugin Development' started by MagicMan, Apr 8, 2014.

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

    MagicMan

    Solved
     
  2. Offline

    PratamaJr

    Code:java
    1. ItemStack magma = new ItemStack(Material.MAGMA_CREAM, 16);
    2. magma.setDuralibity(1552);
    3.  
    4.  
    5.  
    6.  


    Note : 16 is amount of MAGMA CREAM

    and add this for ur player

    Code:
    player.getInventory().addItem(magma);
    MagicMan If its work tell me...
     
  3. Offline

    MagicMan



    What do you mean add this for your player?
    Would I just make a complete new paragraph? Or A listener?
    Sorry I'm new at this whole java thing so could you be more specific?
     
  4. Offline

    PratamaJr

    MagicMan Sorry, if you do not know what I mean

    I mean "For Player"

    Add player.getInventory().addItem(magma); in CommandExecutor

    and make sure you already make Player player = (Player) sender;
     
  5. Offline

    MagicMan


    Thank you so much :) I will try it right away
     
  6. Offline

    PratamaJr

    MagicMan okay...tell me if not work
     
  7. Offline

    MagicMan


    Wait so would this be the code:
    Show Spoiler
    Player player = (Player) sender;
    ItemStack magma = new ItemStack(Material.MAGMA_CREAM,1);
    magma.setDurability(1552);
    player.getInventory().addItem(magma)
     
  8. Offline

    PratamaJr

    MagicMan yes...add this in CommandExecutor....
     
  9. Offline

    MagicMan

    Ok great bro if this works I will credit you in my project
    Equivalent Exchange 3 :)
     
  10. Offline

    PratamaJr

    MagicMan You'r Welcome ;)

    MagicMan wait,,,, weapon.setDurability((short) 1152); change this!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  11. Offline

    MagicMan


    One more question. How would I add permission so only people with that certain permission can craft with "magma"
     
  12. Offline

    PratamaJr

    MagicMan wait....a few minutes

    I'll take a bath

    MagicMan hmmm....i was try it but doesnt work

    wait i fix after take a bath

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  13. Offline

    MagicMan

    Could you rewrite the code to add in the weapon.setdurability before you answer the questions?
    Thanks bro you are a great help <3
     
  14. Offline

    CrazyGuy3000

    Your durability should be in minus like so
    Code:
    magma.setDuralibity((short) -1552);
     
  15. Offline

    PratamaJr

  16. Offline

    MagicMan

    Show Spoiler
    Player player = (Player) sender;
    ItemStack magma = new ItemStack(Material.MAGMA_CREAM,1);
    magma.setDurability((short) -1552);
    player.getInventory().addItem(magma)


    Ok thats my new code
     
  17. Offline

    PratamaJr

    MagicMan add this in command executor and look....

    work or not...
     
  18. Offline

    MagicMan

    I can't at the moment :( Im on my laptop and my project file is on my cmoputer but my sisters on it -.-. If i take her off her baby songs she will cry

    Could you try xD?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  19. Offline

    CrazyGuy3000

    Don't double post, also Don't bump (As that what this will do) without waiting at least 12 hours.
     
  20. Offline

    MagicMan


    It says Player player = (Player) sender; sender is an error
     
  21. Offline

    PratamaJr

  22. Offline

    MagicMan


    Show Spoiler
    Player player = (Player) sender;
    ItemStack MINIUM_STONE = new ItemStack(Material.MAGMA_CREAM);
    MINIUM_STONE.setDurability((short) -1552);
    player.getInventory().addItem(MINIUM_STONE);
    ItemMeta meta = MINIUM_STONE.getItemMeta();
    meta.setDisplayName(ChatColor.RED + "Minium Stone");
    meta.addEnchant(Enchantment.ARROW_INFINITE, 69, true);
    MINIUM_STONE.setItemMeta(meta);


    Says on the first sentence that sender is an error if this is fixed then my whole code is ready to go.
     
  23. Offline

    Maurdekye

    MagicMan First of all, sender is an error because PratamaJr gave you improper instructions; he assumed you'd be using a command to get the item. Just remove that line, and you should be mostly good.
    Also, the durability thing won't work, as Magma Creams don't hold metadata, and I'm pretty sure that it wouldn't do anything. You would have to store the durability in the item's lore, like so;
    Code:java
    1. int durability = 1552;
    2. ItemStack miniumStone = new ItemStack(Material.MAGMA_CREAM);
    3. ItemMeta meta = miniumStone.getItemMeta();
    4. meta.setLore(Arrays.asList(durability + ""));
    5. miniumStone.setItemMeta(meta);
    6. // ... and so on

    You could the retrieve the charges left using this line;
    Code:java
    1. int charges = Integer.parseInt(miniumStone.getItemMeta().getLore().get(0));
     
  24. Offline

    MagicMan


    It shows Arrays as an error and I have to import it but what do I import it from? java.until or what?
     
  25. Offline

    Maurdekye

    MagicMan Do you know how to import classes?
     
  26. Offline

    MagicMan


    No but could you teach me?
     
  27. Offline

    Maurdekye

    MagicMan This is basic stuff, man. You should know how to do this before even attempting a Bukkit plugin.
    Just look it up.
     
  28. Offline

    MagicMan


    Ok look I know I'm not the greatest but could you help me just this once? Do I just have to create a class from Arrays?
     
  29. Offline

    Maurdekye

    MagicMan No, no no. Import. Arrays is a utility class that preexists in Java; just import it so you can use the class.
     
  30. Offline

    MagicMan


    Ok so I looked it up and an answer was decompile it is this true or more searching?
     
Thread Status:
Not open for further replies.

Share This Page