Solved ItemMeta

Discussion in 'Plugin Development' started by justin_393, Aug 10, 2014.

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

    justin_393

    I'm trying to create a custom item name with ItemMeta, but I can't seem to get it right, here is my code.
    The error is in eclipse "Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList" That error is for Fireball and im. There is another error for my "." 's " Syntax error on token(s), misplaced construct(s)"
    I honestly have no clue what is wrong, so if someone could help it would be much appreciated.
    Code:java
    1. String Fireball = "Fireball";
    2.  
    3. ItemStack fireBall = new ItemStack(Material.STICK);
    4. ItemMeta im = fireBall.getItemMeta();
    5. im.setDisplayName(Fireball);
    6. fireBall.setItemMeta(im);
     
  2. Offline

    Forseth11

    Show me your imports please.
     
  3. Offline

    justin_393

    Forseth11
    Code:java
    1. import org.bukkit.ChatColor;
    2. import org.bukkit.Material;
    3. import org.bukkit.entity.EntityType;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerInteractEvent;
    8. import org.bukkit.inventory.ItemStack;
    9. import org.bukkit.inventory.meta.ItemMeta;
    10.  
    11. import jjbat_000.legendaryrealms.Core;
    12. import jjbat_000.legendaryrealms.LRPlayer;
     
  4. Offline

    Forseth11

    hmmm... weird that should be working. Can you post the stack trace from the console?
     
  5. Offline

    guangong4

    Check if your formatting is correct (opening and closing statements)
    Go to each bracket and eclipse should highlight the corresponding one.

    Usually if there's multiple errors for a piece of code that's simple like this, it probably that ^.
     
  6. Offline

    justin_393

    Last edited by a moderator: Jun 9, 2016
  7. Offline

    Forseth11

    Oh I did not read that part. These:
    Code:java
    1. String Fireball = "Fireball";
    2.  
    3. ItemStack fireBall = new ItemStack(Material.STICK);
    4. ItemMeta im = fireBall.getItemMeta();
    5. im.setDisplayName(Fireball);
    6. fireBall.setItemMeta(im);

    Are only in the class block. It has to be in a constructor or a method.
     
Thread Status:
Not open for further replies.

Share This Page