Solved Use args[1] in config

Discussion in 'Plugin Development' started by Hugo_Meteo, Jul 10, 2016.

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

    Hugo_Meteo

    Hi,
    I'm trying to put the args[1] of a command in a config file, which define when the PvP start. Everything is fine with the config file (as when I do /uhc it displays me the default config), but when I try to /uhc pvp 15 for example, it don't put the new value in the config file. Here is my code for the command:

    Code:
    if(args.length == 2){
             if(args[0].equalsIgnoreCase("pvp")){
               String pvpy = args[1];
               config.set("pvp", args[1]);
               pl.saveConfig();
               p.sendMessage(ChatColor.GRAY+"Vous avez défini le PvP à: "+ChatColor.GREEN+""+pvpy);
             }
             
    
    I tried to replace the "args[1] in config.set by the pvpy string, not working
     
  2. Offline

    SuperSniper

    You need to reload the config also.
    pl.reloadConfig();
     
  3. Offline

    Hugo_Meteo

    oh thanks :)

    woops, still not working :'( Not error btw

    EDIT: Ok, it justs add '15' in the config, i got the problem

    Here is the config.yml:
    Code:
    pvp: '35'
    border: 15
    deathmatch: 20
    
    How can I fix that ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 10, 2016
  4. @Hugo_Meteo
    Your code should be working fine, as long as the "config" variable is (Your main class).getConfig()
     
  5. Offline

    Hugo_Meteo

    Well, I fixed it, I was just using a int to display the pvp value, just changed it in String and it's working now !

    Thanks for the help :)
     
  6. @Hugo_Meteo Please mark this as Solved.

    Thread Tools > Edit Thread > Prefix > Solved
     
Thread Status:
Not open for further replies.

Share This Page