Hi there, I did a timer but I don't know why the arguments into it are executed a lot of time. I want to do that just one time. This timer was given to me in the past by @KarimAKL . Do you have any issue ? <Edit by Moderator: Redacted code to keep passwords safe, never post those, long live configs> BukkitRunnable into the PlayerMoveEvent What I want to do is : The player is detected on the block, wait any time, and execute.
@Aragone It's probably because it's inside the PlayerMoveEvent and gets called a lot of times. Btw, you can do '0.2f' or 'o.2F' instead of '(float) 0.2'. EDIT: Just in case you are wondering why it would call a lot of times even though it's inside an if statement. I would guess that's because getX() gets rounded. e.g. -104.4 = -104, -103.9 = 104, etc.
You should use Math.round() instead of casting to an int. I can't say for sure but @KarimAKL is probably right. The task gets scheduled multiple times because the move event gets fired multiple times. You could keep a list of players for which the task is scheduled. Inside the task, as the last statement, remove the player from that list. Do not schedule a task for a player when he exists in the list. Simple.