Schedule warmup task in main thread instead of separate thread

This commit is contained in:
Zak Ford 2012-02-05 18:25:19 -05:00
parent cac70e0a01
commit 576d9d67b0
3 changed files with 34 additions and 27 deletions

View File

@ -1,6 +1,6 @@
package cz.boosik.boosCooldown;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashMap;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -17,8 +17,8 @@ import util.boosChat;
@SuppressWarnings("deprecation")
public class boosCoolDownPlayerListener extends PlayerListener {
private final boosCoolDown plugin;
private static ConcurrentHashMap<String, Location> playerloc = new ConcurrentHashMap<String, Location>();
private static ConcurrentHashMap<String, String> playerworld = new ConcurrentHashMap<String, String>();
private static HashMap<String, Location> playerloc = new HashMap<String, Location>();
private static HashMap<String, String> playerworld = new HashMap<String, String>();
public boosCoolDownPlayerListener(boosCoolDown instance) {
plugin = instance;

View File

@ -1,7 +1,7 @@
package cz.boosik.boosCooldown;
import java.util.HashMap;
import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
@ -9,7 +9,7 @@ import util.boosChat;
public class boosWarmUpManager {
private static ConcurrentHashMap<String, boosWarmUpTimer> playercommands = new ConcurrentHashMap<String, boosWarmUpTimer>();
private static HashMap<String, boosWarmUpTimer> playercommands = new HashMap<String, boosWarmUpTimer>();
static Timer scheduler;

View File

@ -6,10 +6,10 @@ import org.bukkit.entity.Player;
public class boosWarmUpTimer extends TimerTask {
boosCoolDown bCoolDown;
Player player;
String pre;
String message;
private boosCoolDown bCoolDown;
private Player player;
private String pre;
private String message;
public boosWarmUpTimer(boosCoolDown bCoolDown, Timer timer, Player player,
String pre, String message) {
@ -22,24 +22,31 @@ public class boosWarmUpTimer extends TimerTask {
public boosWarmUpTimer() {
}
@Override
public void run() {
bCoolDown.getServer().getScheduler().scheduleSyncDelayedTask(bCoolDown, new boosWarmUpRunnable());
}
public class boosWarmUpRunnable implements Runnable {
@Override
public void run() {
if (player.isOnline() && !player.isDead() && boosWarmUpManager.hasWarmUps(player)) {
boosCoolDownManager.setWarmUpOK(player, pre, message);
boosWarmUpManager.removeWarmUpProcess(this.player.getName() + "@"
boosWarmUpManager.removeWarmUpProcess(player.getName() + "@"
+ pre);
boosCoolDownPlayerListener.clearLocWorld(player);
player.chat(pre + message);
} else if (player.isOnline() && player.isDead() && boosWarmUpManager.hasWarmUps(player)){
boosCoolDownManager.removeWarmUp(player, pre, message);
boosWarmUpManager.removeWarmUpProcess(this.player.getName() + "@"
boosWarmUpManager.removeWarmUpProcess(player.getName() + "@"
+ pre);
boosCoolDownPlayerListener.clearLocWorld(player);
} else if (!player.isOnline() && boosWarmUpManager.hasWarmUps(player)){
boosCoolDownManager.removeWarmUp(player, pre, message);
boosWarmUpManager.removeWarmUpProcess(this.player.getName() + "@"
boosWarmUpManager.removeWarmUpProcess(player.getName() + "@"
+ pre);
boosCoolDownPlayerListener.clearLocWorld(player);
}
}
}
}