Diff cleanup

This commit is contained in:
NuclearW 2013-03-10 22:54:47 -04:00
parent d27f668a2e
commit 1b17b90f32
6 changed files with 28 additions and 30 deletions

View File

@ -72,14 +72,11 @@ public class MctopCommand implements CommandExecutor {
} }
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) { private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) { if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return; return;
} }
if (sql) { if (sql) {
if (skill.equalsIgnoreCase("all")) { if (skill.equalsIgnoreCase("all")) {
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender); sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender);
@ -131,4 +128,3 @@ public class MctopCommand implements CommandExecutor {
} }
} }
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.database.queuemanager;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
public class AsyncQueueManager implements Runnable { public class AsyncQueueManager implements Runnable {
private LinkedBlockingQueue<Queueable> queue; private LinkedBlockingQueue<Queueable> queue;
private boolean running; private boolean running;
@ -11,7 +10,6 @@ public class AsyncQueueManager implements Runnable {
this.queue = new LinkedBlockingQueue<Queueable>(); this.queue = new LinkedBlockingQueue<Queueable>();
this.running = true; this.running = true;
} }
@Override @Override
public void run() { public void run() {
@ -32,29 +30,33 @@ public class AsyncQueueManager implements Runnable {
return queue.contains(new EqualString(player)); 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() { public void disable() {
running = false; running = false;
// Throw one more Queueable into queue to unblock take() // Throw one more Queueable into queue to unblock take()
queue.add(new EndThread()); 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 { private class EndThread implements Queueable {
@Override @Override
public void run() { } public void run() { }
@Override @Override
public String getPlayer() { return null; } public String getPlayer() { return null; }
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.database.queuemanager;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -22,10 +21,11 @@ public class McRankAsync implements Queueable {
this.player = sender.getName(); this.player = sender.getName();
} }
@Override
public void run() { public void run() {
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName); final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(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

@ -3,7 +3,6 @@ package com.gmail.nossr50.database.queuemanager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -27,15 +26,17 @@ public class McTopAsync implements Queueable {
this.player = sender.getName(); this.player = sender.getName();
} }
@Override
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");
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
@Override @Override
public void run() { 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")); sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
} else { }
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query))); sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.database.queuemanager; package com.gmail.nossr50.database.queuemanager;
public interface Queueable { public interface Queueable {
public void run(); public void run();
public String getPlayer(); public String getPlayer();
} }

View File

@ -91,7 +91,6 @@ public class mcMMO extends JavaPlugin {
// XP Event Check // XP Event Check
private boolean xpEventEnabled = false; private boolean xpEventEnabled = false;
// Metadata Values // Metadata Values
public static FixedMetadataValue metadataValue; public static FixedMetadataValue metadataValue;
public final static String entityMetadataKey = "mcMMO: Spawned Entity"; public final static String entityMetadataKey = "mcMMO: Spawned Entity";