Change to the newer, shorter scheduler methods.

This commit is contained in:
GJ 2013-03-20 02:15:15 -04:00
parent db2bf9ee51
commit c3a69c8c55
12 changed files with 19 additions and 19 deletions

View File

@ -336,7 +336,7 @@ public final class DatabaseManager {
if (connection != null && !connection.isClosed()) { if (connection != null && !connection.isClosed()) {
// Schedule a database save if we really had an outage // Schedule a database save if we really had an outage
if (reconnectAttempt > 1) { if (reconnectAttempt > 1) {
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnectTask(), 5); mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new SQLReconnectTask(), 5);
} }
nextReconnectTimestamp = 0; nextReconnectTimestamp = 0;
reconnectAttempt = 0; reconnectAttempt = 0;

View File

@ -88,7 +88,7 @@ public class BlockListener implements Listener {
public void onBlockPistonRetract(BlockPistonRetractEvent event) { public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) { if (event.isSticky()) {
// Needed only because under some circumstances Minecraft doesn't move the block // Needed only because under some circumstances Minecraft doesn't move the block
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTrackerTask(event), 2); plugin.getServer().getScheduler().runTaskLater(plugin, new StickyPistonTrackerTask(event), 2);
} }
} }

View File

@ -405,39 +405,39 @@ public class mcMMO extends JavaPlugin {
BukkitScheduler scheduler = getServer().getScheduler(); BukkitScheduler scheduler = getServer().getScheduler();
// Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException // Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException
scheduler.scheduleSyncDelayedTask(this, new PartyLoaderTask(), 0); scheduler.runTaskLater(this, new PartyLoaderTask(), 0);
// Periodic save timer (Saves every 10 minutes by default) // Periodic save timer (Saves every 10 minutes by default)
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200; long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
scheduler.scheduleSyncRepeatingTask(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks); scheduler.runTaskTimer(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks);
// Regen & Cooldown timer (Runs every second) // Regen & Cooldown timer (Runs every second)
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitorTask(), 20, 20); scheduler.runTaskTimer(this, new SkillMonitorTask(), 20, 20);
// Bleed timer (Runs every two seconds) // Bleed timer (Runs every two seconds)
scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40); scheduler.runTaskTimer(this, new BleedTimerTask(), 40, 40);
// Old & Powerless User remover // Old & Powerless User remover
int purgeInterval = Config.getInstance().getPurgeInterval(); int purgeInterval = Config.getInstance().getPurgeInterval();
if (purgeInterval == 0) { if (purgeInterval == 0) {
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup. scheduler.runTaskLater(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
} }
else if (purgeInterval > 0) { else if (purgeInterval > 0) {
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20; long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks); scheduler.runTaskTimer(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
} }
// Automatically remove old members from parties // Automatically remove old members from parties
long kickInterval = Config.getInstance().getAutoPartyKickInterval(); long kickInterval = Config.getInstance().getAutoPartyKickInterval();
if (kickInterval == 0) { if (kickInterval == 0) {
scheduler.scheduleSyncDelayedTask(this, new PartyAutoKickTask(), 40); // Start 2 seconds after startup. scheduler.runTaskLater(this, new PartyAutoKickTask(), 40); // Start 2 seconds after startup.
} }
else if (kickInterval > 0) { else if (kickInterval > 0) {
long kickIntervalTicks = kickInterval * 60 * 60 * 20; long kickIntervalTicks = kickInterval * 60 * 60 * 20;
scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); scheduler.runTaskTimer(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks);
} }
} }
} }

View File

@ -16,7 +16,7 @@ public class SaveTimerTask implements Runnable {
BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler(); BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler();
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) { for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) {
bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); bukkitScheduler.runTaskLater(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count);
count++; count++;
} }

View File

@ -25,7 +25,7 @@ public class McrankCommandAsyncTask implements Runnable {
public void run() { public void run() {
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName); final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override @Override
public void run() { public void run() {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));

View File

@ -28,7 +28,7 @@ public class MctopCommandAsyncTask implements Runnable {
public void run() { public void run() {
String tablePrefix = Config.getInstance().getMySQLTablePrefix(); String tablePrefix = Config.getInstance().getMySQLTablePrefix();
final HashMap<Integer, ArrayList<String>> userslist = DatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10"); final HashMap<Integer, ArrayList<String>> userslist = DatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10");
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override @Override
public void run() { public void run() {
if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {

View File

@ -18,7 +18,7 @@ public class TrackedEntity implements Runnable {
this.livingEntity = livingEntity; this.livingEntity = livingEntity;
this.id = livingEntity.getUniqueId(); this.id = livingEntity.getUniqueId();
this.scheduler = mcMMO.p.getServer().getScheduler(); this.scheduler = mcMMO.p.getServer().getScheduler();
this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000); this.taskId = scheduler.runTaskTimer(mcMMO.p, this, 12000, 12000).getTaskId();
} }
@Override @Override

View File

@ -97,7 +97,7 @@ public final class HolidayManager {
final int firework_amount = 10; final int firework_amount = 10;
for (int i = 0; i < firework_amount; i++) { for (int i = 0; i < firework_amount; i++) {
int delay = (int) (Math.random() * 3) + 4; int delay = (int) (Math.random() * 3) + 4;
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override @Override
public void run() { public void run() {
spawnFireworks((Player) sender); spawnFireworks((Player) sender);

View File

@ -28,7 +28,7 @@ public class BlockStoreConversionMain implements Runnable {
return; return;
} }
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId();
return; return;
} }

View File

@ -29,7 +29,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
return; return;
} }
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId();
return; return;
} }

View File

@ -42,7 +42,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
return; return;
} }
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId();
return; return;
} }

View File

@ -486,7 +486,7 @@ public final class CombatUtils {
} }
if (baseXP != 0) { if (baseXP != 0) {
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0); mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0);
} }
} }