Using other plugins' objects and stuff

Discussion in 'Plugin Development' started by Datdenkikniet, May 29, 2014.

Thread Status:
Not open for further replies.
  1. Hi guys,

    So, I'm trying to make an economy plugin, but this relies on another plugin (I know this isn't very clear, thats why I explain it below).
    So, what I want to do is this:
    In plugin A, there is an ArrayList<String>, which contains some strings, which are added when a player joins/leaves.
    In plugin B, I also have an ArrayList<String>, and I want it to be exactely equal to the one in plugin A, and it has to update when plugin A also updates its own ArrayList<String>.
    What do I have to do in order for that to work?

    Thanks in advance,

    Datdenkikniet
     
  2. Offline

    Garris0n

    Well, you should get rid of the second one and only use the first. No point in trying to keep them the same..
     
  3. Garris0n :/
    edit: You're probably right though
     
  4. Offline

    metalhedd

    to elaborate. you can directly access plugin A from plugin B by adding it as a dependency (and a library in your project) then do something like:

    PluginA a = getServer().getPluginManager().getPlugin("PluginA");
    a.getMyArrayList().add(something);
     
  5. Offline

    Garris0n

    metalhedd If he really wanted to, he could even just keep a variable referring to the same list instance.

    There is just no reason to attempt to keep two separate lists in complete sync like that.
     
    Smerfa likes this.
Thread Status:
Not open for further replies.

Share This Page