Reformat edit prompts and sort alphabetically

This commit is contained in:
PikaMug 2021-03-03 23:55:24 -05:00
parent 223918ee77
commit 1b925f9374
4 changed files with 112 additions and 85 deletions

View File

@ -237,11 +237,14 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Action a : plugin.getActions()) { final List<String> names = plugin.getActions().stream().map(Action::getName).collect(Collectors.toList());
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", "; for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
text += ChatColor.GRAY + ", ";
} }
text = text.substring(0, text.length() - 2) + "\n"; }
text += ChatColor.YELLOW + getQueryText(context); text += "\n" + ChatColor.YELLOW + getQueryText(context);
return text; return text;
} }
@ -288,10 +291,9 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
String text = ChatColor.GOLD + getTitle(context) + "\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getActions().stream().map(Action::getName).collect(Collectors.toList()); final List<String> names = plugin.getActions().stream().map(Action::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) { 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 += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
text += ChatColor.GRAY + ", ";
} }
} }
text += "\n" + ChatColor.YELLOW + getQueryText(context); text += "\n" + ChatColor.YELLOW + getQueryText(context);

View File

@ -235,11 +235,14 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Condition a : plugin.getConditions()) { final List<String> names = plugin.getConditions().stream().map(Condition::getName).collect(Collectors.toList());
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", "; for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
text += ChatColor.GRAY + ", ";
} }
text = text.substring(0, text.length() - 2) + "\n"; }
text += ChatColor.YELLOW + getQueryText(context); text += "\n" + ChatColor.YELLOW + getQueryText(context);
return text; return text;
} }
@ -286,10 +289,9 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
String text = ChatColor.GOLD + getTitle(context) + "\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getConditions().stream().map(Condition::getName).collect(Collectors.toList()); final List<String> names = plugin.getConditions().stream().map(Condition::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) { 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 += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
text += ChatColor.GRAY + ", ";
} }
} }
text += "\n" + ChatColor.YELLOW + getQueryText(context); text += "\n" + ChatColor.YELLOW + getQueryText(context);

View File

@ -220,11 +220,16 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
= new QuestsEditorPostOpenStringPromptEvent(context, this); = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context); String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Quest q : plugin.getQuests()) { final List<String> names = plugin.getQuests().stream().map(Quest::getName).collect(Collectors.toList());
text += "\n" + ChatColor.GRAY + "- " + ChatColor.AQUA + q.getName(); for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
text += ChatColor.GRAY + ", ";
} }
return text + "\n" + ChatColor.YELLOW + getQueryText(context); }
text += "\n" + ChatColor.YELLOW + getQueryText(context);
return text;
} }
@Override @Override
@ -267,10 +272,9 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
String text = ChatColor.GOLD + getTitle(context) + "\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getQuests().stream().map(Quest::getName).collect(Collectors.toList()); final List<String> names = plugin.getQuests().stream().map(Quest::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) { 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 += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
text += ChatColor.GRAY + ", ";
} }
} }
text += "\n" + ChatColor.YELLOW + getQueryText(context); text += "\n" + ChatColor.YELLOW + getQueryText(context);

View File

