Error with getting world name from config.

Discussion in 'Plugin Development' started by PlayFriik, Dec 27, 2014.

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

    PlayFriik

    That is my line:
    Code:
    String worldName = plugin.getConfig().getString("Maps.");
    
    When I debug it:
    Code:
    MemorySection[path='Maps', root='YamlConfiguration']
    Config section:
    Code:
    Maps:
      World:
        spawn:
          X: 0
          Y: 100
          Z: 0
     
    Last edited: Dec 27, 2014
  2. Offline

    nopvpgamer

    Code:
    String world = getConfig().getString("Maps");
     
  3. Offline

    PlayFriik

    Same result..
     
  4. Offline

    Rocoty

    @PlayFriik Uhm...sorry, what are you trying to do?
     
  5. Offline

    PlayFriik

    @Rocoty
    Hmm, pretty much I am trying to get world name, and then I am gonna use the world name for spawn, so basically I can change worldname whatever I want.

    Code:
            String worldName = plugin.getConfig().getString("Maps");
            double X = plugin.getConfig().getInt("Maps." + worldName + ".spawn.X" + 0.5);
            double Y = plugin.getConfig().getInt("Maps." + worldName + ".spawn.Y");
            double Z = plugin.getConfig().getInt("Maps." + worldName + ".spawn.Z" + 0.5);
            World world = Bukkit.getWorld(worldName);
            Location location = new Location(world, X, Y, Z);
            player.sendMessage(worldName); // debug
            player.teleport(location);
    
     
    Last edited: Dec 27, 2014
  6. Offline

    Rocoty

    What do you expect the variable worldName to be? What is line 2 supposed to do?
     
  7. Offline

    PlayFriik

    worldName should be the name of the world. For example:

    Code:
    Maps:
      there-is-the-worldName:
        spawn:
          X: number
          Y: number
          Z: number
    And when the player falls into void, then it gets these X,Y,Z cords from Maps.there-is-the-worldName.spawn.X/Y/Z in the config file.
     
  8. Offline

    Rocoty

    Okay...why don't you just get the name of the world the player is currently in? Think about it. What value were you hoping to get with line 2?
     
  9. Offline

    PlayFriik

    @Rocoty
    You mean after Maps as a 2 line in the config? Also, I didn't wanted to get player's world because if player is somehow in another world then he gets teleported to random place and it's more configurable.
     
  10. Offline

    Rocoty

    @PlayFriik I am talking about line 2 in the code snippet you sent.
     
  11. Offline

    PlayFriik

    Maps? After a blank line? I don't understand, sorry.. If yes, then I am trying to make minigame plugin where is lobby and a map.
     
  12. Offline

    Rocoty

    @PlayFriik Sorry you're missing my point. I'm trying to help you think about your code logic. You see, what you are doing on line 2 in the snippet doesn't make much sense. So I ask you again, what value were you hoping to get at that line?

    Talking about the snippet from this post:
     
  13. Offline

    PlayFriik

    Oh, I am trying to get an value, what is put in the config after Maps in the next line.
    So after that when the worldName is done then the plugin should put the worldName to Maps."worldName".spawn.X,Y,Z..

    But the problem is that the plugin gets only from worldName
    Code:
    MemorySection[path='Maps', root='YamlConfiguration']
    What is creating NPE error.
     
Thread Status:
Not open for further replies.

Share This Page