1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved How can I use an array in a config?

Discussion in 'Plugin Help' started by MinekCz, Jul 23, 2020.

  1. MinekCz

    MinekCz Spider Jockey

    Messages:
    29
    Hi, I need to create a plugin in which there will be different types of players. The player can choose this type. I mean a type like Farmer, etc. And this type must be saved, so even after rebooting, players will have them. My idea was to save the player to one array but I don't know how to do it (save the array to config). It happened to me that the player was saved in the array but did not appear in the config.

    I'll be happy if you help me!
     
  2. JviguyGamesYT

    JviguyGamesYT Baby Zombie

    Messages:
    113
    GitHub:
    jviguy
    Code:
    yaml example:
    farmers:
    - "name"
    - "name"
    
    php example:
    PHP:
    $farmers $this->getConfig()->get("farmers");
    $newfarmers array_push($farmers$player->getName());
    $this->getConfig()->set("farmers"$newfarmers);
    $this->getConfig()->save();
    not really a lot of explaining but the yaml shows how to make an array in yaml and php does it through php obviously
     
  3. MinekCz

    MinekCz Spider Jockey

    Messages:
    29
    Thank you so much for your help!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.