From 1b17b90f324c0ec9440efb494526c476264a2d83 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sun, 10 Mar 2013 22:54:47 -0400 Subject: [PATCH] Diff cleanup --- .../nossr50/commands/player/MctopCommand.java | 6 +--- .../queuemanager/AsyncQueueManager.java | 34 ++++++++++--------- .../database/queuemanager/McRankAsync.java | 4 +-- .../database/queuemanager/McTopAsync.java | 9 ++--- .../database/queuemanager/Queueable.java | 4 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 1 - 6 files changed, 28 insertions(+), 30 deletions(-) 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 037314739..c861bcf3f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -72,14 +72,11 @@ public class MctopCommand implements CommandExecutor { } private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { - - - - if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { sender.sendMessage(command.getPermissionMessage()); return; } + if (sql) { if (skill.equalsIgnoreCase("all")) { sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender); @@ -131,4 +128,3 @@ public class MctopCommand implements CommandExecutor { } } } - diff --git a/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java b/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java index e92e67718..56f26174c 100644 --- a/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java +++ b/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.database.queuemanager; import java.util.concurrent.LinkedBlockingQueue; public class AsyncQueueManager implements Runnable { - private LinkedBlockingQueue queue; private boolean running; @@ -11,7 +10,6 @@ public class AsyncQueueManager implements Runnable { this.queue = new LinkedBlockingQueue(); this.running = true; } - @Override public void run() { @@ -32,29 +30,33 @@ public class AsyncQueueManager implements Runnable { return queue.contains(new EqualString(player)); } - private class EqualString { - private String player; - public EqualString(String player) { - this.player = player; - } - @Override - public boolean equals(Object obj) { - if (obj instanceof Queueable) { - return ((Queueable)obj).getPlayer().equalsIgnoreCase(player); - } - return false; - } - } - public void disable() { running = false; // Throw one more Queueable into queue to unblock take() queue.add(new EndThread()); } + private class EqualString { + private String player; + + public EqualString(String player) { + this.player = player; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Queueable) { + return ((Queueable)obj).getPlayer().equalsIgnoreCase(player); + } + + return false; + } + } + private class EndThread implements Queueable { @Override public void run() { } + @Override public String getPlayer() { return null; } } diff --git a/src/main/java/com/gmail/nossr50/database/queuemanager/McRankAsync.java b/src/main/java/com/gmail/nossr50/database/queuemanager/McRankAsync.java index 34b3785ac..5930487dd 100644 --- a/src/main/java/com/gmail/nossr50/database/queuemanager/McRankAsync.java +++ b/src/main/java/com/gmail/nossr50/database/queuemanager/McRankAsync.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.database.queuemanager; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; @@ -22,10 +21,11 @@ public class McRankAsync implements Queueable { this.player = sender.getName(); } + @Override 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/database/queuemanager/McTopAsync.java b/src/main/java/com/gmail/nossr50/database/queuemanager/McTopAsync.java index 03c622348..f40535584 100644 --- a/src/main/java/com/gmail/nossr50/database/queuemanager/McTopAsync.java +++ b/src/main/java/com/gmail/nossr50/database/queuemanager/McTopAsync.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.database.queuemanager; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -27,15 +26,17 @@ public class McTopAsync implements Queueable { this.player = sender.getName(); } + @Override 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"); - 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")) { + if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); - } else { + } + else { sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query))); } diff --git a/src/main/java/com/gmail/nossr50/database/queuemanager/Queueable.java b/src/main/java/com/gmail/nossr50/database/queuemanager/Queueable.java index 0af1eaddc..621daec58 100644 --- a/src/main/java/com/gmail/nossr50/database/queuemanager/Queueable.java +++ b/src/main/java/com/gmail/nossr50/database/queuemanager/Queueable.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.database.queuemanager; public interface Queueable { - public void run(); - public String getPlayer(); + public void run(); + public String getPlayer(); } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index d6315767f..3095b458a 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -91,7 +91,6 @@ public class mcMMO extends JavaPlugin { // XP Event Check private boolean xpEventEnabled = false; - // Metadata Values public static FixedMetadataValue metadataValue; public final static String entityMetadataKey = "mcMMO: Spawned Entity";