@ -13,6 +13,7 @@
package me.blackvein.quests.convo.quests.objectives; package me.blackvein.quests.convo.quests.objectives;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -107,14 +108,14 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
final LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES); final LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES);
final LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS); final LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS);
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) {
for (int i = 0; i < mobs.size(); i++) { for (int i = 0; i < mobs.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY
+ " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; + " x " + ChatColor.DARK_AQUA + amnts.get(i);
} }
} else { } else {
final LinkedList<String> locs final LinkedList<String> locs
@ -126,10 +127,10 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
for (int i = 0; i < mobs.size(); i++) { for (int i = 0; i < mobs.size(); i++) {
String msg = Lang.get("blocksWithin"); String msg = Lang.get("blocksWithin");
msg = msg.replace("<amount>", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); msg = msg.replace("<amount>", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY);
text += ChatColor.GRAY + " - " + ChatColor.BLUE text += "\n" + ChatColor.GRAY + " - " + ChatColor.BLUE
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY
+ " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW
+ names.get(i) + " (" + locs.get(i) + ")\n"; + names.get(i) + " (" + locs.get(i) + ")";
} }
} }
return text; return text;
@ -138,12 +139,12 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
final LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES); final LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES);
final LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS); final LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS);
for (int i = 0; i < mobs.size(); i++) { for (int i = 0; i < mobs.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x " text += "\n" + ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x "
+ ChatColor.AQUA + amounts.get(i) + "\n"; + ChatColor.AQUA + amounts.get(i);
} }
return text; return text;
} }
@ -153,7 +154,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} else { } else {
final Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); final Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH);
return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish")
+ ChatColor.GRAY + ")\n"; + ChatColor.GRAY + ")";
} }
case 4: case 4:
if (context.getSessionData(pref + CK.S_COW_MILK) == null) { if (context.getSessionData(pref + CK.S_COW_MILK) == null) {
@ -161,18 +162,18 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} else { } else {
final Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK); final Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK);
return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows") return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows")
+ ChatColor.GRAY + ")\n"; + ChatColor.GRAY + ")";
} }
case 5: case 5:
if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
final LinkedList<String> colors = (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS); final LinkedList<String> colors = (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS);
final LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); final LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS);
for (int i = 0; i < colors.size(); i++) { for (int i = 0; i < colors.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x " text += "\n" + ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x "
+ ChatColor.AQUA + amounts.get(i) + "\n"; + ChatColor.AQUA + amounts.get(i);
} }
return text; return text;
} }
@ -246,7 +247,13 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
switch (number) { switch (number) {
case 1: case 1:
case 2: case 2:
return ChatColor.BLUE;
case 3: case 3:
if (context.getForWhom() instanceof Player) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 4: case 4:
case 5: case 5:
return ChatColor.BLUE; return ChatColor.BLUE;
@ -267,7 +274,11 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
case 2: case 2:
return ChatColor.YELLOW + Lang.get("stageEditorSetMobAmounts"); return ChatColor.YELLOW + Lang.get("stageEditorSetMobAmounts");
case 3: case 3:
if (context.getForWhom() instanceof Player) {
return ChatColor.YELLOW + Lang.get("stageEditorSetKillLocations"); return ChatColor.YELLOW + Lang.get("stageEditorSetKillLocations");
} else {
return ChatColor.GRAY + Lang.get("stageEditorSetKillLocations");
}
case 4: case 4:
return ChatColor.YELLOW + Lang.get("stageEditorSetKillLocationRadii"); return ChatColor.YELLOW + Lang.get("stageEditorSetKillLocationRadii");
case 5: case 5:
@ -289,9 +300,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final String s : (List<String>) context.getSessionData(pref + CK.S_MOB_TYPES)) { for (final String s : (List<String>) context.getSessionData(pref + CK.S_MOB_TYPES)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + s;
} }
return text; return text;
} }
@ -299,9 +310,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) == null) { if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final Integer i : (List<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS)) { for (final Integer i : (List<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + i;
} }
return text; return text;
} }
@ -309,9 +320,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final String s : (List<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS)) { for (final String s : (List<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + s;
} }
return text; return text;
} }
@ -319,9 +330,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) == null) { if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final int i : (List<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS)) { for (final int i : (List<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + i;
} }
return text; return text;
} }
@ -329,9 +340,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) == null) { if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final String s : (List<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES)) { for (final String s : (List<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + s;
} }
return text; return text;
} }
@ -365,10 +376,15 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
case 2: case 2:
return new MobsAmountsPrompt(context); return new MobsAmountsPrompt(context);
case 3: case 3:
if (context.getForWhom() instanceof Player) {
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedKillLocations(); final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedKillLocations();
temp.put(((Player) context.getForWhom()).getUniqueId(), null); temp.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getQuestFactory().setSelectedKillLocations(temp); plugin.getQuestFactory().setSelectedKillLocations(temp);
return new MobsLocationPrompt(context); return new MobsLocationPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("consoleError"));
return new MobsKillListPrompt(context);
}
case 4: case 4:
return new MobsRadiiPrompt(context); return new MobsRadiiPrompt(context);
case 5: case 5:
@ -455,8 +471,8 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event); context.getPlugin().getServer().getPluginManager().callEvent(event);
String mobs = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n"; String mobs = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
final LinkedList<EntityType> mobArr = new LinkedList<EntityType>(Arrays.asList(EntityType.values())); final List<EntityType> mobArr = new LinkedList<>(Arrays.asList(EntityType.values()));
final LinkedList<EntityType> toRemove = new LinkedList<EntityType>(); final List<EntityType> toRemove = new LinkedList<EntityType>();
for (int i = 0; i < mobArr.size(); i++) { for (int i = 0; i < mobArr.size(); i++) {
final EntityType type = mobArr.get(i); final EntityType type = mobArr.get(i);
if (type.isAlive() == false || type.name().equals("PLAYER")) { if (type.isAlive() == false || type.name().equals("PLAYER")) {
@ -464,26 +480,26 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} }
} }
mobArr.removeAll(toRemove); mobArr.removeAll(toRemove);
mobArr.sort(Comparator.comparing(EntityType::name));
for (int i = 0; i < mobArr.size(); i++) { for (int i = 0; i < mobArr.size(); i++) {
mobs += ChatColor.AQUA + MiscUtil.snakeCaseToUpperCamelCase(mobArr.get(i).name());
if (i < (mobArr.size() - 1)) { if (i < (mobArr.size() - 1)) {
mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr.get(i).name()) + ", "; mobs += ChatColor.GRAY + ", ";
} else {
mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr.get(i).name()) + "\n";
} }
} }
return mobs + ChatColor.YELLOW + getQueryText(context); mobs += "\n" + ChatColor.YELLOW + getQueryText(context);
return mobs;
} }
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<String> mobTypes = new LinkedList<String>(); final LinkedList<String> mobTypes = new LinkedList<String>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
if (MiscUtil.getProperMobType(s) != null) { if (MiscUtil.getProperMobType(s) != null) {
mobTypes.add(s); mobTypes.add(s);
} else { } else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidMob")); + Lang.get("stageEditorInvalidMob"));
return new MobsTypesPrompt(context); return new MobsTypesPrompt(context);
} }
@ -520,7 +536,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<Integer> mobAmounts = new LinkedList<Integer>(); final LinkedList<Integer> mobAmounts = new LinkedList<Integer>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
@ -533,7 +548,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} }
mobAmounts.add(i); mobAmounts.add(i);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input)); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
return new MobsAmountsPrompt(context); return new MobsAmountsPrompt(context);
} }
} }
@ -628,7 +643,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<Integer> radii = new LinkedList<Integer>(); final LinkedList<Integer> radii = new LinkedList<Integer>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
@ -641,7 +655,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} }
radii.add(i); radii.add(i);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidItemName")); + Lang.get("stageEditorInvalidItemName"));
return new MobsRadiiPrompt(context); return new MobsRadiiPrompt(context);
} }
@ -840,9 +854,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final String s : (List<String>) context.getSessionData(pref + CK.S_TAME_TYPES)) { for (final String s : (List<String>) context.getSessionData(pref + CK.S_TAME_TYPES)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + s;
} }
return text; return text;
} }
@ -850,9 +864,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) == null) { if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final Integer i : (List<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS)) { for (final Integer i : (List<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + i;
} }
return text; return text;
} }
@ -937,21 +951,28 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event); context.getPlugin().getServer().getPluginManager().callEvent(event);
String mobs = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n"; String mobs = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
final EntityType[] mobArr = EntityType.values(); final List<EntityType> mobArr = new LinkedList<>(Arrays.asList(EntityType.values()));
for (int i = 0; i < mobArr.length; i++) { final List<EntityType> toRemove = new LinkedList<EntityType>();
final EntityType type = mobArr[i]; for (int i = 0; i < mobArr.size(); i++) {
final EntityType type = mobArr.get(i);
if (type.isAlive() == false || Tameable.class.isAssignableFrom(type.getEntityClass()) == false) { if (type.isAlive() == false || Tameable.class.isAssignableFrom(type.getEntityClass()) == false) {
continue; toRemove.add(type);
} }
mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr[i].name()) + ", ";
} }
mobs = mobs.substring(0, mobs.length() - 2) + "\n"; mobArr.removeAll(toRemove);
return mobs + ChatColor.YELLOW + getQueryText(context); mobArr.sort(Comparator.comparing(EntityType::name));
for (int i = 0; i < mobArr.size(); i++) {
mobs += ChatColor.AQUA + MiscUtil.snakeCaseToUpperCamelCase(mobArr.get(i).name());
if (i < (mobArr.size() - 1)) {
mobs += ChatColor.GRAY + ", ";
}
}
mobs += "\n" + ChatColor.YELLOW + getQueryText(context);
return mobs;
} }
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<String> mobTypes = new LinkedList<String>(); final LinkedList<String> mobTypes = new LinkedList<String>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
@ -961,12 +982,12 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
mobTypes.add(s); mobTypes.add(s);
context.setSessionData(pref + CK.S_TAME_TYPES, mobTypes); context.setSessionData(pref + CK.S_TAME_TYPES, mobTypes);
} else { } else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidMob")); + Lang.get("stageEditorInvalidMob"));
return new MobsTameTypesPrompt(context); return new MobsTameTypesPrompt(context);
} }
} else { } else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidMob")); + Lang.get("stageEditorInvalidMob"));
return new MobsTameTypesPrompt(context); return new MobsTameTypesPrompt(context);
} }
@ -1002,7 +1023,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<Integer> mobAmounts = new LinkedList<Integer>(); final LinkedList<Integer> mobAmounts = new LinkedList<Integer>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
@ -1015,7 +1035,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} }
mobAmounts.add(i); mobAmounts.add(i);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", input)); .replace("<input>", input));
return new MobsTameAmountsPrompt(context); return new MobsTameAmountsPrompt(context);
} }
@ -1083,9 +1103,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final String s : (List<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS)) { for (final String s : (List<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + s;
} }
return text; return text;
} }
@ -1093,9 +1113,9 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) == null) { if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
String text = "\n"; String text = "";
for (final Integer i : (List<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS)) { for (final Integer i : (List<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; text += "\n" + ChatColor.GRAY + " - " + ChatColor.AQUA + i;
} }
return text; return text;
} }
@ -1193,7 +1213,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<String> colors = new LinkedList<String>(); final LinkedList<String> colors = new LinkedList<String>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
@ -1201,7 +1220,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
colors.add(s); colors.add(s);
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
} else { } else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidDye")); + Lang.get("stageEditorInvalidDye"));
return new MobsShearColorsPrompt(context); return new MobsShearColorsPrompt(context);
} }
@ -1237,7 +1256,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<Integer> shearAmounts = new LinkedList<Integer>(); final LinkedList<Integer> shearAmounts = new LinkedList<Integer>();
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
@ -1250,7 +1268,8 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
} }
shearAmounts.add(i); shearAmounts.add(i);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input)); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", input));
return new MobsShearAmountsPrompt(context); return new MobsShearAmountsPrompt(context);
} }
} }