1.8.8 Creating YML files with custom strings

Discussion in 'Spigot Plugin Development' started by Spoonle, Mar 24, 2020.

  1. Heyo, I'd like to start off by saying I'm fairly new. I've been coding on and off for about a year now. I've tasked myself with making a more complicated plugin than what I'm used to.

    What I'm wanting to do is create a yml file when the plugin is loaded for the first time. Then, within the plugin on the server, someone could do something like "/<command> <custom string for the individual player>"

    For example:
    /welcomeback Welcome to the server {player}!
    Then they run the command /welba which will send they customized message.

    I've coded the base of the plugin (such as the PlayerJoinEvent in which it sets the new joined player as a string variable, the command for sending the message, etc) However, I don't know where to go from there.

    I guess what I'm asking is, how do I create that custom YML, then allow commands to add custom strings to it?
  2. You should make a FileManager class, this could handle all the configs you need created, when a player logs on, do a try and catch statement to create a yml in the cores data folder, you should store it by player uuid and when the player runs the command get their config from using their uuid. Then it will work just like any other config. By the way make sure you make all of these methods in your FileManager not PlayerJoinEvent so you can access them from all classes.(Don't use static just use an instance of the class). Also in onEnable you will need a method to load all the player configs.
    • Like Like x 1