Timestamp

Discussion in 'Plugin Development' started by Tjeb, Mar 10, 2013.

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

    Tjeb

    Hi there!

    I'm developing a plugin where you are able to save and load the amount of hours played on the server. A friend of mine got some help with the code, and this is what we have done so far.

    Code:
    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
    public void onPlayerQuit(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        String name = player.getName();
        int secondsPlayed = ((int) (System.currentTimeMillis())) /          plugin.getTimestamp().getTimer().get(name);
        plugin.getTimestamp().setPlayerTime(name, secondsPlayed);
         plugin.getTimestamp().getTimer().remove(name);
    }
    getTimestamp() is a return method for my own Timestamp class.
    The HashMap<String, Integer> is in getTimestamp(), and is called getTimer().
    setPlayerTime(string, int) addes the playertime to sql. no problems with that.

    I get null at the Integer secondsPlayed. I cant see any errors here.

    Code:
    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
        public void onPlayerJoin(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            String name = player.getName();
           
            int time = (int) (System.currentTimeMillis() / 1000L);
            plugin.getTimestamp().getTimer().put(name, time);
           
        }
    No nulls at JoinEvent, but errors at QuitEvent.

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page