From aeae60f96862fe48043d8c7e6d0a1756f9df13d8 Mon Sep 17 00:00:00 2001 From: T00thpick1 Date: Fri, 8 Mar 2013 20:30:24 -0500 Subject: [PATCH] check permissions earlier --- .../gmail/nossr50/commands/player/MctopCommand.java | 10 +++++++++- .../nossr50/database/queuemanager/McTopAsync.java | 13 +------------ 2 files changed, 10 insertions(+), 13 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 d82ac7db0..3ddf37958 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -72,17 +72,22 @@ 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, command); + sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender); } else { sqlDisplay(page, skill, sender, command); + sqlDisplay(page, skill, sender); } } else { @@ -124,7 +129,10 @@ public class MctopCommand implements CommandExecutor { private void sqlDisplay(int page, String query, CommandSender sender, Command command) { if (mcMMO.queueManager.contains(sender.getName()) || !mcMMO.queueManager.queue(new McTopAsync(page, query, sender, command))) { + private void sqlDisplay(int page, String query, CommandSender sender) { + if (mcMMO.queueManager.contains(sender.getName()) || !mcMMO.queueManager.queue(new McTopAsync(page, query, sender))) { //Warn that queue is unable to accept } } } + 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 7e93ab1d2..03c622348 100644 --- a/src/main/java/com/gmail/nossr50/database/queuemanager/McTopAsync.java +++ b/src/main/java/com/gmail/nossr50/database/queuemanager/McTopAsync.java @@ -5,40 +5,29 @@ import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.datatypes.skills.SkillType; public class McTopAsync implements Queueable { private CommandSender sender; private String query; private int page; - private Command command; private String player; - public McTopAsync(int page, String query, CommandSender sender, Command command) { + public McTopAsync(int page, String query, CommandSender sender) { this.page = page; this.query = query; this.sender = sender; - this.command = command; this.player = sender.getName(); } public void run() { - if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) { - if (!Permissions.mctop(sender, SkillType.getSkill(query))) { - sender.sendMessage(command.getPermissionMessage()); - return; - } - } 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() {