Calling Methods

Discussion in 'Plugin Development' started by BeerHuntor, Mar 27, 2014.

Thread Status:
Not open for further replies.
  1. Ok so I am trying to call a method from a different class, I have looked all over the internet, nothing I seem to to works. Your probably thinking what a noob question. And your probably right. I didnt want to post it here, but having found nothing that works for my situation, I have to post here.

    Main Class: http://pastebin.com/bcQJXrbJ
    Listener Class: http://pastebin.com/8yR4VnZL
    Inventory Class: http://pastebin.com/L1pemRc0

    I could easily get round this by only having one class, but It looks really untidy with everything in one class. I am trying to call the Method saveInventory() from the inventory class in the listener class.
     
  2. BeerHuntor While we could tell you exactly how to call methods from other classes, you'd be better off in the long run if I just give you this advice:

    Learn Java before trying to make plugins. At least the fundamentals of it, if nothing else.

    Also, there should only be one class extending JavaPlugin in a plugin.
     
    Rocoty and The Fancy Whale like this.
  3. Offline

    The Fancy Whale

  4. I do know java and have made plugins before. However, my last time coding was 3 years ago and have lost touch with a few things. I just asked for help. A refresher if you will. But I see I will not get that from here. I think I will stick to the IRC channel for help in the future, the guys there seem to be abit more welcoming.

    The Fancy Whale Thank you for the link. Didn't even occur to me to check the java website.
     
  5. Well, as it is static, i think you can just do DuelMeInventory.saveInventory();. Else use:

    DuelMeInventory duelInv = new DuelMeInventory(plugin);
    duelInv.saveInventory();

    Be sure to type new DuelMeInventory AFTER DuelMe plugin;.
     
  6. WeeziMonkey Yeah i figured out how to do it. I tried the first instance but it didn't work, so I had to create an object of the class. Second instance you put forward is something similar to what I have done, but it needs a player as arguments. I am assuming

    Player p = event.getEntity().getPlayer();

    duelInv.saveInventory(p); in the onDeath method will get the players inventory who dies?
     
Thread Status:
Not open for further replies.

Share This Page