Solved How to remove a stringlist from config?

Discussion in 'Spigot Plugin Development' started by erikgamer07, Jan 24, 2020.

  1. Hello! I'm making a minigame with teams and when a team gets removed, I need to remove it in the config too. I know how to remove it:
    Code (Java):
    config.set(team.getName(), ""); or config.set(team.getName(), null);
    Imagine the config is this:

    Code (YAML):
         - "p1"
         - "p2"
    And with the code up, the config is:

    Code (YAML):
    Blue: ''
    How do I remove that? I need to remove the entire stringlist. Thanks!
    #1 erikgamer07, Jan 24, 2020
    Last edited: Jan 24, 2020
  2. Instead of saving the team in a .yml files, you could create a Team class and a Control class, where the team class would hold all the variables about the team, and the control class would hold every teams that are created. You'd store the teams in the Control class in a hashmap:
    Code (Text):
    HashMap<String, Team> teams = new HashMap<>();
    When you'd want to delete a team, you'd just remove the team from the hashmap:
    Code (Text):
    When you'd want to save the team if the server reloads or restart, just store the hashmap content in a temporary teams.yml file.
    Code (Text):
    public void onEnable() {

    public void onDisable() {
    Here's a good tutorial about it:
  3. That's a good idea for another proyect I have but, I already changed the system multiple times and I don't want to change it. Thanks.
  4. Please, I need an answer.
  5. I just found a solution: config.set(team.getName(), null);
    That worked. Solved :)