Using the BukkitScheduler...or?

Discussion in 'Plugin Development' started by yottabyte, May 17, 2011.

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

    yottabyte

    Hello great minds of the development forums! I've come to you today to ask about a plugin we have on our server.

    The plugin is very much like the old MyHome plugin, set your home, wait for a cooldown and then you can go there, repeat.

    Now there is just one problem, the cooldown can vary a lot. We're using the BukkitScheduler for this. I can't remember exactly how many ticks it's set to but it's basically five minutes in 20 fps.
    The problem is that the actual cooldown varies a lot depending on how much load the server has. During peak hours the server can go down to about 11-15. This of course also delays the cooldown. Sometimes player have to wait hours instead of 5 minutes. That just leaves me speechless.

    I've heard that you shouldn't use separate timers and all that and everyone should use the Bukkit Scheduler for stuff like this... eh?
     
  2. Offline

    nisovin

    You shouldn't need to use the scheduler to manage cooldowns at all, if I understand you correctly. Just use a HashMap<String,Long> and store the players and their last /home time. You can use System.currentTimeMillis() to get the current time, then next time they attempt it, check the current time against their last time, and if it hasn't been long enough refuse the command.
     
    yottabyte likes this.
  3. Offline

    yottabyte

    Geezus, how did I not think about that in first place. Stupid me. Thanks :p
     
Thread Status:
Not open for further replies.

Share This Page