Need help with plugin

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

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

    CarlOnMyDuty

    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.
     
  2. Offline

    raGan.

  3. Offline

    GodzOfMadness

    raGan. I knew i saw this thread from somewhere i just couldn't put my finger on it...
     
  4. Offline

    c0mp

Thread Status:
Not open for further replies.

Share This Page