diff --git a/src/main/java/us/ajg0702/leaderboards/commands/main/MainCommand.java b/src/main/java/us/ajg0702/leaderboards/commands/main/MainCommand.java index ee460fcd..0920c6e4 100644 --- a/src/main/java/us/ajg0702/leaderboards/commands/main/MainCommand.java +++ b/src/main/java/us/ajg0702/leaderboards/commands/main/MainCommand.java @@ -13,7 +13,6 @@ import java.util.Arrays; import java.util.Collections; -import java.util.List; import static us.ajg0702.leaderboards.LeaderboardPlugin.message; @@ -29,7 +28,7 @@ public MainCommand(LeaderboardPlugin plugin) { addSubCommand(new UpdatePlayer(plugin)); addSubCommand(new RemovePlayer(plugin)); addSubCommand(new Remove(plugin)); - addSubCommand(new ListBoards(plugin)); + addSubCommand(new ListCommand(plugin)); addSubCommand(new Signs(plugin)); addSubCommand(new Export(plugin)); addSubCommand(new Import(plugin)); @@ -45,7 +44,7 @@ public MainCommand(LeaderboardPlugin plugin) { } @Override - public List autoComplete(CommandSender sender, String[] args) { + public java.util.List autoComplete(CommandSender sender, String[] args) { if(!checkPermission(sender)) { return Collections.emptyList(); } @@ -66,7 +65,7 @@ public void execute(CommandSender sender, String[] args, String label) { sendHelp(sender, label, getSubCommands()); } - public static void sendHelp(CommandSender sender, String label, List subCommands) { + public static void sendHelp(CommandSender sender, String label, java.util.List subCommands) { sender.sendMessage(message("")); for(SubCommand subCommand : subCommands) { if(!subCommand.showInTabComplete()) continue; diff --git a/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Export.java b/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Export.java index 505dd8b8..1dba98e6 100644 --- a/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Export.java +++ b/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Export.java @@ -1,16 +1,12 @@ package us.ajg0702.leaderboards.commands.main.subcommands; import com.google.gson.Gson; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import org.bukkit.Bukkit; import us.ajg0702.commands.CommandSender; import us.ajg0702.commands.SubCommand; import us.ajg0702.leaderboards.LeaderboardPlugin; -import us.ajg0702.leaderboards.cache.helpers.DbRow; import java.io.*; -import java.sql.SQLException; import java.util.*; import java.util.logging.Level; diff --git a/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Import.java b/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Import.java index 7bd4e90b..749b4f24 100644 --- a/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Import.java +++ b/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/Import.java @@ -4,7 +4,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import org.bukkit.Bukkit; import us.ajg0702.commands.CommandSender; import us.ajg0702.commands.SubCommand; import us.ajg0702.leaderboards.Debug; diff --git a/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/ListBoards.java b/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/ListCommand.java similarity index 72% rename from src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/ListBoards.java rename to src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/ListCommand.java index d27c71a9..11eee6a5 100644 --- a/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/ListBoards.java +++ b/src/main/java/us/ajg0702/leaderboards/commands/main/subcommands/ListCommand.java @@ -1,6 +1,5 @@ package us.ajg0702.leaderboards.commands.main.subcommands; -import org.bukkit.Bukkit; import us.ajg0702.commands.CommandSender; import us.ajg0702.commands.SubCommand; import us.ajg0702.leaderboards.LeaderboardPlugin; @@ -11,17 +10,23 @@ import static us.ajg0702.leaderboards.LeaderboardPlugin.message; -public class ListBoards extends SubCommand { +public class ListCommand extends SubCommand { private final LeaderboardPlugin plugin; - public ListBoards(LeaderboardPlugin plugin) { + public ListCommand(LeaderboardPlugin plugin) { super("list", Collections.emptyList(), "ajleaderboards.use", "List all boards in ajleaderboards, or list the top 10 players in a certain board."); this.plugin = plugin; } @Override public java.util.List autoComplete(CommandSender commandSender, String[] args) { - return filterCompletion(plugin.getTopManager().getBoards(), args[0]); + if(args.length <= 1) { + return filterCompletion(plugin.getTopManager().getBoards(), args[0]); + } else if(args.length == 2) { + return filterCompletion(TimedType.lowerNames(), args[1]); + } else { + return Collections.emptyList(); + } } @Override @@ -35,14 +40,15 @@ public void execute(CommandSender sender, String[] args, String label) { sender.sendMessage(message(list.toString())); return; } - String boardn = args[0]; - if(!plugin.getCache().boardExists(boardn)) { - sender.sendMessage(message("&cThe board '"+boardn+"' does not exist.")); + String board = args[0]; + TimedType timedType = args.length > 1 ? TimedType.of(args[1]) : TimedType.ALLTIME; + if(!plugin.getCache().boardExists(board)) { + sender.sendMessage(message("&cThe board '"+board+"' does not exist.")); return; } - StringBuilder list = new StringBuilder("&6Top for " + boardn); + StringBuilder list = new StringBuilder("&6Top for " + board + " " + timedType.lowerName()); for(int i = 1;i<=10;i++) { - StatEntry e = plugin.getCache().getStat(i, boardn, TimedType.ALLTIME); + StatEntry e = plugin.getCache().getStat(i, board, timedType); list.append("\n&6").append(i).append(". &e").append(e.getPlayerName()).append(" &7- &e").append(e.getScorePretty()); } sender.sendMessage(message(list.toString()));