From 5312eab16bd5aef16a5ac4685c1e80cbb5e9c1eb Mon Sep 17 00:00:00 2001 From: Alastair Date: Thu, 4 Aug 2016 02:37:19 +0000 Subject: [PATCH] Sorted out the portal and location sorting --- .../AdvancedPortalsCommand.java | 9 ++++-- .../destinations/DestinationCommand.java | 28 +++++++------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index 275d701..7769c5b 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -404,14 +404,19 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter { break; case "list" : String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a"; + LinkedList portals = new LinkedList<>(); for (AdvancedPortal portal : Portal.Portals) { - message = message + " " + portal.portalName; + portals.add(portal.portalName); + } + Collections.sort(portals); + for (Object portalName : portals.toArray()) { + message = message + " " + portalName; } player.sendMessage(message); break; default: PluginMessages.UnknownCommand(sender, command); - } + } } else { PluginMessages.UnknownCommand(sender, command); } diff --git a/src/com/sekwah/advancedportals/destinations/DestinationCommand.java b/src/com/sekwah/advancedportals/destinations/DestinationCommand.java index 7f832d0..483854d 100644 --- a/src/com/sekwah/advancedportals/destinations/DestinationCommand.java +++ b/src/com/sekwah/advancedportals/destinations/DestinationCommand.java @@ -64,21 +64,13 @@ public class DestinationCommand implements CommandExecutor, TabCompleter { break; case "list": String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a"; - int locationsPerPage = 5; - if(locationsPerPage > 5){ - List destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray()); - List destis = new ArrayList<>(); - for (Object object : destiObj) { - destis.add(object != null ? object.toString() : null); - } - Collections.sort(destis); - for (String desti : destis) message = message + " " + desti; - sender.sendMessage(message); + List destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray()); + LinkedList destis = new LinkedList<>(); + for (Object object : destiObj.toArray()) { + destis.add(object.toString()); } - else{ - - } - for (String desti : config.getConfig().getKeys(false)) message = message + " " + desti; + Collections.sort(destis); + for (Object desti : destis.toArray()) message = message + " " + desti; sender.sendMessage(message); break; case "help": @@ -111,13 +103,13 @@ public class DestinationCommand implements CommandExecutor, TabCompleter { @Override public List onTabComplete(CommandSender sender, Command cmd, String command, String[] args) { - LinkedList autoComplete = new LinkedList(); + LinkedList autoComplete = new LinkedList<>(); ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml"); if(args.length > 1 && args[0].equalsIgnoreCase("warp")){ for (String string : config.getConfig().getKeys(false)) { - if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string)) - autoComplete.add(string); - } + if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string)) + autoComplete.add(string); + } } if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("AdvancedPortals.CreatePortal")) { if (args.length == 1) {