Not working code Player zginal = e.getEntity(); Player zabil = e.getEntity().getKiller(); int punkty = cfg.getInt(zginal.getName()+".Punkty"); int punktyz = cfg.getInt(zabil.getName()+".PunktyZ"); cfg.set(zginal.getName()+".Punkty", punkty-3); cfg.set(zabil.getName()+".PunktyZ", punktyz+1); cfg.save(file); if(cfg.getInt(zabil.getName()+".PunktyZ") == 1){ Strzala.getInstance().addArrow1(zabil); }else if(cfg.getInt(zabil.getName()+".PunktyZ") == 2){ Strzala.getInstance().addArrow2(zabil); }
Ohhhh i was idiot I don't do p.getInventory in my Arrow class Wait i test this Strzala.getInstance().addArrow3(zabil); This wasn't working Arrow class public void addArrow3(Player p){ ItemStack arrow = new ItemStack(Material.ARROW); ItemMeta arrow2 = arrow.getItemMeta(); arrow2.setDisplayName("Strzala maga lvl 3"); arrow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 3); p.getInventory().addItem(arrow); } public void addArrow2(Player p){ ItemStack arrow = new ItemStack(Material.ARROW); ItemMeta arrow2 = arrow.getItemMeta(); arrow2.setDisplayName("Strzala maga lvl 2"); arrow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 2); p.getInventory().addItem(arrow); } public void addArrow1(Player p){ ItemStack arrow = new ItemStack(Material.ARROW); ItemMeta arrow2 = arrow.getItemMeta(); arrow2.setDisplayName("Strzala maga lvl 1"); arrow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); p.getInventory().addItem(arrow); } Anybody can help ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Plugers11 It's hard to tell when you don't use the code tags or upload to pastebin, and also when you don't even try to tell us what isn't working. Also, you said "wasn't working"... yet I'm assuming it's still not working? Also, you'll need to set the item meta back on the arrow afterwards.
This is error Caused by: java.lang.NullPointerException at me.minirpg.eventy.Zginiecie.on(Zginiecie.java:35) ~[?:?] Strzala.getInstance().addArrow1(zabil); - 35 line AdamQpzm So what ? u can help ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
It seems like both would be null. Strzala doesn't seem to be declared to be anything at all, and as to zabil: of course there sometimes wouldn't be a killer, there are other ways for people to die than be killed by other people.
Don't post random code without even telling us what it does or formatting right and then post once every 5 minutes just so this thread will be at the top of the list, and then ask a question that is so general it's really impossible to tell what you're saying. I'm not coming back to this thread.
Code:java public void addArrow(Player p, int i){ ItemStack arrow = new ItemStack(Material.ARROW); ItemMeta arrow2 = arrow.getItemMeta(); arrow2.setDisplayName("Strzala maga lvl "+Integer.toString(i)); arrow.setItemMeta(arrow2); p.getInventory().addItem(arrow);} There is no need to add an enchantment to an arrow, because it is pointless. Add the enchantment to a bow instead.