how do I implement config.yml files?

Discussion in 'Spigot Plugin Development' started by lilmikey0174, Jul 3, 2018.

  1. When You make a plugin how do you make a config.yml file able to read the data you imput...
    (logic 1 million)
    Example:
    in config.yml:
    Code (Text):

    #GenericPluginName
    #Idk wot to do here
    Discord: http://discord.gg/xxxxxxx
     
    in plugin.java:
    Code (Text):
    -Filler-
    player.sendMessage(ChatColor.DARK_GRAY + Discord)
    -Filler-
    Does this make sense at all?
    Essentially I am asking how can I define a variable from config.yml (I think)
     
  2. You have two options. Either use regex to find and replace a section
    Code (Java):
    message = message.replaceAll("<Discord Link>", config.getString("Discord"));
    player.sendMessage(message);
    Or, if you plan to allow them to write actual java and have the server then run it when you call it, you'll want to use an evaluator of some kind.
    Here's a link to one of them called BeanShell.