From c3a69c8c55dc114c97be9e80922b0c74e8f638d3 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 20 Mar 2013 02:15:15 -0400 Subject: [PATCH] Change to the newer, shorter scheduler methods. --- .../gmail/nossr50/database/DatabaseManager.java | 2 +- .../gmail/nossr50/listeners/BlockListener.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 16 ++++++++-------- .../gmail/nossr50/runnables/SaveTimerTask.java | 2 +- .../commands/McrankCommandAsyncTask.java | 2 +- .../commands/MctopCommandAsyncTask.java | 2 +- .../nossr50/skills/archery/TrackedEntity.java | 2 +- .../com/gmail/nossr50/util/HolidayManager.java | 2 +- .../conversion/BlockStoreConversionMain.java | 2 +- .../BlockStoreConversionXDirectory.java | 2 +- .../BlockStoreConversionZDirectory.java | 2 +- .../gmail/nossr50/util/skills/CombatUtils.java | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index be90bc083..45cba591a 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -336,7 +336,7 @@ public final class DatabaseManager { if (connection != null && !connection.isClosed()) { // Schedule a database save if we really had an outage 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; reconnectAttempt = 0; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 1aacc2dfb..0998b3cb1 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -88,7 +88,7 @@ public class BlockListener implements Listener { public void onBlockPistonRetract(BlockPistonRetractEvent event) { if (event.isSticky()) { // 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); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index b0b45defc..9381d9c73 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -405,39 +405,39 @@ public class mcMMO extends JavaPlugin { BukkitScheduler scheduler = getServer().getScheduler(); // 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) 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) - scheduler.scheduleSyncRepeatingTask(this, new SkillMonitorTask(), 20, 20); + scheduler.runTaskTimer(this, new SkillMonitorTask(), 20, 20); // Bleed timer (Runs every two seconds) - scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40); + scheduler.runTaskTimer(this, new BleedTimerTask(), 40, 40); // Old & Powerless User remover int purgeInterval = Config.getInstance().getPurgeInterval(); 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) { 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 long kickInterval = Config.getInstance().getAutoPartyKickInterval(); 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) { long kickIntervalTicks = kickInterval * 60 * 60 * 20; - scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); + scheduler.runTaskTimer(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 8a1af3760..1b1aaaf79 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java @@ -16,7 +16,7 @@ public class SaveTimerTask implements Runnable { BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler(); for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) { - bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); + bukkitScheduler.runTaskLater(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count); count++; } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 27ad089bb..eb7338320 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -25,7 +25,7 @@ public class McrankCommandAsyncTask implements Runnable { public void run() { final Map skills = DatabaseManager.readSQLRank(playerName); - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { @Override public void run() { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 085974058..1d35f68ab 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -28,7 +28,7 @@ public class MctopCommandAsyncTask implements Runnable { public void run() { String tablePrefix = Config.getInstance().getMySQLTablePrefix(); final HashMap> 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 public void run() { if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index 267f80ba9..c6faab97e 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -18,7 +18,7 @@ public class TrackedEntity implements Runnable { this.livingEntity = livingEntity; this.id = livingEntity.getUniqueId(); 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 diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index c0ddfd63a..61eda995f 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -97,7 +97,7 @@ public final class HolidayManager { final int firework_amount = 10; for (int i = 0; i < firework_amount; i++) { 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 public void run() { spawnFireworks((Player) sender); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java index e1ddd4b2f..599f25477 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java @@ -28,7 +28,7 @@ public class BlockStoreConversionMain implements Runnable { return; } - this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); + this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); return; } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java index 89465df4d..0f705d286 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java @@ -29,7 +29,7 @@ public class BlockStoreConversionXDirectory implements Runnable { return; } - this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); + this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); return; } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java index 5b183b6dc..34a9245f8 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java @@ -42,7 +42,7 @@ public class BlockStoreConversionZDirectory implements Runnable { return; } - this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1); + this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); return; } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 8e44e9774..cba499eb4 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -486,7 +486,7 @@ public final class CombatUtils { } 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); } }