Development Assistance Plugin already initialized

Discussion in 'Plugin Help/Development/Requests' started by stefvanschie, Jun 23, 2015.

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

    stefvanschie

  2. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
    @stefvanschie Why are you calling the constructor of BuildingGame?
     
  3. Offline

    stefvanschie

    @timtower I want to get certain thing like my Yaml files from the main class (in this case the BuildingGame class)
     
  4. Online

    timtower Administrator Administrator Moderator

    @stefvanschie Then pass the main instance in the constructor of the listener class. Making a new instance isn't possible.
     
  5. Offline

    stefvanschie

    How would I do that? Never worked with different classes before.
     
  6. Offline

    nverdier

  7. Offline

    stefvanschie

    @nverdier Well I already now C# and I'm learning Java, but when I look on: Java reference to other classes, they say I have to do it like I've done, so I don't know why it doesn't work.
     
  8. Online

    timtower Administrator Administrator Moderator

    @stefvanschie Because you are making a new instance instead of passing along the old one.
     
  9. Offline

    stefvanschie

  10. Online

    timtower Administrator Administrator Moderator

  11. Offline

    stefvanschie

    Something like this?
    Code:
    public BuildingGame(Join, instance)
    {
      this.instance = join;
    }
     
  12. Online

    timtower Administrator Administrator Moderator

  13. Offline

    stefvanschie

    @timtower Tried that before, but I got an Abnormal Plugin State error. I found another way that goes like this:
    Code:
    public static BuildingGame main;
    @Override
    public void onEnable()
    {
      main = this;
    }
    But this only works with the class that has the Java plugin, 'cause the other classes don't have the onEnable. How would I do this in the other classes?
     
  14. Online

    timtower Administrator Administrator Moderator

    @stefvanschie Then you did something else wrong. And I won't do anything static
     
  15. Offline

    stefvanschie

    What's wrong with static?
     
  16. Offline

    Boomer

    cough offline mode cough switch that before the thread gets shutdown for plugin-code helping on an offline-mode server cough cough
     
  17. Offline

    Xerox262

    This is probably gonna get removed for being irrelevant to the post, but I don't get the whole no offline mode rule... When I make a plugin it's final use is an online server, but it's so much easier to test in an offline server, that way I don't get the annoying "Invalid game session, please log in again" message in the middle of testing.

    To make this post relevant i'll say this

    Anything variable = new Anything();
    Never do that to a class that extends JavaPlugin, if you need the plugin in your Join class do this

    Join join = new Join(this);

    then in join put

    BuildingGame plugin;

    public Join(BuildingGame instance) {
    plugin = instance;
    }
     
  18. Online

    timtower Administrator Administrator Moderator

    Thanks for the notice.
    Locked.
    That is why
     
Thread Status:
Not open for further replies.

Share This Page