Solved Items

Discussion in 'Spigot Plugin Help' started by Eptix, May 22, 2016.

  1. problem:

    1.
    - player can drop the items.
    2.
    - arrowmeta does not show.
    3.
    - i will not 1 arrow, i need 16 arrows, how can i do that?

    Code (Text):
    public void onJoin(PlayerJoinEvent e) {
           
            Player p = e.getPlayer();
            ItemStack stonesword = new ItemStack(Material.STONE_SWORD);
            ItemMeta stoneswordmeta = stonesword.getItemMeta();      
            stoneswordmeta.setDisplayName("§bKit §7- §bSchwert");
            ArrayList<String> stoneswordlore = new ArrayList<>();
            stoneswordlore.add("§8● §5FFA");
            stoneswordmeta.setLore(stoneswordlore);  
            stonesword.setItemMeta(stoneswordmeta);
            p.getInventory().setItem(0, stonesword);
           
            ItemStack bow = new ItemStack(Material.BOW);
            ItemMeta bowmeta = bow.getItemMeta();
            bowmeta.setDisplayName("§bKit §7- §bBogen");
            ArrayList<String> bowlore = new ArrayList<>();
            bowlore.add("§8● §5FFA");
            bowmeta.setLore(bowlore);
            bow.setItemMeta(bowmeta);
            p.getInventory().setItem(1, bow);
           
            ItemStack arrow = new ItemStack(Material.ARROW);
            ItemMeta arrowmeta = arrow.getItemMeta();
            arrowmeta.setDisplayName("§bKit §7- §bPfeil");
            ArrayList<String> arrowlore = new ArrayList<>();
            arrowlore.add("§8● §5FFA");
            arrowmeta.setLore(arrowlore);
            bow.setItemMeta(arrowmeta);
            p.getInventory().setItem(2, arrow);
     
  2. Cancel the PlayerDropItemEvent for that certain item.

    Code (Text):
    bow.setItemMeta(arrowmeta);
    You apply the arrowmeta to the bow, you meant arrow instead.

    Code (Text):
    ItemStack arrow = new ItemStack(Material.ARROW, 16);