Solved Not being able to teleport to world after reload

Discussion in 'Plugin Development' started by AdamDev, Dec 2, 2018.

  1. Offline

    AdamDev

    So, I seem to have run straight into a weird bug or something wrong with loading the worlds. With the command /fhome <factory #>, depending on the integer inputted it will teleport you to that specific world but it seems that I have to do /fbf ( to buy the factory and create the world, even though it's already created ), buy the factory and relog. After coming back on and doing /fhome 1 or /fhome it says that it teleports but comes up with a NullPointerException on my world.

    The worlds work as so:
    - Upon creating the world, it saved with an integer (ex. 1). After the integer is created, it is added to the player's name (ex. Steve). The complete world name would be Steve1. Screenshot: [​IMG]
    - This is also saved to the player's config as well the world is saved to the factory worlds list. Screenshots:
    Players Config VVV Factory Config VVV
    [​IMG] [​IMG]
    - Even after debugging in the game by sending the players name and id together in the game, it still tells me that the world is null in the errors because it wouldn't send me that message of it together if it wasnt null. Screenshot: That's what it would do if it is null
    [​IMG]

    I've tried the best I can, but it seems that I have reached a blockade.

    Thanks for the help,

    - AdamDev
     
  2. Offline

    knokko

    @AdamDev

    I think we will need to see some of your code to solve this. Specifically, the code that makes sure the worlds aren't null and the code where you load the data from your config. If I understand the problem correctly: all factory worlds become null after leaving it and coming back.
    And what do you mean with coming back? Logging in and out? Leaving the factory world and coming back? Restarting the server? Reloading the server?
     
  3. Offline

    The_Spaceman

    when reloading/restarting the world you need to reload the world again. use the
    [​IMG]again, loop through the saved factories and then the worlds are getting loaded in Bukkit
     
  4. Offline

    AdamDev

    Sorry I didnt specify. I'll have some code when I get to my conputer. What I mean is that logging off the server and then logging back onto the server.

    As I had said before, I'm not currently home so I can test anything but let me understand what you're getting at. Upon reload, I check if the worlds on the server are in the list of factory worlds. Pretty tough to write code here but ill try:
    Code:
    if (factoryworlds.contains(serverworldname)) {
        WorldCreator wc = new WorldCreator(serverworldname);
        wc.createWorld(serverworldname);
    }
    Am I right?
     
  5. Offline

    The_Spaceman

    update: after a restart of the server you have to re-create all your world
    only when the server starts... (I forgot)

    just put in your onEnable() {
    for (String customWorldName : customWorlds) {
    WorldCreator wc = new WorldCreator(customWorldName);
    Bukkit.getServer().createWorld(wc);
    }
    }
     
  6. Offline

    AdamDev

    @The_Spaceman
    Well, it seems your solution has worked and I'll have to work around some other things.
    Marked as solved.
     
    The_Spaceman likes this.

Share This Page