Configuration file issue

Discussion in 'Plugin Development' started by Praxounet, Jan 5, 2019.

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

    Praxounet

    So I'm making a party plugin, and at some point I have to save the name of the player who creates the party. So basically I save his name when he types /party invite <nickname> because it creates a party at the same time.
    The thing is, my config.yml is not saving his name.


    Code:
    if (args.length == 2) {
                  
                    p = Bukkit.getPlayer(args[1]);
                  
                    if (args[0].equalsIgnoreCase("invite")) {
                      
                      
                      
                        if (p != null) {
                                player.sendMessage("§6[Party]" + " " + ChatColor.WHITE + p.getName() + " a bien été invité !");
                                p.sendMessage("§6[Party]" + " " + ChatColor.WHITE + player.getName() + " vous a invité !");
                                p.sendMessage("§6[Party]" + " " + ChatColor.WHITE + "Faites /party join afin de rejoindre le groupe !");
                              
                                plugin.getConfig().set("party.leader", player.getName());
                              
                            return true;
                            }else {
                              player.sendMessage("§cLe joueur ciblé n'est pas connecté.");  
                                  }
                        }
                  }


    To save his name, I use the method plugin.getConfig().set("party.leader", player.getName());

    (player is defined as Player player = (Player)sender;)

    Is this method wrong or something ? This is how my config.yml appears after the /party invite <nickname> command :

    what..PNG
     
  2. Offline

    KarimAKL

    @Praxounet After plugn.getConfig().set() you need to use plugin.saveConfig()
     
  3. Offline

    Praxounet

    Thanks ! It's working :)
     
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page