Rename a config path

Discussion in 'Plugin Development' started by Synapz, May 6, 2015.

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

    Synapz

    I save all my Arenas in a arena.yml file, so when I create a new arena I add a new path (Arenas.<arena-name>), this way when the server reloads/stops I can fetch that Arena's information from the arena.yml and load it into the server again.

    My Problem
    I am adding a new command to rename arenas (/pb admin rename <arena> <new-name>. The problem is, I cannot change the path of the arena name to the new-name.

    I created a solution that would take all the values in Arenas.<arena-name> (like spawns, settings etc), set them to a variable, remove the Arenas.<arena-name> re-add the arena with the new-name then re-set all the values. Isn't really a stable solution, so I was wondering if there was a method/other way I can go on renaming a path?
     
  2. Offline

    mine-care

    Well it is not stable nor efficient, there are 2 alternatives I can think of, 1. Don't define the arena name by the configuration section, instead have a section for name so for example arenas.someoldname.Name
    2. Upon this command add a second config section like Arenas.newname.... And delete the old one

    Another option would be to use databases but I am not really sure how this would allow customization by file-work
     
    Synapz likes this.
Thread Status:
Not open for further replies.

Share This Page