Config & Chunks

Discussion in 'Plugin Development' started by RoboticPlayer, Oct 27, 2015.

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

    RoboticPlayer

    Two parts to this thread. First, how would I check if a YML file has a certain path. For example, if I wanted to check if the config had the path "world". How would I check that? If that path didn't exist, how would I create it?

    Secondly, how should I store chunks in a config.yml file? Not nesecarily the chunks themselves, but the locations that the chunk contains if that is a better practice. This way I can do certain things when a chunk is interacted with if it is in a yml file.

    Basically I need to use both of these because I am creating a method to "claim" a chunk. The claimed chunk will be stored in a yml file with the player's UUID and the chunk that was claimed.
     
  2. Offline

    teej107

    Have you tried looking in the JavaDocs?

    Store the chunk's x and z coordinates.
     
  3. Offline

    RoboticPlayer

    @teej107 For the first one, I found the contains method, now if I wanted to create a new path, would I use createSection or createPath?
     
  4. Offline

    teej107

    @henderry2019 createPath is an actual method? You can also just store the value at a certain path and it will be created for you.
     
  5. Offline

    RoboticPlayer

    @teej107 ok, another thing is how would I loop through all of the paths within a path? For example:
    Code:
    player:
        chunk1:
            x:
            z:
        chunk2:
            x:
            z:
    How would I loop through the number of chunks that are in the path? Or how would I get how many there are? Edit: Without having previous knowledge of how many exist.
     
  6. Offline

    teej107

    @henderry2019 Again,
     
  7. Offline

    RoboticPlayer

    @teej107 Just checked, didn't find anything relevant.
     
  8. Offline

    teej107

    There is a method that can return the keys in a Set.
     
  9. Offline

    RoboticPlayer

    @teej107 I found the getKeys and getValues methods, but which would I use and how would I use them?
     
  10. Offline

    teej107

    Well it says that is returns all the keys (and values if you are using getValues) in a Set/Map. Maps and Sets have a #size() method.
     
  11. Offline

    RoboticPlayer

    @teej107 Two things. One, what if I want to get the keys of a key? So my config will be set up like this:
    How would I get all of the keys within the playerUUID WITHOUT getting the values of the x and z keys.

    Two, how can I only get CERTAIN keys? When I am checking for the number of chunks they have, I don't want to include the other things like maxChunks. Would I just do getKeys#size() - 1?
     
  12. Offline

    teej107

    @henderry2019 Here is a more simple idea. Use a StringList instead to save your x and z coordinates
     
  13. Offline

    RoboticPlayer

    @teej107 So something like this:
    Code:
    playerUUID:
        chunk1:
          - [x-coord]
          - [z-coord]
    Still, how would I get how many chunks there are?
     
  14. Offline

    teej107

    @henderry2019 No. Like this
    Code:
    playerUUID:
    - 'x z'
    - 'x z'
    - 'x z'
     
  15. Offline

    RoboticPlayer

Thread Status:
Not open for further replies.

Share This Page