From c0b4a33346f3cc335eee594a3c1805286ff6f902 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 10 Mar 2013 15:07:07 -0400 Subject: [PATCH] Importing Bukkit is usually bad. --- .../com/gmail/nossr50/commands/player/McrankCommand.java | 3 +-- .../com/gmail/nossr50/commands/player/MctopCommand.java | 3 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 3 +-- .../runnables/commands/McrankCommandAsyncTask.java | 3 +-- .../runnables/commands/MctopCommandAsyncTask.java | 3 +-- src/main/java/com/gmail/nossr50/util/HolidayManager.java | 3 +-- .../nossr50/util/blockmeta/HashChunkletManager.java | 9 +++++---- .../util/blockmeta/chunkmeta/HashChunkManager.java | 6 +++--- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 5e0e60cad..8200265f3 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.player; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -119,6 +118,6 @@ public class McrankCommand implements CommandExecutor { } private void sqlDisplay(CommandSender sender, String playerName) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender)); + mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index d0fcea9e5..d4ea6e6aa 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.player; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -124,6 +123,6 @@ public class MctopCommand implements CommandExecutor { } private void sqlDisplay(int page, String query, CommandSender sender, Command command) { - Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); + mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command)); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index d4a1e6fad..f0bc48c31 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -8,7 +8,6 @@ import java.util.List; import net.shatteredlands.shatt.backup.ZipLibrary; -import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; @@ -156,7 +155,7 @@ public class mcMMO extends JavaPlugin { getLogger().info("Please do not replace the mcMMO jar while the server is running."); } - Bukkit.getPluginManager().disablePlugin(this); + getServer().getPluginManager().disablePlugin(this); } } 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 85ff65364..44b59f466 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.commands; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; @@ -24,7 +23,7 @@ public class McrankCommandAsyncTask implements Runnable { public void run() { final Map skills = DatabaseManager.readSQLRank(playerName); - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(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 9d04d98c6..4110b84f7 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.commands; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -40,7 +39,7 @@ public class MctopCommandAsyncTask implements Runnable { } 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"); - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { @Override public void run() { if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index 42a72ae81..c0ddfd63a 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -12,7 +12,6 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -98,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; - Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { @Override public void run() { spawnFireworks((Player) sender); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index 8b60c6f19..fa970e58d 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -11,10 +11,11 @@ import java.io.StreamCorruptedException; import java.io.UTFDataFormatException; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; +import com.gmail.nossr50.mcMMO; + public class HashChunkletManager implements ChunkletManager { public HashMap store = new HashMap(); @@ -168,7 +169,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void saveAll() { - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { saveWorld(world); } } @@ -176,7 +177,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void unloadAll() { saveAll(); - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { unloadWorld(world); } } @@ -276,7 +277,7 @@ public class HashChunkletManager implements ChunkletManager { for (String key : store.keySet()) { if (store.get(key).isEmpty()) { String[] info = key.split(","); - File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data"); + File dataDir = new File(mcMMO.p.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + info[1]); if (!cxDir.exists()) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index c6f2daa5f..9495d29dd 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -11,12 +11,12 @@ import java.util.Iterator; import java.util.List; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory; public class HashChunkManager implements ChunkManager { @@ -283,7 +283,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void saveAll() { closeAll(); - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { saveWorld(world); } } @@ -292,7 +292,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void unloadAll() { closeAll(); - for (World world : Bukkit.getWorlds()) { + for (World world : mcMMO.p.getServer().getWorlds()) { unloadWorld(world); } }