Best method for accessing offline player data

Discussion in 'Spigot Plugin Development' started by Bolt, May 27, 2015.

  1. There are commands like Essentials /seen where it can access offline player data. I was wondering, how would I do this? I am currently storing data in a MySQL database using UUIDs. as the Primary Key. I was wondering if I should create a separate column for player names? Essentially, what's the best way to access player data of players that are offline? Convert to UUIDs? Others methods?
     
  2. Essentials seen as far as I'm aware stores all its data in a yaml file so that's how it knows when you logged where you logged and you in so just save the data?
     
  3. Hi Jack! xD Yeah, they store data in yaml files but what would be a good way to do this with MySQL? Should I create a separate Unique column for player names?
     
  4. Do you need help storing the player data without Essentials, or do you need help storing it within MySQL.

    I know how to store it in a file, not in MySQL, sorry
     
  5. I know how to store the offline player data. What I mean to say is what's the best way to access the saved data if they're offline? For example, you do /seen <player>, it works even if the the player is offline. I know essentials has their own way of doing this because you can't do Bukkit.getPlayer() for an offline player. What I'm asking is what's the best way to make a reference to the stored data of the offline player.
     
  6. Bukkit.getOfflinePlayer()?
     
  7. On a player disconnect, get there data and save it to a file...

    Code (Text):
    @EventHandler
    public void onLeave(PlayerQuitEvent e){
    Player pl = e.getPlayer();
    System.getTime(); //Something like that
    Then just save it to a file

    Search Bukkit YAML for file help...
     
  8. What I mean was something like Essentials /seen <name> or /ban <name>. They have their own look-up method to search their saved files based on a given username so that the command can still work even for offline players. I know there is Bukkit.getOfflinePlayer() but I want to base if off of my plugin's own logs of player names rather than the native server's player cache. I am using MySQL btw but any other suggestions even if using config files would still be gladly accepted.
     
  9. Code (Text):
    Player pl = (Player) Bukkit.getOfflinePlayer();
     

Share This Page