Config help

Discussion in 'Plugin Development' started by xXLightbulbXx, Jul 15, 2015.

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

    xXLightbulbXx

    Hey, Can someone please tell me why when i type "/setamount 10" it won't add it to the config?
    Code:
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
             Player player = (Player) sender;
             if(sender instanceof Player){
               
                 if(label.equalsIgnoreCase("moneydrops")){
                     if(args.length == 0){
                         player.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "-==--==--==--==--==--==--==-\n" + ChatColor.AQUA + "" + "Version: " + ChatColor.GOLD + "1.0\n" + "" + ChatColor.AQUA + "Author: " + ChatColor.GOLD + "xXLightbulbXx\n" + ChatColor.GREEN + "" + ChatColor.BOLD + "-==--==--==--==--==--==--==-");
                     }else{
                         player.sendMessage(ChatColor.GREEN + "You successfully reloaded " + ChatColor.GOLD + "MoneyDrops");
                         saveConfig();
                         reloadConfig();
                     }
                 }
               
                 if(label.equalsIgnoreCase("setamount")){
                     if(args.length == 0){
                         player.sendMessage(ChatColor.RED + "Please specify an amount");
                     }else{
                         if(args.length == 1){
                             player.sendMessage(ChatColor.GREEN + "You successfully set the amount to " + ChatColor.GOLD + args[0]);
                             getConfig().set("Amount.", args[0]);
                         }
                     }
                 }
             }
            return true;
        }
     
  2. Offline

    DoggyCode™

    @xXLightbulbXx because you don't save the config after

    getConfig().set("Amount.", args[0]);

    also, I'd suggest you do something like this since it's a int:

    Code:
    int i = Integer.parseInt(args[0]);
    getConfig().set("Amount.", i);
    saveConfig();
    
     
    Last edited: Jul 16, 2015
    Lionhard likes this.
  3. Offline

    Adamki11s

    You need to save your config, after you set the amount.
     
  4. Offline

    xXLightbulbXx

    Lol im so stupid, Thanks!
     
Thread Status:
Not open for further replies.

Share This Page