Solved Adding Entry to YAML File

Discussion in 'Plugin Development' started by SmearySubset, Jul 5, 2021.

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

    SmearySubset

    I am developing a plugin that, when given a set of coordinates, looks at each block inbetween the coordinates, checks if it is a block of red wool or blue wool, and if so, puts the x value of that block in a config file under the "blocks.redwool" or "blocks.bluewool" path. I can't seem to figure out how to add a "-" value (whatever they are called) to the YAML file for each registered block so that it looks something like this:
    Code:
    blocks:
      redwool:
        -5
        -8
      bluewool:
        -2
        -9
    
    Right now, it looks like this:
    Code:
    blocks:
      redwool:
      bluewool:
    Sorry for formatting. I am aware that two spaces are required for each level!

    Thanks!
    SmearySubset
     
    Last edited by a moderator: Jul 5, 2021
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    SmearySubset

    @timtower How would I add each entry to the file though?
     
  4. Offline

    timtower Administrator Administrator Moderator

    You make a list.
    You add items to the list.
    You set the list to a path.
    You save the config.
     
  5. Offline

    SmearySubset

    @timtower my plugin is going to be iterating through thousands of blocks so that would mean the list would have hundreds of different locations, which would use up a ton of memory. Is there a way to upload each location individually to the config file as soon as its registered instead of putting it in a list first?
     
  6. Offline

    timtower Administrator Administrator Moderator

    You can set it using a location x,y,z as key
     
  7. Offline

    SmearySubset

    Okay, thanks. I think I got it.
     
Thread Status:
Not open for further replies.

Share This Page