Finding time since last death

Discussion in 'Plugin Development' started by Jakesully123456, May 16, 2015.

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

    Jakesully123456

    How might I find the time since a player last died?
     
  2. Store system.currentMilis as a long or whatever and then compare the current millis to another current milis to get the difference then divide my 60000 to get minutes.
     
  3. A little bit more explained:
    Create a hashmap out of a uuid and a Long(not long), and on each PlayerDeathEvent store the player's uuid with System.currentTimeMillis(). To check the time since the player's last death you first check if the map contains the player's uuid (to prevent issues) and if it contains it you call System.currentTimeMillis() - the long of the map.
     
  4. Offline

    Jakesully123456

    This is the only way?
    I knew this way, I was trying to see if there was a function for it, seeing as you can get time since last damage.
    Thanks anyway.
     
  5. Offline

    Ungemonstert

    The time since last death is already saved by bukkit. In the statistics.
    In my example, in PlayerJoinEvent:
    Code:
    @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            p.sendMessage("Time since last death: "+p.getStatistic(Statistic.TIME_SINCE_DEATH));
        }
    
     
Thread Status:
Not open for further replies.

Share This Page