Replace Timers with Bukkit schedulers

This commit is contained in:
cnaude 2013-04-04 20:48:56 -07:00
parent d97c1adaf0
commit e135df1c62
3 changed files with 16 additions and 22 deletions

View File

@ -1,8 +1,6 @@
package net.spoothie.chairs;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -55,21 +53,18 @@ public class EventListener implements Listener {
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
delayedSitTask();
}
class sendSitTask extends TimerTask {
private void delayedSitTask() {
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.sendSit();
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Timer timer = new Timer();
long delay = 1 * 2000;
timer.schedule(new sendSitTask(), delay);
//plugin.sendSit();
}, 20 );
}
@EventHandler
@ -113,6 +108,7 @@ public class EventListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer().getItemInHand().getType().isBlock()
&& (event.getPlayer().getItemInHand().getTypeId() != 0)
&& plugin.ignoreIfBlockInHand) {
return;
}
@ -287,9 +283,7 @@ public class EventListener implements Listener {
plugin.sit.put(player.getName(), block.getLocation());
event.setUseInteractedBlock(Result.DENY);
Timer timer = new Timer();
long delay = 1 * 2000;
timer.schedule(new sendSitTask(), delay);
delayedSitTask();
}
}
}

View File

@ -1,5 +1,5 @@
name: Chairs
version: 2.0.1
version: 2.0.2
description: Let players sit on blocks.
authors:
- spoothie