Create a file for each new player

Discussion in 'Plugin Development' started by JustDoom, Jul 23, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    JustDoom

    How would I create a new file that stores, for example, player kills and deaths, then puts that new file inside a folder called playerData?
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    JustDoom

  4. Offline

    timtower Administrator Administrator Moderator

    Why do you want to make a new file for each player?
    And you don't need to make a file when they join, just when you need to save things.
     
  5. Offline

    JustDoom

    if its all in one file if it gets corrupted you lose everything
     
  6. Offline

    timtower Administrator Administrator Moderator

    Chance of things getting corrupt is very low though, just don't touch it by hand.
    Database is also an option
     
  7. Offline

    JustDoom

    How would I create a new file that stores, for example, player kills and deaths, then puts that new file inside a folder called playerData?
    Not trying to be rude but can I just have help with my question?
     
  8. Offline

    timtower Administrator Administrator Moderator

    What part are you having issues with?
    The new file? When they join?
    What do you have already?
     
  9. Offline

    JustDoom

    I have the custom config code https://www.spigotmc.org/wiki/config-files/#using-custom-configurations
    I dont know how to set the name of the file to the uuid of the player and how to put it into a folder
    EDIT: Also how would I create a new file for the player when they join? Im still new to plugin dev and java in general
     
  10. Offline

    timtower Administrator Administrator Moderator

    @JustDoom Listen to the PlayerJoinEvent, get their UUID, turn it into a String.
     
  11. Offline

    JustDoom

    how do i put it into a folder
     
  12. Offline

    timtower Administrator Administrator Moderator

    What do you have so far? We aren't at the files yet.
     
  13. Offline

    JustDoom

    ok sorry, yeah i make their uuid into a string in a on join event
     
  14. Offline

    timtower Administrator Administrator Moderator

    Code? Just saying things does not convince me.
     
  15. Offline

    JustDoom

    ?
     
  16. Offline

    timtower Administrator Administrator Moderator

    Please post the code that you have so far.
     
  17. Offline

    JustDoom

    @EventHandlerpublic void join(PlayerJoinEvent event){
    Player player = event.getPlayer();
    String uuid = player.getUniqueId().toString();
    }
     
  18. Offline

    timtower Administrator Administrator Moderator

  19. Offline

    JustDoom

  20. Offline

    timtower Administrator Administrator Moderator

    @JustDoom Don't just say done, post the code as well please.
    Now you have a File reference for each player that joins.

    Check if it exists, if so: load it.
    If not: write a blank config.
     
Thread Status:
Not open for further replies.

Share This Page