Lists registered paid signs in the sorted order

This commit is contained in:
Kristian Knarvik 2022-07-14 23:33:36 +02:00
parent 5ce0e5e6a7
commit 427169c51a

View File

@ -10,7 +10,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static net.knarcraft.paidsigns.formatting.StringFormatter.getTranslatedErrorMessage;
import static net.knarcraft.paidsigns.formatting.StringFormatter.replacePlaceholder;
@ -42,7 +46,11 @@ public class ListCommand extends TokenizedCommand {
*/
private void displaySigns(CommandSender sender) {
StringBuilder signs = new StringBuilder();
for (String signName : PaidSigns.getInstance().getSignManager().getAllPaidSigns().keySet()) {
Set<String> signNames = PaidSigns.getInstance().getSignManager().getAllPaidSigns().keySet();
List<String> signNameList = new ArrayList<>(signNames);
Collections.sort(signNameList);
for (String signName : signNameList) {
signs.append(StringFormatter.replacePlaceholder(Translator.getTranslatedMessage(
TranslatableMessage.PAID_SIGNS_INFO_FORMAT), "{name}", signName));
}