Help with this config..

Discussion in 'Spigot Plugin Development' started by KDTemperor, May 9, 2017.

  1. Anyone correct me if I'm, doing wrong?
    Code (Text):
                if(args[0].equalsIgnoreCase("create"))
                {
                    if(args[1].length() <= 4)
                    {
                        pl.sendMessage(ChatColor.RED + "The Guild name must be atleast" + ChatColor.GOLD + " 4 "+ ChatColor.RED + "characters");
                    }
                    if(args[1].contains(db.getString(args[1])))
                    {
                        pl.sendMessage(ChatColor.RED + "The Guild name has already been taken.");
                    }
                    else
                    {
                        db.set("Guilds.", args[1]);
                        db.set("Guilds." + args[1] + ".Info.Leader", pl.getName());
                    }
    }
                    }
    I'm kind of confused...
    it should be:
    Guilds:
    <Guild Name>:
    Info:
    Leader: <Name>
     
  2. Try create a section for each guild?

    Code (Text):
    if (!(plugin.getGuilds().equals("Guild name/arg[]"))) {
            plugin.getGuilds().createSection("Guild name/arg[]");
        }

        if (plugin.getGuilds().equals("guild name/arg[]")) {
            ConfigurationSection cs = plugin.getGuilds()
                    .getConfigurationSection("guild name/arg[]");
            cs.set("Guild name", "Name/arg[]");
            cs.set("Guild leader", "leader name");
            if (cs.get("Times banned") == null) {
                cs.set("Times banned", 1);
            plugin.saveGuilds();
        }
     
  3. my problem right now is,
    should I still use args[1]?
    since the guild name is not yet defined...
    I'm adding more config sections and sub-commands
     
  4. If args[1] is the guild name in the command then create the section called args[1 :)