Get world returns null (Multiverse-Core?)

Discussion in 'Plugin Development' started by Zarkopafilis, Aug 28, 2014.

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

    Zarkopafilis

    Im using multiverse core. I use mv tp commands to teleport players but I cant get the world via
    getWorld(String name) (= null)

    Any solutions?
     
  2. Offline

    xTigerRebornx

    Zarkopafilis Post full code, you provide no context to your situation other then "I can't get the world". Where is the code called?
     
  3. Offline

    Zarkopafilis

    xTigerRebornx
    My main class contains:

    Code:
    public static World w = Bukkit.getWorld("testworld");
     
    @Override
    public void onEnable(){
    if(w == null){
      Bukkit.getLogger().log(Level.SEVERE, "null"); //this prints out
    }
    }
     
    @Override
    public void onDisable(){}
     
  4. Offline

    xTigerRebornx

    Zarkopafilis Problem is caused by your blatant abuse of static. Stop abusing statics, drop the current usage of static, and make sure your plugin is dependent on Multiverse and that Multiverse has actually loaded the World.
     
    funnyman850 and nlthijs48 like this.
  5. Offline

    Zarkopafilis

    I am not abusing static. I use the world in other classes as well. Do i need to get the world via multiverse or just check if its loaded and get it the standard way?
     
  6. Offline

    SmooshCakez

    1. Make sure the world is loaded by Multiverse.
    2. Remove the static modifier.


    Also, use the plugin logger (getLogger()) from JavaPlugin, not the Minecraft logger.
     
  7. Offline

    xTigerRebornx

    Zarkopafilis You are clearly abusing static, and it is now visible that you don't understand the proper use of static and believe that it exists "to let you use the variable in other classes".
    I am not sure how Multiverse handles it worlds, it may unload them if nobody is in it, or it may just keep it loaded. You'll have to research and find out.
     
  8. Offline

    Necrodoom

    I would think that the world won't even get its chance to load on the class creation. The world should be grabbed when its needed, not directly on startup.​
    And yes, get rid of the static.​
     
  9. Offline

    LordPyrak

    I've had this happen to me before, initialize the world in your onEnable.
    Code:java
    1. public static World w;
    2.  
    3. @Override
    4. public void onEnable(){
    5. w = Bukkit.getWorld("testworld");
    6. if(w == null){
    7. Bukkit.getLogger().log(Level.SEVERE, "null"); //this prints out
    8. }
    9. }
    10.  
    11. @Override
    12. public void onDisable(){}
     
Thread Status:
Not open for further replies.

Share This Page