Discussion in 'Plugin Development' started by x86cam, Jun 16, 2012.
I can't seem to figure it out.
How would I?
You can place the player and the current time when they moved in a hashmap. Then in a command, you would call up the current time when the command is sent and compare it to the stored value for the player. Otherwise, you would schedule a repeating task on enable that loops through the hashmap each second and checks if the difference between the current time and the stored values have a difference of 5 minutes.
Try using a delayed task
20L is equal to one second so you can do
20L * 60
That would give you a minute and then to get 5 minutes
20L * 60 * 5
The only issue is that delayed tasks are reset if you reload the server.
when is an player afk, when he hasn't moved for the past 5 minuts, then he will standinside an animal farm, so your plugin wont detect it, when looking if an player is afk, you should need to check inventory event, and yaw/pitch chances, I think that thats the best way to detect afk people
I think you can learn everything you want to do from my plugin BP-AFK: https://github.com/obnoxint/BP-AFK
You could track movement by checking every minute through a series of these events:
Get location of the entity
Wait 1 minute (60 * 20 is the ticks, however, because most servers have lots of latency differences, 1200 ticks may not be sufficient).
Get new location
Compare. If new, go to 1. If not new, go to 2.
Clear player from HashMap
Keep player in HashMap, add a minute. Go to 1.
Checks if value is equal to 5, does an action
Think of this as a flow chart.
Separate names with a comma.