1.14.4 /Run <project> Command. Run a list of commands from a list.

Discussion in 'Spigot Plugin Development' started by RyanP_J, Mar 3, 2020.

  1. Hi,

    Im new to posting stuff on help forums so ask me any questions. Im getting into plugin development and I understand the basic concept of the config.yml the plugin Im making is a plugin where you'll run the command /run <project> and the command will search for a .yml file (same name as <projects) in the 'projects' folder and run the set commands from the list.

    So for example if I run the command /run sparkles
    - It would first search for the file sparkles.yml.
    - If it successful it would go in order and run the list of commands list this:

    Commands:
    -particle blah blah blah
    -setblock ~ ~ ~ blah lah

    etc.

    Thanks.
     
  2. So, what exactly is your question..?
    Are you asking use for the code?
     
  3. Yeah, what would I need to use to make this happen?
     
  4. On reload iterate all the files in your folder -
    for(File file : folder.listFiles)
    Check if file is .yml, and, if so, create YamlConfiguration out of it -
    YamlConfiguration.loadConfiguration(file)
    Save all the commands for "projects" in some object or Map<String, List<String>> -
    map.put(file.getname().replace(".yml", "").toLowerCase(), cfg.getStringList("Commands"))
    When player is performing your command just get list of your command for specific "project"(remeber to check for args amount, null of list and is sender is a player) -
    commands.foreach(isPlayer ? player::performCommand : Bukkit::dispatchCommand)
     
    #4 imDaniX, Mar 3, 2020
    Last edited: Mar 3, 2020
    • Like Like x 1