From 223918ee771557e5f4161ca819747ac2fa15638e Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Wed, 3 Mar 2021 06:26:07 -0500 Subject: [PATCH] Display objects of editor delete prompts alphabetically --- .../quests/convo/actions/menu/ActionMenuPrompt.java | 13 +++++++++---- .../convo/conditions/menu/ConditionMenuPrompt.java | 13 +++++++++---- .../quests/convo/quests/menu/QuestMenuPrompt.java | 13 +++++++++---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java b/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java index 9ba78db36..61b55a2ff 100644 --- a/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java @@ -14,6 +14,7 @@ package me.blackvein.quests.convo.actions.menu; import java.util.LinkedList; import java.util.List; +import java.util.stream.Collectors; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -285,11 +286,15 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + getTitle(context) + "\n"; - for (final Action a : plugin.getActions()) { - text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ","; + final List names = plugin.getActions().stream().map(Action::getName).collect(Collectors.toList()); + for (int i = 0; i < names.size(); i++) { + if (i < (names.size() - 1)) { + text += ChatColor.AQUA + names.get(i) + ChatColor.GRAY + ", "; + } else { + text += ChatColor.AQUA + names.get(i); + } } - text = text.substring(0, text.length() - 1) + "\n"; - text += ChatColor.YELLOW + getQueryText(context); + text += "\n" + ChatColor.YELLOW + getQueryText(context); return text; } diff --git a/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java b/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java index 93489f5a2..d384ac85f 100644 --- a/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java @@ -14,6 +14,7 @@ package me.blackvein.quests.convo.conditions.menu; import java.util.LinkedList; import java.util.List; +import java.util.stream.Collectors; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -283,11 +284,15 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + getTitle(context) + "\n"; - for (final Condition c : plugin.getConditions()) { - text += ChatColor.AQUA + c.getName() + ChatColor.GRAY + ","; + final List names = plugin.getConditions().stream().map(Condition::getName).collect(Collectors.toList()); + for (int i = 0; i < names.size(); i++) { + if (i < (names.size() - 1)) { + text += ChatColor.AQUA + names.get(i) + ChatColor.GRAY + ", "; + } else { + text += ChatColor.AQUA + names.get(i); + } } - text = text.substring(0, text.length() - 1) + "\n"; - text += ChatColor.YELLOW + getQueryText(context); + text += "\n" + ChatColor.YELLOW + getQueryText(context); return text; } diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/menu/QuestMenuPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/menu/QuestMenuPrompt.java index 9525b7eb7..4bbdf8144 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/menu/QuestMenuPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/menu/QuestMenuPrompt.java @@ -14,6 +14,7 @@ package me.blackvein.quests.convo.quests.menu; import java.util.LinkedList; import java.util.List; +import java.util.stream.Collectors; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -264,11 +265,15 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt { plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + getTitle(context) + "\n"; - for (final Quest quest : plugin.getQuests()) { - text += ChatColor.AQUA + quest.getName() + ChatColor.GRAY + ","; + final List names = plugin.getQuests().stream().map(Quest::getName).collect(Collectors.toList()); + for (int i = 0; i < names.size(); i++) { + if (i < (names.size() - 1)) { + text += ChatColor.AQUA + names.get(i) + ChatColor.GRAY + ", "; + } else { + text += ChatColor.AQUA + names.get(i); + } } - text = text.substring(0, text.length() - 1) + "\n"; - text += ChatColor.YELLOW + getQueryText(context); + text += "\n" + ChatColor.YELLOW + getQueryText(context); return text; }