1.14.4 How to Create a custom YML File?

Discussion in 'Spigot Plugin Development' started by Th3Wh1teG0d, Jan 22, 2020.

  1. Hi, how do i create a custom YML file "time.yml" and how do i set for every player the same:

    Code (Java):

    and how do i add per repeatingTask 1 number for example:

    time: 1
    second later
    time: 2
    another second later

    and how do i read the number when a player executes a command where he gives a player name

    example: p.sendMessage("Your Time is " + file.getTime(or so) + " seconds");
  2. A nice tutorial about configuration files here, as for the ther timer you will need to create a scheduler.
  3. If you know how to do it (I am not going to explain it now since the user above gave a link, or you have to specifically ask for it) make sure to use a serialisation method.
    For example store the timings in a Map and on server shutdown, store that map into the YAML file.
    If you do not do this, and store the values directly into the YAML each second/tick, your server will run much slower (especially with more players online) because I/O (putting values into YAML files) are heavy tasks.
  4. IO tasks can be run async
  5. In this tutorial they dont explain how to create


    for every player.
  6. They explained how it works, what methods to use to get started. If you understood their tutorial you can create what you wanted. Try to create something, if you fail, try again, before you give up, upload your code and we will help you :)
  7. FileConfiguragion#set(uuid+".time", value)
  8. Obviously they don’t have a tutorial for exactly your problem xD what are you thinking. Look up how to use YML in Java and then use it.

    Here’s for starters:

    If that’s too complicated here’s what you’re probably looking for:
    #8 the3rdnumber, Jan 22, 2020
    Last edited: Jan 22, 2020
    • Agree Agree x 3
    • Funny Funny x 2
  9. Can i get some Code ?
    • Funny Funny x 1
  10. I'm sure you can figure out how to use that by visiting the links already posted in this thread.
  11. You've asked for code specifically for at least 3 different threads that I've seen. If you need others to write the code for you, you're not really a developer. You're not learning anything.
    Spigot's configuration API is already backed by Maps if I remember correctly; inserting values is as quick as that. Saving it to file is the intensive task that ought to be done async.
    • Agree Agree x 3
    • Like Like x 1
  12. Stop asking and start learning!

    Google is the greatest tool for programmers and these forums are purely for a little help and pointers.

    These people are super talented and are giving great support, so make use of their time, and learn! If you do get stuck, you can post examples of your current code, and people will point out issues and help.

    Dont be worried if you look silly for doing something wrong or not understanding, but outright asking for the code is not the way to go about it.
  13. I think he's trolling lmao, this can't be real.
  14. should start a movement with that spoiler image above where everyone only posts that image

    or copy paste random sections of code found on google and see what happens
    • Agree Agree x 1