FileConfig API - changing path name

Discussion in 'Plugin Development' started by alex123099, Jul 23, 2013.

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

    alex123099

    How would I go with changing the path names?
    What I mean is if for example I have:
    Code:
    cookie:
    price: 5
    desc: this is a cookie
    
    and I now want it to be:
    Code:
    cookiessss:
    price: 5
    desc: this is a cookie
    
    How would I do that?
     
  2. Offline

    Alex5657

    Correct me if I'm wrong, but I think you have to delete and re-create the section. What exactly are you trying to achieve? Maybe I can help you do it more efficiently.
     
  3. Offline

    blablubbabc

  4. Offline

    alex123099

    I'm making a vote points plugin, in which I have a shop. I'm using a .yml file to store the shop items along with their price and descritpion. I have a function for the shop, which allows you to rename the item name. The item name is the path in the .yml file, thus, in order for the function to work, I need to be able to change the path name.
     
  5. Offline

    Alex5657

    Ah, k. Just load all the items when the plugin is enabled. I suggest creating a class for it (ex. ShopItem) where you will store all the info. Put them in a list and modify them from the list. At the end (onDisable) clear the config and re-write it using the data from the list.

    That is how I always do it ;)
     
  6. Offline

    alex123099

    This is exactly how my system is built, however, i wish for changes to be instant, and every time saving all nodes would take too much resources
     
  7. Offline

    Alex5657

    It will only do that when the server restart/shuts down. Otherwise, it will be "lagless". It will take a milisecond or two longer to shutdown though.
     
  8. Offline

    alex123099

    That might be true, but in order to avoid out of sync problems, which can be caused by someone modifying the list with in-game command whilst another is doing it manually, it's better to update it. In addition, I have other classes access the same files so they need to be updated all the time. Of course it might not be the most efficient way, but I think it's the most fitting solution for my problem
     
  9. Offline

    soulofw0lf

    actually alex your other classes should also access the lists you make onEnable, having multiple things writing to configs can easily lead to data corruption, it really is best just to make the lists like he suggested.
     
Thread Status:
Not open for further replies.

Share This Page