Error

Discussion in 'Plugin Development' started by boogagoal1, Aug 26, 2013.

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

    boogagoal1

    Hey guys! I am currently making a custom FAQ plugin for my server and it was going perfect until I hit the item box GUI. Well, I hit that and this happened: http://hastebin.com/tukofepoxi.avrasm <--Look at line 62. On ItemStack ITEM <-it shows an error in Eclipse saying: Duplicate local variable item. Well, what do I do? I am sorry for so many issues. I started Java Saturday. Just a beginner.

    Never mind that. Fixed. How do I fix something when it says: Duplicate local variable lore (example)? I have had this happen various times.

    *Bump*

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

    leet4044

    It Means there's a duplicate value somewhere else in your code
     
  3. Offline

    boogagoal1

    What if I actually want it like that?
     
  4. Offline

    Polaris29

    No it doesn't, that means there are duplicate variable names in the same method|constructor body contained within the same code block or a code block and a nested block within that.



    You can't have duplicate local variable names, that's not how programming languages work
     
    Rocoty likes this.
  5. Offline

    xTrollxDudex

    boogagoal1
    You forgot to check if the sender Player
     
    boogagoal1 likes this.
  6. Offline

    boogagoal1

    So what would be the correct way? Polaris29
     
  7. Offline

    Polaris29

    Well, if duplicate variable names is what your problem is, then just rename one of them.
     
  8. Offline

    boogagoal1

    I did so: http://pastebin.com/x5Wbt0JR but now the Iron Sword doesn't show on the second box and the Zombie Head isn't named MC-IF. Neither does it say Custom and MCInfected. Did I do something wrong? Thanks.
     
  9. Offline

    Polaris29

    boogagoal1 I think you have to re set the item's meta with item.setMeta(itemMeta); and also, you're adding the iron sword to the player's inventory, not the custom inventory
     
  10. Offline

    boogagoal1

    So between what lines do I add item.setMeta(itemMeta) or where?
     
  11. Offline

    Polaris29

    boogagoal1 After you're done doing stuff with the item's meta
     
  12. Offline

    boogagoal1

    Uh... I don't know... I actually was just given this code and don't understand it. The itembox GUI. Can you add me on Skype at "ethan.fine1" please? I'd really appreciate it.
     
  13. Offline

    Polaris29

    boogagoal1 You would just do something like this:

    Code:java
    1.  
    2. ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte)2 );
    3. // Get the meta
    4. ItemMeta itemMeta = item.getItemMeta();
    5. // Do stuff to the meta
    6. itemMeta.setDisplayName("MC-IF");
    7. List <String> lore = new ArrayList<String>();
    8. lore.add("Custom");
    9. lore.add("MCInfected");
    10. itemMeta.setLore(lore);
    11. // Set the meta once your done doing stuff to it
    12. item.setMeta(itemMeta); // Might be setItemMeta
    13.  
     
Thread Status:
Not open for further replies.

Share This Page