mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
One per player
This commit is contained in:
parent
a7f146a835
commit
44188396b4
@ -123,7 +123,11 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
|
|
||||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||||
if (mcMMO.queueManager.contains(sender.getName()) || !mcMMO.queueManager.queue(new McRankAsync(playerName, sender))) {
|
if (mcMMO.queueManager.contains(sender.getName()) || !mcMMO.queueManager.queue(new McRankAsync(playerName, sender))) {
|
||||||
|
<<<<<<< HEAD
|
||||||
//Warn that queue is unable to accept
|
//Warn that queue is unable to accept
|
||||||
|
=======
|
||||||
|
//Tell user to wait until their first command goes through
|
||||||
|
>>>>>>> One per player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
package com.gmail.nossr50.commands.player;
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -128,3 +129,121 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.database.Leaderboard;
|
||||||
|
import com.gmail.nossr50.database.queuemanager.McTopAsync;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
public class MctopCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
display(1, "ALL", sender, useMySQL, command);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (StringUtils.isInt(args[0])) {
|
||||||
|
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||||
|
}
|
||||||
|
else if (SkillTools.isSkill(args[0])) {
|
||||||
|
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
if (!StringUtils.isInt(args[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SkillTools.isSkill(args[0])) {
|
||||||
|
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||||
|
if (sql) {
|
||||||
|
if (skill.equalsIgnoreCase("all")) {
|
||||||
|
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sqlDisplay(page, skill, sender, command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flatfileDisplay(page, skill, sender, command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||||
|
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||||
|
|
||||||
|
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||||
|
|
||||||
|
if (skill.equalsIgnoreCase("all")) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int n = (page * 10) - 9; // Position
|
||||||
|
for (String x : info) {
|
||||||
|
if (x != null) {
|
||||||
|
String digit = String.valueOf(n);
|
||||||
|
|
||||||
|
if (n < 10) {
|
||||||
|
digit = "0" + digit;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] splitx = x.split(":");
|
||||||
|
|
||||||
|
// Format: 1. Playername - skill value
|
||||||
|
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
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))) {
|
||||||
|
//Tell user to wait until their first command goes through
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>>>>>> One per player
|
||||||
|
@ -36,6 +36,7 @@ public class AsyncQueueManager implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(String player) {
|
public boolean contains(String player) {
|
||||||
|
<<<<<<< HEAD
|
||||||
return queue.contains(new EqualString(player));
|
return queue.contains(new EqualString(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +52,9 @@ public class AsyncQueueManager implements Runnable {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
return queue.contains(player);
|
||||||
|
>>>>>>> One per player
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ 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);
|
||||||
|
|
||||||
@ -54,9 +55,19 @@ public class McRankAsync implements Queueable {
|
|||||||
|
|
||||||
}, 1L);
|
}, 1L);
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayer() {
|
public String getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
|
=======
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof String) {
|
||||||
|
return ((String)obj).equalsIgnoreCase(player);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
>>>>>>> One per player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public class McTopAsync implements Queueable {
|
|||||||
this.player = sender.getName();
|
this.player = sender.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!query.equalsIgnoreCase("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")) {
|
||||||
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
|
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
|
||||||
@ -67,8 +68,17 @@ public class McTopAsync implements Queueable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
<<<<<<< HEAD
|
||||||
public String getPlayer() {
|
public String getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof String) {
|
||||||
|
return ((String)obj).equalsIgnoreCase(player);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
>>>>>>> One per player
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user