MINIRPG

Discussion in 'Plugin Development' started by Plugers11, Apr 24, 2014.

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

    Plugers11

    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);
    }
     
  2. Offline

    CraftCreeper6

  3. Offline

    Plugers11

    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.
     
    Last edited by a moderator: Jun 7, 2016
  4. 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.
     
  5. Offline

    Plugers11

    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.
     
    Last edited by a moderator: Jun 7, 2016
  6. Plugers11 Either the getInstance() returns null or zabil is null
     
  7. Offline

    Bobit

    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.
     
  8. Offline

    Plugers11

    Can i do commands with configs and arrows ?
     
  9. Offline

    Bobit

    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.
     
  10. Offline

    Blackveil

    Code:java
    1. public void addArrow(Player p, int i){
    2. ItemStack arrow = new ItemStack(Material.ARROW);
    3. ItemMeta arrow2 = arrow.getItemMeta();
    4. arrow2.setDisplayName("Strzala maga lvl "+Integer.toString(i));
    5. arrow.setItemMeta(arrow2);
    6. p.getInventory().addItem(arrow);
    7. }


    There is no need to add an enchantment to an arrow, because it is pointless. Add the enchantment to a bow instead.
     
  11. Bobit I assumed it was probably just his main class, that seems logical at least.
     
  12. Offline

    stink123456

    You forgot to set the itemMeta (arrow.setItemMeta(arrow2));
     
Thread Status:
Not open for further replies.

Share This Page