X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FGetSonesCommand.java;h=83167cdd6826104bab7b33628699048237b4de0b;hp=9ff85874eb23a62e8546b9da564ce8d0e716ebf1;hb=faf66247a34f64946990a985d2ea3003465969cb;hpb=6f019de1d4d9742981d851ac3c9097cca8bff58e diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java index 9ff8587..83167cd 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–2013 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,8 @@ package net.pterodactylus.sone.fcp; +import static net.pterodactylus.sone.fcp.AbstractSoneCommandKt.encodeSones; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -24,12 +26,9 @@ import java.util.List; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; import freenet.support.SimpleFieldSet; -import freenet.support.api.Bucket; /** * Implements the “GetSones” FCP command that returns the list of known Sones. - * - * @author David ‘Bombe’ Roden */ public class GetSonesCommand extends AbstractSoneCommand { @@ -47,15 +46,15 @@ public class GetSonesCommand extends AbstractSoneCommand { * {@inheritDoc} */ @Override - public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) { + 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(), "")); + return new Response("Sones", encodeSones(Collections. emptyList(), "Sones.")); } Collections.sort(sones, Sone.NICE_NAME_COMPARATOR); - return new Response("Sones", encodeSones(sones.subList(startSone, (maxSones == -1) ? sones.size() : Math.min(startSone + maxSones, sones.size())), "")); + return new Response("Sones", encodeSones(sones.subList(startSone, (maxSones == -1) ? sones.size() : Math.min(startSone + maxSones, sones.size())), "Sones.")); } }