Sorted out the portal and location sorting

This commit is contained in:
Alastair 2016-08-04 02:37:19 +00:00
parent d4da241c2c
commit 5312eab16b
2 changed files with 17 additions and 20 deletions

View File

@ -404,14 +404,19 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
break; break;
case "list" : case "list" :
String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a"; String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a";
LinkedList<String> portals = new LinkedList<>();
for (AdvancedPortal portal : Portal.Portals) { 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); player.sendMessage(message);
break; break;
default: default:
PluginMessages.UnknownCommand(sender, command); PluginMessages.UnknownCommand(sender, command);
} }
} else { } else {
PluginMessages.UnknownCommand(sender, command); PluginMessages.UnknownCommand(sender, command);
} }

View File

@ -64,21 +64,13 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
break; break;
case "list": case "list":
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a"; String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
int locationsPerPage = 5; List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray());
if(locationsPerPage > 5){ LinkedList<String> destis = new LinkedList<>();
List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray()); for (Object object : destiObj.toArray()) {
List<String> destis = new ArrayList<>(); destis.add(object.toString());
for (Object object : destiObj) {
destis.add(object != null ? object.toString() : null);
}
Collections.sort(destis);
for (String desti : destis) message = message + " " + desti;
sender.sendMessage(message);
} }
else{ Collections.sort(destis);
for (Object desti : destis.toArray()) message = message + " " + desti;
}
for (String desti : config.getConfig().getKeys(false)) message = message + " " + desti;
sender.sendMessage(message); sender.sendMessage(message);
break; break;
case "help": case "help":
@ -111,13 +103,13 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) { public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>(); LinkedList<String> autoComplete = new LinkedList<>();
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml"); ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
if(args.length > 1 && args[0].equalsIgnoreCase("warp")){ if(args.length > 1 && args[0].equalsIgnoreCase("warp")){
for (String string : config.getConfig().getKeys(false)) { for (String string : config.getConfig().getKeys(false)) {
if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string)) if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string))
autoComplete.add(string); autoComplete.add(string);
} }
} }
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("AdvancedPortals.CreatePortal")) { if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("AdvancedPortals.CreatePortal")) {
if (args.length == 1) { if (args.length == 1) {