why is getServer() undefined when i try to use it in a class that doesn't extend javaplugin

Discussion in 'Plugin Development' started by Relentless_x, Apr 9, 2011.

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

    Relentless_x

    The title says it all really... getServer() is undefined in a class that doesnt extend javaplugin .. why? and how do i get around this?

    Thanks in advance
     
  2. Offline

    Evenprime

    That's how Java works. getServer() is a method defined for the Class JavaPlugin, therefore you can only call it in that class or its children.

    EDIT: Forget what was here before, there is a much simpler method. Just use:

    Code:
    Bukkit.getServer();
    
    That works from everywhere.
     
  3. Offline

    Relentless_x

    thanks allot :) I'll try it out now :)
     
  4. Offline

    desmin88

    @Relentless_x
    If you don't quite understand EvenPrime I have some code that'll tell you how to do it.
    In another class file or somewhere where getServer() is undefined, do this.
    In your main class put this
    Code:
    Mainclassname Mainclassname = new Mainclassname();
    Them say in a playerListener, do this
    Code:
    Mainclassname.getServer();
     
  5. Offline

    Relentless_x

    ah yes i didnt even think of doing this aha, i mean i do it for all of the methods i make, guess because this is a built in one i didnt think of it :p thanks :)
     
Thread Status:
Not open for further replies.

Share This Page