It's giving the player 2 items.

Discussion in 'Plugin Development' started by ninja2003, Jul 27, 2014.

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

    ninja2003

    I'm making a plugin for my server that gives that player an item a compass in this case and then they right click and select bla bla bla but for reason it gives me 2 items heres the code
    Code:java
    1. @EventHandler(priority=EventPriority.MONITOR)
    2. public void onPlayerJoinEvent(PlayerJoinEvent event)
    3. {
    4. Player p = event.getPlayer();
    5. if (event.getPlayer().getLocation().getWorld().getName().equals("Spawn"))
    6. {
    7. ItemStack spawncompass = new ItemStack(Material.COMPASS, 0);
    8. ItemMeta stackMeta = spawncompass.getItemMeta();
    9. stackMeta.setDisplayName(ChatColor.RED + "Quick Join!");
    10. ArrayList<String> lore = new ArrayList<String>();
    11. lore.add(ChatColor.GRAY + "If you don't feel like ");
    12. lore.add(ChatColor.GRAY + "running and jumping in ");
    13. lore.add(ChatColor.GRAY + "the portals this is the ");
    14. lore.add(ChatColor.GRAY + "perfect thing for you, All ");
    15. lore.add(ChatColor.GRAY + "you got to do is right click ");
    16. lore.add(ChatColor.GRAY + "me and choose the game you");
    17. lore.add(ChatColor.GRAY + "wanna play!");
    18. stackMeta.setLore(lore);
    19. spawncompass.setItemMeta(stackMeta);
    20. p.getInventory().addItem(spawncompass);
    21. }
    22. }
     
  2. Offline

    DannyDog

    ninja2003
    Nothing looks out of the ordinary besides the 0 on line 7.
    Maybe remove that extra argument.
     
  3. Offline

    Iroh

Thread Status:
Not open for further replies.

Share This Page