X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FGetSonesCommand.java;h=eedf120442888ccd2c9d8de2d8a24a0400537ad7;hb=5c5bee980f9cab5792e34d1c9840f73b8b191830;hp=3ff234a60fb100eada466ec581d41b2ec540c95d;hpb=5ab6ee01df9bac0c7bd5d27a6990dfdf60555d0f;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java index 3ff234a..eedf120 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetSonesCommand.java - Copyright © 2011–2016 David Roden + * Sone - GetSonesCommand.java - Copyright © 2011–2020 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ package net.pterodactylus.sone.fcp; +import static net.pterodactylus.sone.data.SoneKt.*; import static net.pterodactylus.sone.fcp.AbstractSoneCommandKt.encodeSones; import java.util.ArrayList; @@ -24,7 +25,8 @@ import java.util.Collections; import java.util.List; import net.pterodactylus.sone.core.Core; -import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.data.*; + import freenet.support.SimpleFieldSet; /** @@ -49,11 +51,11 @@ public class GetSonesCommand extends AbstractSoneCommand { public Response execute(SimpleFieldSet parameters) { int startSone = getInt(parameters, "StartSone", 0); int maxSones = getInt(parameters, "MaxSones", -1); - List sones = new ArrayList(getCore().getSones()); + List sones = new ArrayList<>(getCore().getSones()); if (sones.size() < startSone) { return new Response("Sones", encodeSones(Collections. emptyList(), "Sones.")); } - Collections.sort(sones, Sone.NICE_NAME_COMPARATOR); + sones.sort(niceNameComparator()); return new Response("Sones", encodeSones(sones.subList(startSone, (maxSones == -1) ? sones.size() : Math.min(startSone + maxSones, sones.size())), "Sones.")); }