1.15.2 How to store player online time

Discussion in 'Spigot Plugin Development' started by hsun00, Mar 2, 2020.

  1. Hi,
    I want to check the total amount of hours/minutes players have played on the server, and later check if they have been on for example more than 50 hours. What would be the best and easiest way to do this? I've looked into different ways such as hooking onto other plugins (Statz, PlaceholderAPI), creating hasmaps and storing the values in a yml file, and tried some other approaches I found, but nothing works. I am not experienced and trying to learn. If someone could show me an example on how to do this that would be great :)
  2. Easiest way would to just get the players statistic value


    It says that this is in ticks and not minutes (20 ticks in 1 second)

    So you would get this by getting a player object, then doing:

    Code (Java):
    int secondsPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE) / 20;
    #2 Steve362, Mar 2, 2020
    Last edited: Mar 2, 2020
    • Agree Agree x 1