ItemStack help.

Discussion in 'Plugin Development' started by BeastCraft3, May 18, 2014.

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

    BeastCraft3

    Im wondering why this code doesnt work. I get an error at the playerinteract event, the error is on the ItemStack magma = new ItemStack(magma);
    ItemStack Slime = new ItemStack(Slime);
    please help me.
    Code:java
    1. ItemStack Slime = new ItemStack(Material.SLIME_BALL);{
    2. ItemMeta Slimemeta = Slime.getItemMeta();
    3. ArrayList<String> cc = new ArrayList<String>();
    4. Slimemeta.setDisplayName(ChatColor.YELLOW + "Players => " + ChatColor.RED + " Disabled");
    5. cc.add(ChatColor.YELLOW + "Players => " + ChatColor.RED + " Disabled");
    6. Slimemeta.setLore(cc);
    7. Slime.setItemMeta(Slimemeta);
    8. }
    9.  
    10. ItemStack magma = new ItemStack(Material.MAGMA_CREAM);{
    11. ItemMeta magmameta = magma.getItemMeta();
    12. ArrayList<String> cc = new ArrayList<String>();
    13. magmameta.setDisplayName(ChatColor.YELLOW + "Players => " + ChatColor.GREEN + " Enabled");
    14. cc.add(ChatColor.YELLOW + "Players => " + ChatColor.RED + " Enabled");
    15. magmameta.setLore(cc);
    16. magma.setItemMeta(magmameta);
    17. }

    Code:java
    1. @EventHandler
    2. public void playerInteract(PlayerInteractEvent event) {
    3. Player player = event.getPlayer();
    4. final Player player2 = event.getPlayer();
    5. ItemStack magma = new ItemStack([COLOR=#000000]magma[/COLOR]); <--- Error here!
    6. ItemStack Slime = new ItemStack([COLOR=#000000]Slime[/COLOR]); <--- Error here!
    7.  
     
  2. Offline

    tommyhoogstra

    As messy as your code is, you should also check if the item in the players hand has an item meta, if it doesnt, return

    You should also post the error.
     
  3. Offline

    BeastCraft3

    I've posted the error.. the error is in line 5 and 6 in the Playerinteractevent. I get a redline under the magma and Slime

    tommyhoogstra
    I've posted the error.. the error is in line 5 and 6 in the Playerinteractevent. I get a redline under the magma and Slime

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

    tommyhoogstra

    No, you posted the lines that ERRORED. I want to see the error, the stack trace from console
     
  5. Offline

    BeastCraft3

    nvm. Im going to post a different post on this ;3 to make it easier to understand
     
  6. Offline

    tommyhoogstra

    So you haven't even exported the plugin?
     
  7. Offline

    BeastCraft3

Thread Status:
Not open for further replies.

Share This Page