Solved Changing commands from config

Discussion in 'Spigot Plugin Development' started by --TOMAS--, May 15, 2016.

Thread Status:
Not open for further replies.
  1. Hi, I need to know how to do this. I have a plugin, which by a String in the config you can choose between commands in English or Spanish, but I want this string only can put "en" (english) or "es" (spanish), how do ? And how do I get if the player puts some other word default is changed to "en"? And how do I detect in the code if the player put "en" or "es"? I hope I explained.

    CONFIG:
    Code (Text):
    #You can choose "en" for commands in english or "es" for commands in spanish
    Commands: 'en'
    CODE:
    Code (Text):
    public void onEnable(){
            PluginDescriptionFile pdfFile = getDescription();
            Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_AQUA + "Plugin enabled!");
            if(getConfig().getString(("Commands")//Here's what I do not know){
            registerCommandsInEnglish();
            }else{
            registerCommandsInSpanish();
            }
        }
     
  2. This doesn't make too much sense, especially without more information. What plugin? What commands? I would assume the config value decides whether to listen for one set of commands or another, based on the value, rather than a command of "/en" or "/es" .. can you expand on your issue, please?
     
  3. Code (Text):
    FileConfiguration config = plugin.getConfig();
    ConfigurationSection root = config.getRoot();

    String language = root.getString("Commands", "en");//English by default if not specified

    //if something other than 'en' or 'sp' is set, default to 'en'
    if(!language.equals("en") && !language.equals("sp")){
      language = "en";
    }

    if(language.equals("en")){
      registerCommandsInEnglish();
    }
    else if(language.equals("sp")){
      registerCommandsInSpanish();
    }
     
  4. Wow, nice!! THANKS!!
     
  5. Well, clearly I misunderstood. Sorry for not being on the ball :confused:
     
Thread Status:
Not open for further replies.