Quests/core/src/main/java/me/pikamug/quests/convo/quests/stages/QuestStageMainPrompt.java

2783 lines
131 KiB
Java
Raw Normal View History

2021-08-16 06:11:42 +02:00
/*
* Copyright (c) PikaMug and contributors
2021-08-16 06:11:42 +02:00
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2021-08-16 06:11:42 +02:00
*/
package me.pikamug.quests.convo.quests.stages;
import me.pikamug.quests.actions.Action;
import me.pikamug.quests.conditions.Condition;
import me.pikamug.quests.module.CustomObjective;
import me.pikamug.quests.BukkitQuestsPlugin;
import me.pikamug.quests.convo.QuestsNumericPrompt;
import me.pikamug.quests.convo.generic.OverridePrompt;
import me.pikamug.quests.convo.quests.QuestsEditorNumericPrompt;
import me.pikamug.quests.convo.quests.QuestsEditorStringPrompt;
import me.pikamug.quests.convo.quests.objectives.QuestBlocksPrompt;
import me.pikamug.quests.convo.quests.objectives.QuestItemsPrompt;
import me.pikamug.quests.convo.quests.objectives.QuestMobsPrompt;
import me.pikamug.quests.convo.quests.objectives.QuestNpcsPrompt;
import me.pikamug.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
import me.pikamug.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
import me.pikamug.quests.util.Key;
import me.pikamug.quests.util.BukkitConfigUtil;
import me.pikamug.quests.util.BukkitLang;
import me.pikamug.quests.util.BukkitMiscUtil;
2022-01-04 07:15:52 +01:00
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
2021-10-07 10:36:57 +02:00
import org.jetbrains.annotations.NotNull;
2021-10-09 08:38:57 +02:00
import org.jetbrains.annotations.Nullable;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
2021-10-09 08:38:57 +02:00
import java.util.TreeSet;
import java.util.UUID;
2021-10-09 08:38:57 +02:00
import java.util.stream.Collectors;
2023-02-27 01:05:39 +01:00
public class QuestStageMainPrompt extends QuestsEditorNumericPrompt {
private final BukkitQuestsPlugin plugin;
2019-10-04 01:48:35 +02:00
private final int stageNum;
private final String stagePrefix;
private final String classPrefix;
2019-10-04 01:48:35 +02:00
private boolean hasObjective = false;
private final int size = 17;
2019-10-04 01:48:35 +02:00
2023-02-27 01:05:39 +01:00
public QuestStageMainPrompt(final int stageNum, final ConversationContext context) {
super(context);
this.plugin = (BukkitQuestsPlugin)context.getPlugin();
2019-10-04 01:48:35 +02:00
this.stageNum = stageNum;
this.stagePrefix = "stage" + stageNum;
this.classPrefix = getClass().getSimpleName();
}
public int getStageNumber() {
return stageNum;
2019-10-04 01:48:35 +02:00
}
2020-08-06 11:32:43 +02:00
@Override
2019-10-04 01:48:35 +02:00
public int getSize() {
return size;
}
2020-08-06 11:32:43 +02:00
@Override
public String getTitle(final ConversationContext context) {
return context.getSessionData(Key.Q_NAME) + " | " + BukkitLang.get("stageEditorStage") + " " + stageNum;
2019-10-04 01:48:35 +02:00
}
2020-08-06 11:32:43 +02:00
@Override
public ChatColor getNumberColor(final ConversationContext context, final int number) {
2019-10-04 01:48:35 +02:00
switch (number) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
return ChatColor.BLUE;
case 9:
case 10:
case 11:
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
case 12:
if (context.getSessionData(stagePrefix + Key.S_DELAY) == null) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
case 13:
if (context.getSessionData(stagePrefix + Key.S_START_MESSAGE) == null) {
2019-10-04 01:48:35 +02:00
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
} else {
return ChatColor.BLUE;
}
case 14:
if (context.getSessionData(stagePrefix + Key.S_COMPLETE_MESSAGE) == null) {
2019-10-04 01:48:35 +02:00
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
} else {
return ChatColor.BLUE;
}
case 15:
if (context.getSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
2019-10-04 01:48:35 +02:00
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
} else {
return ChatColor.BLUE;
}
case 16:
return ChatColor.RED;
case 17:
return ChatColor.GREEN;
default:
return null;
2019-10-04 01:48:35 +02:00
}
}
2020-01-04 07:12:34 +01:00
2020-08-06 11:32:43 +02:00
@Override
public String getSelectionText(final ConversationContext context, final int number) {
2019-10-04 01:48:35 +02:00
switch (number) {
case 1:
return ChatColor.GOLD + BukkitLang.get("stageEditorBlocks");
case 2:
return ChatColor.GOLD + BukkitLang.get("stageEditorItems");
case 3:
return ChatColor.GOLD + BukkitLang.get("stageEditorNPCs");
case 4:
return ChatColor.GOLD + BukkitLang.get("stageEditorMobs");
case 5:
return ChatColor.YELLOW + BukkitLang.get("stageEditorKillPlayers");
case 6:
return ChatColor.YELLOW + BukkitLang.get("stageEditorReachLocs");
case 7:
return ChatColor.YELLOW + BukkitLang.get("stageEditorPassword");
case 8:
return ChatColor.DARK_PURPLE + BukkitLang.get("stageEditorCustom");
case 9:
if (!hasObjective) {
return ChatColor.GRAY + BukkitLang.get("stageEditorEvents");
} else {
return ChatColor.AQUA + BukkitLang.get("stageEditorEvents");
}
case 10:
if (!hasObjective) {
return ChatColor.GRAY + BukkitLang.get("stageEditorConditions");
} else {
return ChatColor.AQUA + BukkitLang.get("stageEditorConditions");
}
case 11:
if (!hasObjective) {
return ChatColor.GRAY + BukkitLang.get("delay");
} else {
return ChatColor.YELLOW + BukkitLang.get("delay");
}
case 12:
if (context.getSessionData(stagePrefix + Key.S_DELAY) == null) {
return ChatColor.GRAY + BukkitLang.get("stageEditorDelayMessage");
} else {
return ChatColor.YELLOW + BukkitLang.get("stageEditorDelayMessage");
}
case 13:
if (context.getSessionData(stagePrefix + Key.S_START_MESSAGE) == null) {
2019-10-04 01:48:35 +02:00
if (!hasObjective) {
return ChatColor.GRAY + BukkitLang.get("stageEditorStartMessage");
2019-10-04 01:48:35 +02:00
} else {
return ChatColor.YELLOW + BukkitLang.get("stageEditorStartMessage");
2019-10-04 01:48:35 +02:00
}
} else {
return ChatColor.YELLOW + BukkitLang.get("stageEditorStartMessage");
}
case 14:
if (context.getSessionData(stagePrefix + Key.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + BukkitLang.get("stageEditorCompleteMessage");
2019-10-04 01:48:35 +02:00
} else {
return ChatColor.YELLOW + BukkitLang.get("stageEditorCompleteMessage");
2019-10-04 01:48:35 +02:00
}
} else {
return ChatColor.YELLOW + BukkitLang.get("stageEditorCompleteMessage");
}
case 15:
if (context.getSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY + BukkitLang.get("overrideCreateSet");
2019-10-04 01:48:35 +02:00
} else {
return ChatColor.YELLOW + BukkitLang.get("overrideCreateSet");
2019-10-04 01:48:35 +02:00
}
} else {
return ChatColor.YELLOW + BukkitLang.get("overrideCreateSet");
}
case 16:
return ChatColor.RED + BukkitLang.get("stageEditorDelete");
case 17:
return ChatColor.GREEN + BukkitLang.get("done");
default:
return null;
2019-10-04 01:48:35 +02:00
}
}
2020-08-06 11:32:43 +02:00
@Override
2019-10-04 01:48:35 +02:00
@SuppressWarnings("unchecked")
2020-08-06 11:32:43 +02:00
public String getAdditionalText(final ConversationContext context, final int number) {
2019-10-04 01:48:35 +02:00
switch (number) {
case 1:
if (context.getSessionData(stagePrefix + Key.S_BREAK_NAMES) == null
&& context.getSessionData(stagePrefix + Key.S_DAMAGE_NAMES) == null
&& context.getSessionData(stagePrefix + Key.S_PLACE_NAMES) == null
&& context.getSessionData(stagePrefix + Key.S_USE_NAMES) == null
&& context.getSessionData(stagePrefix + Key.S_CUT_NAMES) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return "";
}
case 2:
if (context.getSessionData(stagePrefix + Key.S_CRAFT_ITEMS) == null
&& context.getSessionData(stagePrefix + Key.S_SMELT_ITEMS) == null
&& context.getSessionData(stagePrefix + Key.S_ENCHANT_ITEMS) == null
&& context.getSessionData(stagePrefix + Key.S_BREW_ITEMS) == null
&& context.getSessionData(stagePrefix + Key.S_CONSUME_ITEMS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return "";
}
case 3:
if (context.getSessionData(stagePrefix + Key.S_DELIVERY_NPCS) == null
&& context.getSessionData(stagePrefix + Key.S_NPCS_TO_TALK_TO) == null
&& context.getSessionData(stagePrefix + Key.S_NPCS_TO_KILL) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return "";
}
case 4:
if (context.getSessionData(stagePrefix + Key.S_MOB_TYPES) == null
&& context.getSessionData(stagePrefix + Key.S_TAME_TYPES) == null
&& context.getSessionData(stagePrefix + Key.S_FISH) == null
&& context.getSessionData(stagePrefix + Key.S_COW_MILK) == null
&& context.getSessionData(stagePrefix + Key.S_SHEAR_COLORS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return "";
}
case 5:
if (context.getSessionData(stagePrefix + Key.S_PLAYER_KILL) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
final Integer players = (Integer) context.getSessionData(stagePrefix + Key.S_PLAYER_KILL);
return ChatColor.GRAY + "(" + ChatColor.AQUA + players + " " + BukkitLang.get("stageEditorPlayers")
+ ChatColor.GRAY + ")";
}
case 6:
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2020-08-06 11:32:43 +02:00
final LinkedList<String> locations
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS);
2020-08-06 11:32:43 +02:00
final LinkedList<Integer> radii
= (LinkedList<Integer>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS);
2020-08-06 11:32:43 +02:00
final LinkedList<String> names
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES);
2021-10-07 10:36:57 +02:00
if (locations != null && radii != null && names != null) {
for (int i = 0; i < locations.size(); i++) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ")
.append(BukkitLang.get("stageEditorReachRadii1")).append(" ").append(ChatColor.BLUE)
2021-12-06 10:58:41 +01:00
.append(radii.get(i)).append(ChatColor.GRAY).append(" ")
.append(BukkitLang.get("stageEditorReachRadii2")).append(" ").append(ChatColor.AQUA)
2021-12-06 10:58:41 +01:00
.append(names.get(i)).append(ChatColor.GRAY).append(" (").append(ChatColor.DARK_AQUA)
.append(locations.get(i)).append(ChatColor.GRAY).append(")");
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 7:
if (context.getSessionData(stagePrefix + Key.S_PASSWORD_PHRASES) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
final LinkedList<String> passPhrases
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_PASSWORD_PHRASES);
2020-08-06 11:32:43 +02:00
final LinkedList<String> passDisplays
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS);
2021-10-07 10:36:57 +02:00
if (passPhrases != null && passDisplays != null) {
for (int i = 0; i < passDisplays.size(); i++) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.AQUA).append(" - \"").append(passDisplays.get(i))
.append("\"\n").append(ChatColor.DARK_AQUA).append(" - ")
.append(passPhrases.get(i));
2021-10-07 10:36:57 +02:00
}
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 8:
if (context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
final LinkedList<String> customObj
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES);
2021-10-07 10:36:57 +02:00
if (customObj != null) {
for (final String s : customObj) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.LIGHT_PURPLE).append(" - ").append(s);
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 9:
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
} else if (context.getSessionData(stagePrefix + Key.S_START_EVENT) == null
&& context.getSessionData(stagePrefix + Key.S_FINISH_EVENT) == null
&& context.getSessionData(stagePrefix + Key.S_DEATH_EVENT) == null
&& context.getSessionData(stagePrefix + Key.S_DISCONNECT_EVENT) == null
&& context.getSessionData(stagePrefix + Key.S_CHAT_EVENTS) == null
&& context.getSessionData(stagePrefix + Key.S_COMMAND_EVENTS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return "";
}
case 10:
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
} else if (context.getSessionData(stagePrefix + Key.S_CONDITION) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return "";
}
case 11:
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
} else {
if (context.getSessionData(stagePrefix + Key.S_DELAY) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2019-10-04 01:48:35 +02:00
} else {
final Long time = (Long) context.getSessionData(stagePrefix + Key.S_DELAY);
2021-10-07 10:36:57 +02:00
if (time == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2021-10-07 10:36:57 +02:00
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + BukkitMiscUtil.getTime(time) + ChatColor.GRAY + ")";
2021-10-07 10:36:57 +02:00
}
}
}
case 12:
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
} else if (context.getSessionData(stagePrefix + Key.S_DELAY) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noDelaySet") + ")";
} else if (context.getSessionData(stagePrefix + Key.S_DELAY_MESSAGE) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
+ context.getSessionData(stagePrefix + Key.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 13:
if (context.getSessionData(stagePrefix + Key.S_START_MESSAGE) == null) {
2019-10-04 01:48:35 +02:00
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
} else {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2019-10-04 01:48:35 +02:00
}
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
+ context.getSessionData(stagePrefix + Key.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 14:
if (context.getSessionData(stagePrefix + Key.S_COMPLETE_MESSAGE) == null) {
2019-10-04 01:48:35 +02:00
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
2019-10-04 01:48:35 +02:00
} else {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2019-10-04 01:48:35 +02:00
}
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
+ context.getSessionData(stagePrefix + Key.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 15:
if (context.getSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + BukkitLang.get("stageEditorOptional") + ")";
2019-10-04 01:48:35 +02:00
} else {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2019-10-04 01:48:35 +02:00
}
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
if (stagePrefix != null) {
final List<String> overrides
= (List<String>) context.getSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY);
2021-10-07 10:36:57 +02:00
if (overrides != null) {
2021-10-07 10:41:56 +02:00
for (final String override : overrides) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
.append(override);
2021-10-07 10:36:57 +02:00
}
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 16:
case 17:
return "";
default:
return null;
2019-10-04 01:48:35 +02:00
}
}
@SuppressWarnings("unchecked")
2019-10-04 01:48:35 +02:00
@Override
public @NotNull String getBasicPromptText(final ConversationContext context) {
final String input = (String) context.getSessionData(classPrefix + "-override");
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
if (input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY, null);
} else {
2021-10-07 10:36:57 +02:00
final LinkedList<String> overrides = new LinkedList<>();
if (context.getSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY) != null) {
overrides.addAll((List<String>) context.getSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY));
}
overrides.add(input);
context.setSessionData(stagePrefix + Key.S_OVERRIDE_DISPLAY, overrides);
context.setSessionData(classPrefix + "-override", null);
}
}
context.setSessionData(stagePrefix, Boolean.TRUE);
2019-10-04 01:48:35 +02:00
checkObjective(context);
2021-10-07 10:36:57 +02:00
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2019-10-04 01:48:35 +02:00
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + "- " + ChatColor.AQUA
+ getTitle(context).replaceFirst(" \\| ", ChatColor.LIGHT_PURPLE + " | ") + " -");
2019-10-04 01:48:35 +02:00
for (int i = 1; i <= size; i++) {
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)).append(" ")
.append(getAdditionalText(context, i));
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
2019-10-04 01:48:35 +02:00
switch (input.intValue()) {
case 1:
2023-02-27 01:05:39 +01:00
return new QuestBlocksPrompt(stageNum, context);
case 2:
2023-02-27 01:05:39 +01:00
return new QuestItemsPrompt(stageNum, context);
case 3:
2023-02-27 01:05:39 +01:00
return new QuestNpcsPrompt(stageNum, context);
case 4:
2023-02-27 01:05:39 +01:00
return new QuestMobsPrompt(stageNum, context);
case 5:
2023-02-27 01:05:39 +01:00
return new QuestKillPlayerPrompt(context);
case 6:
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
case 7:
2023-02-27 01:05:39 +01:00
return new QuestPasswordListPrompt(context);
case 8:
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectiveModulePrompt(context);
case 9:
if (hasObjective) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
case 10:
if (hasObjective) {
2023-02-27 01:05:39 +01:00
return new QuestConditionListPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
case 11:
if (hasObjective) {
2023-02-27 01:05:39 +01:00
return new QuestDelayPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
case 12:
if (context.getSessionData(stagePrefix + Key.S_DELAY) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorNoDelaySet"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else {
2023-02-27 01:05:39 +01:00
return new QuestDelayMessagePrompt(context);
}
case 13:
if (hasObjective) {
2023-02-27 01:05:39 +01:00
return new QuestStartMessagePrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
case 14:
if (hasObjective) {
2023-02-27 01:05:39 +01:00
return new QuestCompleteMessagePrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
case 15:
if (hasObjective) {
return new OverridePrompt.Builder()
.source(this)
.promptText(BukkitLang.get("overrideCreateEnter"))
.build();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
case 16:
2023-02-27 01:05:39 +01:00
return new QuestStageDeletePrompt(context);
case 17:
2023-02-27 01:05:39 +01:00
return new QuestStageMenuPrompt(context);
default:
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2020-08-06 11:32:43 +02:00
public boolean checkObjective(final ConversationContext context) {
if (context.getSessionData(stagePrefix + Key.S_BREAK_NAMES) != null
|| context.getSessionData(stagePrefix + Key.S_DAMAGE_NAMES) != null
|| context.getSessionData(stagePrefix + Key.S_PLACE_NAMES) != null
|| context.getSessionData(stagePrefix + Key.S_USE_NAMES) != null
|| context.getSessionData(stagePrefix + Key.S_CUT_NAMES) != null
|| context.getSessionData(stagePrefix + Key.S_CRAFT_ITEMS) != null
|| context.getSessionData(stagePrefix + Key.S_SMELT_ITEMS) != null
|| context.getSessionData(stagePrefix + Key.S_ENCHANT_ITEMS) != null
|| context.getSessionData(stagePrefix + Key.S_BREW_ITEMS) != null
|| context.getSessionData(stagePrefix + Key.S_CONSUME_ITEMS) != null
|| context.getSessionData(stagePrefix + Key.S_DELIVERY_NPCS) != null
|| context.getSessionData(stagePrefix + Key.S_NPCS_TO_TALK_TO) != null
|| context.getSessionData(stagePrefix + Key.S_NPCS_TO_KILL) != null
|| context.getSessionData(stagePrefix + Key.S_MOB_TYPES) != null
|| context.getSessionData(stagePrefix + Key.S_FISH) != null
|| context.getSessionData(stagePrefix + Key.S_COW_MILK) != null
|| context.getSessionData(stagePrefix + Key.S_TAME_TYPES) != null
|| context.getSessionData(stagePrefix + Key.S_SHEAR_COLORS) != null
|| context.getSessionData(stagePrefix + Key.S_PLAYER_KILL) != null
|| context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS) != null
|| context.getSessionData(stagePrefix + Key.S_PASSWORD_PHRASES) != null
|| context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES) != null) {
2019-10-04 01:48:35 +02:00
hasObjective = true;
return true;
2019-10-04 01:48:35 +02:00
}
return false;
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
public class QuestKillPlayerPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestKillPlayerPrompt(final ConversationContext context) {
super(context);
2019-10-04 01:48:35 +02:00
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
2019-10-04 01:48:35 +02:00
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorKillPlayerPrompt");
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
2019-10-04 01:48:35 +02:00
try {
2020-08-06 11:32:43 +02:00
final int i = Integer.parseInt(input);
2019-10-04 01:48:35 +02:00
if (i < 0) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorPositiveAmount"));
2023-02-27 01:05:39 +01:00
return new QuestKillPlayerPrompt(context);
2019-10-04 01:48:35 +02:00
} else if (i > 0) {
context.setSessionData(stagePrefix + Key.S_PLAYER_KILL, i);
2019-10-04 01:48:35 +02:00
}
2020-08-06 11:32:43 +02:00
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("reqNotANumber")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestKillPlayerPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_PLAYER_KILL, null);
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
public class QuestReachListPrompt extends QuestsEditorNumericPrompt {
2019-10-04 01:48:35 +02:00
2023-02-27 01:05:39 +01:00
public QuestReachListPrompt(final ConversationContext context) {
super(context);
2019-10-04 01:48:35 +02:00
}
private final int size = 5;
2020-08-06 11:32:43 +02:00
@Override
public int getSize() {
return size;
}
2020-08-06 11:32:43 +02:00
@Override
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorReachLocs");
}
2020-08-06 11:32:43 +02:00
@Override
public ChatColor getNumberColor(final ConversationContext context, final int number) {
switch (number) {
case 1:
case 2:
case 3:
return ChatColor.BLUE;
case 4:
return ChatColor.RED;
case 5:
return ChatColor.GREEN;
default:
return null;
}
}
2020-08-06 11:32:43 +02:00
@Override
public String getSelectionText(final ConversationContext context, final int number) {
switch(number) {
case 1:
return ChatColor.YELLOW + BukkitLang.get("stageEditorSetLocations");
case 2:
return ChatColor.YELLOW + BukkitLang.get("stageEditorSetLocationRadii");
case 3:
return ChatColor.YELLOW + BukkitLang.get("stageEditorSetLocationNames");
case 4:
return ChatColor.RED + BukkitLang.get("clear");
case 5:
return ChatColor.GREEN + BukkitLang.get("done");
default:
return null;
}
}
2020-08-06 11:32:43 +02:00
@Override
@SuppressWarnings("unchecked")
2020-08-06 11:32:43 +02:00
public String getAdditionalText(final ConversationContext context, final int number) {
switch(number) {
case 1:
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
final List<String> locations
= (List<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS);
2021-10-07 10:36:57 +02:00
if (locations != null) {
for (final String s : locations) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.DARK_AQUA)
.append(s);
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
case 2:
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2019-10-04 01:48:35 +02:00
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
final List<Integer> radius
= (List<Integer>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS);
2021-10-07 10:36:57 +02:00
if (radius != null) {
for (final Integer i : radius) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(i);
2021-10-07 10:36:57 +02:00
}
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
case 3:
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
2019-10-04 01:48:35 +02:00
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
final List<String> names
= (List<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES);
2021-10-07 10:36:57 +02:00
if (names != null) {
for (final String s : names) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA).append(s);
2021-10-07 10:36:57 +02:00
}
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
case 4:
case 5:
return "";
default:
return null;
2019-10-04 01:48:35 +02:00
}
}
@Override
public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2019-10-04 01:48:35 +02:00
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -");
for (int i = 1; i <= size; i++) {
2021-10-07 10:36:57 +02:00
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)).append(" ")
.append(getAdditionalText(context, i));
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
2019-10-04 01:48:35 +02:00
@SuppressWarnings("unchecked")
@Override
2021-10-07 10:36:57 +02:00
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
switch(input.intValue()) {
case 1:
2020-12-04 10:27:33 +01:00
if (context.getForWhom() instanceof Player) {
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
temp.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getQuestFactory().setSelectedReachLocations(temp);
2023-02-27 01:05:39 +01:00
return new QuestReachLocationPrompt(context);
2020-12-04 10:27:33 +01:00
} else {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("consoleError"));
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2020-12-04 10:27:33 +01:00
}
case 2:
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorNoLocations"));
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestReachRadiiPrompt(context);
2019-10-04 01:48:35 +02:00
}
case 3:
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorNoLocations"));
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestReachNamesPrompt(context);
2019-10-04 01:48:35 +02:00
}
case 4:
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorObjectiveCleared"));
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS, null);
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS, null);
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES, null);
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
case 5:
2021-10-07 10:41:56 +02:00
final int one;
final int two;
final int three;
2021-10-07 10:36:57 +02:00
final List<String> locations
= (List<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS);
2021-10-07 10:36:57 +02:00
final List<Integer> radius
= (List<Integer>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS);
2021-10-07 10:36:57 +02:00
final List<String> names
= (List<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES);
2021-10-07 10:36:57 +02:00
if (locations != null) {
one = locations.size();
2019-10-04 01:48:35 +02:00
} else {
one = 0;
}
2021-10-07 10:36:57 +02:00
if (radius != null) {
two = radius.size();
2019-10-04 01:48:35 +02:00
} else {
two = 0;
}
2021-10-07 10:36:57 +02:00
if (names != null) {
three = names.size();
2019-10-04 01:48:35 +02:00
} else {
three = 0;
}
if (one == two && two == three) {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("listsNotSameSize"));
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2019-10-04 01:48:35 +02:00
}
default:
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
}
2019-10-04 01:48:35 +02:00
2023-02-27 01:05:39 +01:00
public class QuestReachLocationPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestReachLocationPrompt(final ConversationContext context) {
super(context);
2019-10-04 01:48:35 +02:00
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
2019-10-04 01:48:35 +02:00
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorReachLocationPrompt");
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@SuppressWarnings("unchecked")
@Override
2020-08-06 11:32:43 +02:00
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdAdd"))) {
2020-08-06 11:32:43 +02:00
final Block block = plugin.getQuestFactory().getSelectedReachLocations().get(player.getUniqueId());
2019-10-04 01:48:35 +02:00
if (block != null) {
2020-08-06 11:32:43 +02:00
final Location loc = block.getLocation();
2022-05-04 12:16:25 +02:00
final LinkedList<String> locations
= context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS) != null
? (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS)
2022-05-04 12:16:25 +02:00
: new LinkedList<>();
2021-10-07 10:36:57 +02:00
if (locations != null) {
locations.add(BukkitConfigUtil.getLocationInfo(loc));
2019-10-04 01:48:35 +02:00
}
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS, locations);
2022-05-04 12:16:25 +02:00
LinkedList<Integer> amounts = new LinkedList<>();
LinkedList<String> names = new LinkedList<>();
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS) != null) {
amounts = (LinkedList<Integer>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS);
2022-05-04 12:16:25 +02:00
}
if (context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES) != null) {
names = (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES);
2022-05-04 12:16:25 +02:00
}
if (locations != null && amounts != null && names != null) {
for (int i = 0; i < locations.size(); i++) {
if (i >= amounts.size()) {
amounts.add(5);
}
if (i >= names.size()) {
names.add(BukkitLang.get("location").replace("<id>", "#" + (i + 1)));
2022-05-04 12:16:25 +02:00
}
}
}
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS, amounts);
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES, names);
2019-10-04 01:48:35 +02:00
} else {
player.sendMessage(ChatColor.RED + BukkitLang.get("stageEditorNoBlockSelected"));
2023-02-27 01:05:39 +01:00
return new QuestReachLocationPrompt(context);
2019-10-04 01:48:35 +02:00
}
2022-05-04 12:16:25 +02:00
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
temp.remove(player.getUniqueId());
plugin.getQuestFactory().setSelectedReachLocations(temp);
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2020-08-06 11:32:43 +02:00
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
2019-10-04 01:48:35 +02:00
temp.remove(player.getUniqueId());
plugin.getQuestFactory().setSelectedReachLocations(temp);
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestReachLocationPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestReachRadiiPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestReachRadiiPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorReachLocationRadiiPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-12-06 10:58:41 +01:00
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2021-10-07 10:36:57 +02:00
final LinkedList<Integer> radii = new LinkedList<>();
2020-08-06 11:32:43 +02:00
for (final String s : input.split(" ")) {
2019-10-04 01:48:35 +02:00
try {
2020-08-06 11:32:43 +02:00
final int i = Integer.parseInt(s);
2019-10-04 01:48:35 +02:00
if (i < 1) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidMinimum")
.replace("<number>", "1"));
2023-02-27 01:05:39 +01:00
return new QuestReachRadiiPrompt(context);
2019-10-04 01:48:35 +02:00
}
radii.add(i);
2020-08-06 11:32:43 +02:00
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("reqNotANumber")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestReachRadiiPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS_RADIUS, radii);
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
public class QuestReachNamesPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestReachNamesPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorReachLocationNamesPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
final LinkedList<String> locNames = new LinkedList<>(Arrays.asList(input.split(BukkitLang.get("charSemi"))));
context.setSessionData(stagePrefix + Key.S_REACH_LOCATIONS_NAMES, locNames);
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestReachListPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
public class QuestPasswordListPrompt extends QuestsEditorNumericPrompt {
2023-02-27 01:05:39 +01:00
public QuestPasswordListPrompt(final ConversationContext context) {
super(context);
}
private final int size = 4;
2020-08-06 11:32:43 +02:00
@Override
public int getSize() {
return size;
}
2020-08-06 11:32:43 +02:00
@Override
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorPassword");
}
2020-08-06 11:32:43 +02:00
@Override
public ChatColor getNumberColor(final ConversationContext context, final int number) {
switch (number) {
case 1:
case 2:
return ChatColor.BLUE;
case 3:
return ChatColor.RED;
case 4:
return ChatColor.GREEN;
default:
return null;
}
}
2020-08-06 11:32:43 +02:00
@Override
public String getSelectionText(final ConversationContext context, final int number) {
switch(number) {
case 1:
return ChatColor.YELLOW + BukkitLang.get("stageEditorAddPasswordDisplay");
case 2:
return ChatColor.YELLOW + BukkitLang.get("stageEditorAddPasswordPhrases");
case 3:
return ChatColor.RED + BukkitLang.get("clear");
case 4:
return ChatColor.GREEN + BukkitLang.get("done");
default:
return null;
}
}
2020-08-06 11:32:43 +02:00
@Override
@SuppressWarnings("unchecked")
2020-08-06 11:32:43 +02:00
public String getAdditionalText(final ConversationContext context, final int number) {
switch(number) {
case 1:
if (context.getSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
final List<String> displays = (List<String>) context.getSessionData(stagePrefix
+ Key.S_PASSWORD_DISPLAYS);
2021-10-07 10:36:57 +02:00
if (displays != null) {
for (final String display : displays) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
.append(display);
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 2:
if (context.getSessionData(stagePrefix + Key.S_PASSWORD_PHRASES) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2021-10-07 10:36:57 +02:00
final List<String> phrases = (List<String>) context.getSessionData(stagePrefix
+ Key.S_PASSWORD_PHRASES);
2021-10-07 10:36:57 +02:00
if (phrases != null) {
for (final String phrase : phrases) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.DARK_AQUA)
.append(phrase);
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 3:
case 4:
return "";
default:
return null;
}
}
@Override
public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2019-10-04 01:48:35 +02:00
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -");
for (int i = 1; i <= size; i++) {
2021-10-07 10:36:57 +02:00
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)).append(" ")
.append(getAdditionalText(context, i));
}
2021-10-07 10:36:57 +02:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
@SuppressWarnings("unchecked")
@Override
2021-10-07 10:36:57 +02:00
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
switch(input.intValue()) {
case 1:
2023-02-27 01:05:39 +01:00
return new QuestPasswordDisplayPrompt(context);
case 2:
if (context.getSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorMustSetPasswordDisplays"));
2023-02-27 01:05:39 +01:00
return new QuestPasswordListPrompt(context);
} else {
2023-02-27 01:05:39 +01:00
return new QuestPasswordPhrasePrompt(context);
}
case 3:
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorObjectiveCleared"));
context.setSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS, null);
context.setSessionData(stagePrefix + Key.S_PASSWORD_PHRASES, null);
2023-02-27 01:05:39 +01:00
return new QuestPasswordListPrompt(context);
case 4:
2021-10-07 10:41:56 +02:00
final int one;
final int two;
2021-10-07 10:36:57 +02:00
final List<String> displays
= (List<String>) context.getSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS);
final List<String> phrases = (List<String>) context.getSessionData(stagePrefix + Key.S_PASSWORD_PHRASES);
2021-10-07 10:36:57 +02:00
if (displays != null) {
one = displays.size();
} else {
one = 0;
}
2021-10-07 10:36:57 +02:00
if (phrases != null) {
two = phrases.size();
} else {
two = 0;
}
if (one == two) {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("listsNotSameSize"));
2023-02-27 01:05:39 +01:00
return new QuestPasswordListPrompt(context);
}
default:
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestPasswordDisplayPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestPasswordDisplayPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorPasswordDisplayPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context) + "\n";
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
if (context.getSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS) != null) {
@SuppressWarnings("unchecked")
final List<String> displays = (List<String>) context.getSessionData(stagePrefix
+ Key.S_PASSWORD_DISPLAYS);
2021-10-07 10:36:57 +02:00
if (displays != null) {
displays.addAll(Arrays.asList(input.split(BukkitLang.get("charSemi"))));
2021-10-07 10:36:57 +02:00
}
context.setSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS, displays);
} else {
final List<String> displays = new LinkedList<>(Arrays.asList(input.split(BukkitLang.get("charSemi"))));
context.setSessionData(stagePrefix + Key.S_PASSWORD_DISPLAYS, displays);
}
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestPasswordListPrompt(context);
}
}
2023-02-27 01:05:39 +01:00
public class QuestPasswordPhrasePrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestPasswordPhrasePrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorPasswordPhrasePrompt");
}
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context) + "\n";
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
if (context.getSessionData(stagePrefix + Key.S_PASSWORD_PHRASES) != null) {
@SuppressWarnings("unchecked")
final List<String> phrases = (List<String>) context.getSessionData(stagePrefix
+ Key.S_PASSWORD_PHRASES);
2021-10-07 10:36:57 +02:00
if (phrases != null) {
phrases.addAll(Arrays.asList(input.split(BukkitLang.get("charSemi"))));
2021-10-07 10:36:57 +02:00
}
context.setSessionData(stagePrefix + Key.S_PASSWORD_PHRASES, phrases);
} else {
final List<String> phrases = new LinkedList<>(Arrays.asList(input.split(BukkitLang.get("charSemi"))));
context.setSessionData(stagePrefix + Key.S_PASSWORD_PHRASES, phrases);
}
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestPasswordListPrompt(context);
}
}
2023-02-27 01:05:39 +01:00
public class QuestActionListPrompt extends QuestsEditorNumericPrompt {
2023-02-27 01:05:39 +01:00
public QuestActionListPrompt(final ConversationContext context) {
super(context);
}
private final int size = 8;
2020-08-06 11:32:43 +02:00
@Override
public int getSize() {
return size;
}
2020-08-06 11:32:43 +02:00
@Override
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorStageEvents");
}
2020-08-06 11:32:43 +02:00
@Override
public ChatColor getNumberColor(final ConversationContext context, final int number) {
switch (number) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
return ChatColor.BLUE;
case 8:
return ChatColor.GREEN;
default:
return null;
2019-10-04 01:48:35 +02:00
}
}
2020-08-06 11:32:43 +02:00
@Override
public String getSelectionText(final ConversationContext context, final int number) {
switch(number) {
case 1:
return ChatColor.YELLOW + BukkitLang.get("stageEditorStartEvent");
case 2:
return ChatColor.YELLOW + BukkitLang.get("stageEditorFinishEvent");
case 3:
return ChatColor.YELLOW + BukkitLang.get("stageEditorFailEvent");
case 4:
return ChatColor.YELLOW + BukkitLang.get("stageEditorDeathEvent");
case 5:
return ChatColor.YELLOW + BukkitLang.get("stageEditorDisconnectEvent");
case 6:
return ChatColor.YELLOW + BukkitLang.get("stageEditorChatEvents");
case 7:
return ChatColor.YELLOW + BukkitLang.get("stageEditorCommandEvents");
case 8:
return ChatColor.GREEN + BukkitLang.get("done");
default:
return null;
}
}
2020-08-06 11:32:43 +02:00
@Override
@SuppressWarnings("unchecked")
2020-08-06 11:32:43 +02:00
public String getAdditionalText(final ConversationContext context, final int number) {
switch(number) {
case 1:
if (context.getSessionData(stagePrefix + Key.S_START_EVENT) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-10-07 10:36:57 +02:00
return ChatColor.YELLOW + "(" + ChatColor.AQUA + context.getSessionData(stagePrefix
+ Key.S_START_EVENT) + ChatColor.YELLOW + ")";
}
case 2:
if (context.getSessionData(stagePrefix + Key.S_FINISH_EVENT) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-10-07 10:36:57 +02:00
return ChatColor.YELLOW + "(" + ChatColor.AQUA + context.getSessionData(stagePrefix
+ Key.S_FINISH_EVENT) + ChatColor.YELLOW + ")";
}
case 3:
if (context.getSessionData(stagePrefix + Key.S_FAIL_EVENT) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-10-07 10:36:57 +02:00
return ChatColor.YELLOW + "(" + ChatColor.AQUA + context.getSessionData(stagePrefix
+ Key.S_FAIL_EVENT) + ChatColor.YELLOW + ")";
}
case 4:
if (context.getSessionData(stagePrefix + Key.S_DEATH_EVENT) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-10-07 10:36:57 +02:00
return ChatColor.YELLOW + "(" + ChatColor.AQUA + context.getSessionData(stagePrefix
+ Key.S_DEATH_EVENT) + ChatColor.YELLOW + ")";
}
case 5:
if (context.getSessionData(stagePrefix + Key.S_DISCONNECT_EVENT) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-10-07 10:36:57 +02:00
return ChatColor.YELLOW + "(" + ChatColor.AQUA + context.getSessionData(stagePrefix
+ Key.S_DISCONNECT_EVENT) + ChatColor.YELLOW + ")";
}
case 6:
if (context.getSessionData(stagePrefix + Key.S_CHAT_EVENTS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
final LinkedList<String> chatEvents = (LinkedList<String>) context.getSessionData(stagePrefix
+ Key.S_CHAT_EVENTS);
2020-08-06 11:32:43 +02:00
final LinkedList<String> chatEventTriggers
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_CHAT_EVENT_TRIGGERS);
2021-10-07 10:36:57 +02:00
if (chatEvents != null && chatEventTriggers != null) {
for (final String event : chatEvents) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.AQUA).append(" - ").append(event)
.append(ChatColor.BLUE).append(" (").append(BukkitLang.get("stageEditorTriggeredBy"))
2021-12-06 10:58:41 +01:00
.append(": \"").append(chatEventTriggers.get(chatEvents.indexOf(event)))
.append("\")");
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 7:
if (context.getSessionData(stagePrefix + Key.S_COMMAND_EVENTS) == null) {
return ChatColor.GRAY + "(" + BukkitLang.get("noneSet") + ")";
} else {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder();
2020-08-06 11:32:43 +02:00
final LinkedList<String> commandEvents
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_COMMAND_EVENTS);
2020-08-06 11:32:43 +02:00
final LinkedList<String> commandEventTriggers
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_COMMAND_EVENT_TRIGGERS);
2021-10-07 10:36:57 +02:00
if (commandEvents != null && commandEventTriggers != null) {
for (final String event : commandEvents) {
2021-12-06 10:58:41 +01:00
text.append("\n").append(ChatColor.AQUA).append(" - ").append(event)
.append(ChatColor.BLUE).append(" (").append(BukkitLang.get("stageEditorTriggeredBy"))
2021-12-06 10:58:41 +01:00
.append(": \"").append(commandEventTriggers.get(commandEvents.indexOf(event)))
.append("\")");
2021-10-07 10:36:57 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
case 8:
return "";
default:
return null;
2019-10-04 01:48:35 +02:00
}
}
@Override
public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -");
for (int i = 1; i <= size; i++) {
2021-10-07 10:36:57 +02:00
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)).append(" ")
.append(getAdditionalText(context, i));
}
2021-10-07 10:36:57 +02:00
return text.toString();
}
@Override
2021-10-07 10:36:57 +02:00
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
switch(input.intValue()) {
case 1:
2023-02-27 01:05:39 +01:00
return new QuestStartActionPrompt(context);
case 2:
2023-02-27 01:05:39 +01:00
return new QuestFinishActionPrompt(context);
case 3:
2023-02-27 01:05:39 +01:00
return new QuestFailActionPrompt(context);
case 4:
2023-02-27 01:05:39 +01:00
return new QuestDeathActionPrompt(context);
case 5:
2023-02-27 01:05:39 +01:00
return new QuestDisconnectActionPrompt(context);
case 6:
2023-02-27 01:05:39 +01:00
return new QuestChatActionPrompt(context);
case 7:
2023-02-27 01:05:39 +01:00
return new QuestCommandActionPrompt(context);
case 8:
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
default:
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestStartActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestStartActionPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorStartEvent");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorEventsPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none")).append("\n");
2019-10-04 01:48:35 +02:00
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
2019-10-04 01:48:35 +02:00
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestStartActionPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_START_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_START_EVENT, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorEventCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestStartActionPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestFinishActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestFinishActionPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorFinishEvent");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorEventsPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none"));
2019-10-04 01:48:35 +02:00
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
2019-10-04 01:48:35 +02:00
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestFinishActionPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_FINISH_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_FINISH_EVENT, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorEventCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestFinishActionPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestFailActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestFailActionPrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorFailEvent");
}
@Override
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorEventsPrompt");
}
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none"));
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestFailActionPrompt(context);
} else {
context.setSessionData(stagePrefix + Key.S_FAIL_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_FAIL_EVENT, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorEventCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else {
2023-02-27 01:05:39 +01:00
return new QuestFailActionPrompt(context);
}
}
}
2019-10-04 01:48:35 +02:00
2023-02-27 01:05:39 +01:00
public class QuestDeathActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestDeathActionPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorDeathEvent");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorEventsPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none")).append("\n");
2019-10-04 01:48:35 +02:00
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
2019-10-04 01:48:35 +02:00
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestDeathActionPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_DEATH_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_DEATH_EVENT, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorEventCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestDeathActionPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestDisconnectActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestDisconnectActionPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorDisconnectEvent");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorEventsPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none"));
2019-10-04 01:48:35 +02:00
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2023-02-27 01:05:39 +01:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
2019-10-04 01:48:35 +02:00
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestDisconnectActionPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_DISCONNECT_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_DISCONNECT_EVENT, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorEventCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestDisconnectActionPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestChatActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestChatActionPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorChatEvents");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorChatEventsPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none"));
2019-10-04 01:48:35 +02:00
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2023-02-27 01:05:39 +01:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
2019-10-04 01:48:35 +02:00
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestChatActionPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_CHAT_TEMP_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestChatActionTriggerPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_CHAT_EVENTS, null);
context.setSessionData(stagePrefix + Key.S_CHAT_EVENT_TRIGGERS, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorChatEventsCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestChatActionPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestChatActionTriggerPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestChatActionTriggerPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorChatTrigger");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
final String tempEvent = (String) context.getSessionData(stagePrefix + Key.S_CHAT_TEMP_EVENT);
2021-10-07 10:36:57 +02:00
if (tempEvent != null) {
return BukkitLang.get("stageEditorChatEventsTriggerPrompt").replace("<event>", tempEvent)
2021-10-07 10:36:57 +02:00
.replace("<action>", tempEvent);
} else {
return BukkitLang.get("stageEditorChatEventsTriggerPrompt");
2021-10-07 10:36:57 +02:00
}
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
final String tempEvent = (String) context.getSessionData(stagePrefix + Key.S_CHAT_TEMP_EVENT);
String text = ChatColor.GOLD + "- " + getTitle(context) + " -\n";
2021-10-07 10:36:57 +02:00
if (tempEvent != null) {
text += ChatColor.YELLOW + getQueryText(context)
.replaceFirst(tempEvent, ChatColor.AQUA + tempEvent + ChatColor.YELLOW);
}
2019-10-04 01:48:35 +02:00
return text;
}
@SuppressWarnings("unchecked")
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
if (context.getSessionData(stagePrefix + Key.S_CHAT_EVENTS) == null) {
2021-10-07 10:36:57 +02:00
final LinkedList<String> chatEvents = new LinkedList<>();
final LinkedList<String> chatEventTriggers = new LinkedList<>();
final String event = (String) context.getSessionData(stagePrefix + Key.S_CHAT_TEMP_EVENT);
2019-10-04 01:48:35 +02:00
chatEvents.add(event);
chatEventTriggers.add(input.trim());
context.setSessionData(stagePrefix + Key.S_CHAT_EVENTS, chatEvents);
context.setSessionData(stagePrefix + Key.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2020-08-06 11:32:43 +02:00
final LinkedList<String> chatEvents
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_CHAT_EVENTS);
2020-08-06 11:32:43 +02:00
final LinkedList<String> chatEventTriggers
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_CHAT_EVENT_TRIGGERS);
final String event = (String) context.getSessionData(stagePrefix + Key.S_CHAT_TEMP_EVENT);
2021-10-07 10:36:57 +02:00
if (chatEvents != null && chatEventTriggers != null) {
chatEvents.add(event);
chatEventTriggers.add(input.trim());
context.setSessionData(stagePrefix + Key.S_CHAT_EVENTS, chatEvents);
context.setSessionData(stagePrefix + Key.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
2021-10-07 10:36:57 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestChatActionTriggerPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestCommandActionPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestCommandActionPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorCommandEvents");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorCommandEventsPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:41:56 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none"));
2019-10-04 01:48:35 +02:00
} else {
for (final Action a : plugin.getLoadedActions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
2019-10-04 01:48:35 +02:00
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidEvent")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestCommandActionPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_COMMAND_TEMP_EVENT, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestCommandActionTriggerPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_COMMAND_EVENTS, null);
context.setSessionData(stagePrefix + Key.S_COMMAND_EVENT_TRIGGERS, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorCommandEventsCleared"));
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestCommandActionPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestCommandActionTriggerPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestCommandActionTriggerPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorCommandTrigger");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
final String tempEvent = (String) context.getSessionData(stagePrefix + Key.S_COMMAND_TEMP_EVENT);
2021-10-07 10:36:57 +02:00
if (tempEvent != null) {
return BukkitLang.get("stageEditorCommandEventsTriggerPrompt").replace("<event>", tempEvent)
2021-10-07 10:36:57 +02:00
.replace("<action>", tempEvent);
} else {
return BukkitLang.get("stageEditorCommandEventsTriggerPrompt");
2021-10-07 10:36:57 +02:00
}
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
final String tempEvent = (String) context.getSessionData(stagePrefix + Key.S_COMMAND_TEMP_EVENT);
String text = ChatColor.GOLD + "- " + getTitle(context) + " -\n";
2021-10-07 10:36:57 +02:00
if (tempEvent != null) {
text += ChatColor.YELLOW + getQueryText(context)
.replaceFirst(tempEvent, ChatColor.AQUA + tempEvent + ChatColor.YELLOW);
}
2019-10-04 01:48:35 +02:00
return text;
}
@SuppressWarnings("unchecked")
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
if (context.getSessionData(stagePrefix + Key.S_COMMAND_EVENTS) == null) {
2021-10-07 10:36:57 +02:00
final LinkedList<String> commandEvents = new LinkedList<>();
final LinkedList<String> commandEventTriggers = new LinkedList<>();
final String event = (String) context.getSessionData(stagePrefix + Key.S_COMMAND_TEMP_EVENT);
2019-10-04 01:48:35 +02:00
commandEvents.add(event);
commandEventTriggers.add(input.trim());
context.setSessionData(stagePrefix + Key.S_COMMAND_EVENTS, commandEvents);
context.setSessionData(stagePrefix + Key.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2020-08-06 11:32:43 +02:00
final LinkedList<String> commandEvents
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_COMMAND_EVENTS);
2020-08-06 11:32:43 +02:00
final LinkedList<String> commandEventTriggers
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_COMMAND_EVENT_TRIGGERS);
final String event = (String) context.getSessionData(stagePrefix + Key.S_COMMAND_TEMP_EVENT);
2021-10-07 10:36:57 +02:00
if (commandEvents != null && commandEventTriggers != null) {
commandEvents.add(event);
commandEventTriggers.add(input.trim());
context.setSessionData(stagePrefix + Key.S_COMMAND_EVENTS, commandEvents);
context.setSessionData(stagePrefix + Key.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
2021-10-07 10:36:57 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestActionListPrompt(context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestCommandActionTriggerPrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestConditionListPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestConditionListPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorConditions");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorConditionsPrompt");
}
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:41:56 +02:00
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -\n");
if (plugin.getLoadedConditions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(BukkitLang.get("none")).append("\n");
} else {
for (final Condition c : plugin.getLoadedConditions()) {
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append("- ").append(c.getName()).append("\n");
}
}
2021-10-07 10:36:57 +02:00
return text.toString() + ChatColor.YELLOW + getQueryText(context);
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
Condition found = null;
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
found = c;
break;
}
}
if (found == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorInvalidCondition")
2022-06-11 07:14:16 +02:00
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestConditionListPrompt(context);
} else {
context.setSessionData(stagePrefix + Key.S_CONDITION, found.getName());
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_CONDITION, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorConditionCleared"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else {
2023-02-27 01:05:39 +01:00
return new QuestConditionListPrompt(context);
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestDelayPrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestDelayPrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("timePrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
2023-02-28 04:30:31 +01:00
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null) {
if (input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2021-10-07 10:36:57 +02:00
}
if (input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_DELAY, null);
context.getForWhom().sendRawMessage(ChatColor.GREEN + BukkitLang.get("stageEditorDelayCleared"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2021-10-07 10:36:57 +02:00
}
2021-10-07 10:41:56 +02:00
final long stageDelay;
2021-10-07 10:36:57 +02:00
try {
final int i = Integer.parseInt(input);
stageDelay = i * 1000L;
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("reqNotANumber")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestDelayPrompt(context);
2021-10-07 10:36:57 +02:00
}
if (stageDelay < 1000) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidMinimum")
.replace("<number>", "1"));
2023-02-27 01:05:39 +01:00
return new QuestDelayPrompt(context);
2021-10-07 10:36:57 +02:00
} else {
context.setSessionData(stagePrefix + Key.S_DELAY, stageDelay);
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2021-10-07 10:36:57 +02:00
}
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
public class QuestDelayMessagePrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestDelayMessagePrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorDelayMessagePrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_DELAY_MESSAGE, input);
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_DELAY_MESSAGE, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorMessageCleared"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestDelayMessagePrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2019-10-04 01:48:35 +02:00
2023-02-27 01:05:39 +01:00
public class QuestStartMessagePrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestStartMessagePrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorStartMessagePrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_START_MESSAGE, input);
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_START_MESSAGE, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorMessageCleared"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestCompleteMessagePrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestCompleteMessagePrompt(final ConversationContext context) {
super(context);
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorCompleteMessagePrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
return ChatColor.YELLOW + getQueryText(context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_COMPLETE_MESSAGE, input);
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_COMPLETE_MESSAGE, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorMessageCleared"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestStageDeletePrompt extends QuestsEditorStringPrompt {
2023-02-27 01:05:39 +01:00
public QuestStageDeletePrompt(final ConversationContext context) {
super(context);
}
public final int size = 2;
public int getSize() {
return size;
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return null;
}
2023-02-27 01:05:39 +01:00
@SuppressWarnings("unused")
public ChatColor getNumberColor(final ConversationContext context, final int number) {
switch (number) {
case 1:
return ChatColor.GREEN;
case 2:
return ChatColor.RED;
default:
return null;
}
}
2023-02-27 01:05:39 +01:00
@SuppressWarnings("unused")
public String getSelectionText(final ConversationContext context, final int number) {
switch (number) {
case 1:
return ChatColor.GREEN + BukkitLang.get("yesWord");
case 2:
return ChatColor.RED + BukkitLang.get("noWord");
default:
return null;
}
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("confirmDelete");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
2021-10-07 10:36:57 +02:00
final StringBuilder text = new StringBuilder(ChatColor.YELLOW + getQueryText(context) + " ("
+ ChatColor.RED + BukkitLang.get("stageEditorStage") + " " + stageNum + ChatColor.YELLOW + ")\n"
+ ChatColor.GOLD + "(" + BukkitLang.get("stageEditorConfirmStageNote") + ")\n");
for (int i = 1; i <= size; i++) {
2021-10-07 10:36:57 +02:00
text.append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i).append(ChatColor.RESET)
.append(" - ").append(getSelectionText(context, i)).append("\n");
}
return QuestsNumericPrompt.sendClickableSelection(text.toString(), context);
2019-10-04 01:48:35 +02:00
}
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(BukkitLang.get("yesWord")))) {
2023-02-27 01:05:39 +01:00
new QuestStageMenuPrompt(context).deleteStage(context, stageNum);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorDeleteSucces"));
2023-02-27 01:05:39 +01:00
return new QuestStageMenuPrompt(context);
} else if (input != null && (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(BukkitLang.get("noWord")))) {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("invalidOption"));
2023-02-27 01:05:39 +01:00
return new QuestStageDeletePrompt(context);
2019-10-04 01:48:35 +02:00
}
}
}
2023-02-27 01:05:39 +01:00
public class QuestCustomObjectiveModulePrompt extends QuestsEditorStringPrompt {
2021-10-09 08:38:57 +02:00
2023-02-27 01:05:39 +01:00
public QuestCustomObjectiveModulePrompt(final ConversationContext context) {
2021-10-09 08:38:57 +02:00
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return BukkitLang.get("stageEditorModules");
2021-10-09 08:38:57 +02:00
}
@Override
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorModulePrompt");
2021-10-09 08:38:57 +02:00
}
@Override
public @NotNull String getPromptText(@NotNull final ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
2022-01-04 07:15:52 +01:00
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
if (plugin.getCustomObjectives().isEmpty()) {
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
.append("https://pikamug.gitbook.io/quests/casual/modules").append(ChatColor.RESET)
.append("\n");
text.append(ChatColor.RED).append("(").append(BukkitLang.get("stageEditorNoModules")).append(")")
2022-04-22 10:25:15 +02:00
.append("\n");
2022-01-04 07:15:52 +01:00
} else {
for (final String name : plugin.getCustomObjectives().stream().map(CustomObjective::getModuleName)
2022-01-04 07:15:52 +01:00
.collect(Collectors.toCollection(TreeSet::new))) {
text.append(ChatColor.DARK_PURPLE).append(" - ").append(name).append("\n");
}
}
return text.toString() + ChatColor.YELLOW + getQueryText(context);
}
final TextComponent component = new TextComponent(getTitle(context) + "\n");
component.setColor(net.md_5.bungee.api.ChatColor.LIGHT_PURPLE);
final TextComponent line = new TextComponent("");
2021-10-09 08:38:57 +02:00
if (plugin.getCustomObjectives().isEmpty()) {
2022-01-04 07:15:52 +01:00
final TextComponent link = new TextComponent("https://pikamug.gitbook.io/quests/casual/modules\n");
link.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
link.setUnderlined(true);
line.addExtra(link);
line.addExtra(ChatColor.RED + "(" + BukkitLang.get("stageEditorNoModules") + ")\n");
2021-10-09 08:38:57 +02:00
} else {
for (final String name : plugin.getCustomObjectives().stream().map(CustomObjective::getModuleName)
.collect(Collectors.toCollection(TreeSet::new))) {
2022-01-04 07:15:52 +01:00
final TextComponent click = new TextComponent(ChatColor.DARK_PURPLE + " - " + name + "\n");
click.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + name));
2022-01-04 07:15:52 +01:00
line.addExtra(click);
2021-10-09 08:38:57 +02:00
}
}
2022-01-04 07:15:52 +01:00
component.addExtra(line);
component.addExtra(ChatColor.YELLOW + getQueryText(context));
((Player)context.getForWhom()).spigot().sendMessage(component);
return "";
2021-10-09 08:38:57 +02:00
}
@Override
public Prompt acceptInput(@NotNull final ConversationContext context, @Nullable final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
2021-10-09 08:38:57 +02:00
String found = null;
// Check if we have a module with the specified name
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-09 08:38:57 +02:00
if (co.getModuleName().equalsIgnoreCase(input)) {
found = co.getModuleName();
break;
}
}
if (found == null) {
// No? Check again, but with locale sensitivity
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-09 08:38:57 +02:00
if (co.getModuleName().toLowerCase().contains(input.toLowerCase())) {
found = co.getModuleName();
break;
}
}
}
if (found != null) {
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectivesPrompt(found, context);
2021-10-09 08:38:57 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))) {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES, null);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA, null);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorCustomCleared"));
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2021-10-09 08:38:57 +02:00
}
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorModuleNotFound"));
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectiveModulePrompt(context);
2021-10-09 08:38:57 +02:00
}
}
2023-02-27 01:05:39 +01:00
public class QuestCustomObjectivesPrompt extends QuestsEditorStringPrompt {
2021-10-09 08:38:57 +02:00
private final String moduleName;
2023-02-27 01:05:39 +01:00
public QuestCustomObjectivesPrompt(final String moduleName, final ConversationContext context) {
super(context);
2021-10-09 08:38:57 +02:00
this.moduleName = moduleName;
}
2021-10-10 02:48:08 +02:00
public String getModuleName() {
return moduleName;
}
@Override
2020-08-06 11:32:43 +02:00
public String getTitle(final ConversationContext context) {
return BukkitLang.get("customObjectivesTitle");
}
@Override
2020-08-06 11:32:43 +02:00
public String getQueryText(final ConversationContext context) {
return BukkitLang.get("stageEditorCustomPrompt");
}
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
2023-02-28 04:30:31 +01:00
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
if (!(context.getForWhom() instanceof Player) || !plugin.getConfigSettings().canClickablePrompts()) {
2022-01-04 07:15:52 +01:00
final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + "- " + getTitle(context)
+ " -\n");
if (plugin.getCustomObjectives().isEmpty()) {
text.append(ChatColor.DARK_AQUA).append(ChatColor.UNDERLINE)
.append("https://pikamug.gitbook.io/quests/casual/modules\n");
text.append(ChatColor.RED).append("(").append(BukkitLang.get("stageEditorNoModules")).append(")\n");
2022-01-04 07:15:52 +01:00
} else {
for (final CustomObjective co : plugin.getCustomObjectives()) {
2022-01-04 07:15:52 +01:00
if (co.getModuleName().equals(moduleName)) {
text.append(ChatColor.DARK_PURPLE).append(" - ").append(co.getName()).append("\n");
}
}
}
return text.toString() + ChatColor.YELLOW + getQueryText(context);
}
final TextComponent component = new TextComponent(getTitle(context) + "\n");
component.setColor(net.md_5.bungee.api.ChatColor.LIGHT_PURPLE);
final TextComponent line = new TextComponent("");
2019-10-04 01:48:35 +02:00
if (plugin.getCustomObjectives().isEmpty()) {
2022-01-04 07:15:52 +01:00
final TextComponent link = new TextComponent("https://pikamug.gitbook.io/quests/casual/modules\n");
link.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
link.setUnderlined(true);
line.addExtra(link);
line.addExtra(ChatColor.RED + "(" + BukkitLang.get("stageEditorNoModules") + ")\n");
2019-10-04 01:48:35 +02:00
} else {
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-09 08:38:57 +02:00
if (co.getModuleName().equals(moduleName)) {
2022-01-04 07:15:52 +01:00
final TextComponent click = new TextComponent(ChatColor.DARK_PURPLE + " - " + co.getName()
+ "\n");
click.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice "
+ co.getName()));
2022-01-04 07:15:52 +01:00
line.addExtra(click);
2021-10-09 08:38:57 +02:00
}
2019-10-04 01:48:35 +02:00
}
}
2022-01-04 07:15:52 +01:00
component.addExtra(line);
component.addExtra(ChatColor.YELLOW + getQueryText(context));
((Player)context.getForWhom()).spigot().sendMessage(component);
return "";
2019-10-04 01:48:35 +02:00
}
@SuppressWarnings("unchecked")
@Override
2021-10-07 10:36:57 +02:00
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input != null && !input.equalsIgnoreCase(BukkitLang.get("cmdCancel"))
&& !input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
CustomObjective found = null;
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-09 08:38:57 +02:00
if (co.getModuleName().equals(moduleName)) {
2019-10-04 01:48:35 +02:00
if (co.getName().toLowerCase().contains(input.toLowerCase())) {
found = co;
break;
}
}
}
if (found != null) {
if (context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES) != null) {
2019-10-04 01:48:35 +02:00
// The custom objective may already have been added, so let's check that
final LinkedList<String> list = (LinkedList<String>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES);
2021-10-07 10:36:57 +02:00
final LinkedList<Entry<String, Object>> dataMapList
= (LinkedList<Entry<String, Object>>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_DATA);
final LinkedList<Integer> countList = (LinkedList<Integer>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_COUNT);
2021-10-07 10:36:57 +02:00
if (list != null && !list.contains(found.getName()) && dataMapList != null
&& countList != null) {
2019-10-04 01:48:35 +02:00
// Hasn't been added yet, so let's do it
list.add(found.getName());
2021-10-07 10:36:57 +02:00
dataMapList.addAll(found.getData());
2019-10-04 01:48:35 +02:00
countList.add(-999);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES, list);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA, dataMapList);
2019-10-04 01:48:35 +02:00
} else {
// Already added, so inform user
2021-12-29 14:26:12 +01:00
context.getForWhom().sendRawMessage(ChatColor.RED
+ BukkitLang.get("stageEditorCustomAlreadyAdded"));
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectivesPrompt(moduleName, context);
2019-10-04 01:48:35 +02:00
}
} else {
// The custom objective hasn't been added yet, so let's do it
2021-10-07 10:36:57 +02:00
final LinkedList<Integer> countList = new LinkedList<>();
final LinkedList<Entry<String, Object>> dataMapList = new LinkedList<>(found.getData());
2019-10-04 01:48:35 +02:00
countList.add(-999);
2021-10-07 10:36:57 +02:00
final LinkedList<String> list = new LinkedList<>();
2019-10-04 01:48:35 +02:00
list.add(found.getName());
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES, list);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA, dataMapList);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_COUNT, countList);
2019-10-04 01:48:35 +02:00
}
// Send user to the count prompt / custom data prompt if there is any needed
if (found.canShowCount()) {
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectiveCountPrompt();
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
if (!found.getData().isEmpty()) {
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found
.getDescriptions());
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2019-10-04 01:48:35 +02:00
}
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("stageEditorModuleNotFound"));
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectivesPrompt(moduleName, context);
2019-10-04 01:48:35 +02:00
}
} else if (input != null && input.equalsIgnoreCase(BukkitLang.get("cmdClear"))) {
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES, null);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA, null);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("stageEditorCustomCleared"));
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
private class QuestCustomObjectiveCountPrompt extends StringPrompt {
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final ConversationContext context) {
2021-12-06 10:58:41 +01:00
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- ");
2019-10-04 01:48:35 +02:00
@SuppressWarnings("unchecked")
2021-12-06 10:58:41 +01:00
final LinkedList<String> list
= (LinkedList<String>) context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES);
2021-10-07 10:36:57 +02:00
if (list != null && plugin != null) {
final String objName = list.getLast();
2021-12-06 10:58:41 +01:00
text.append(objName).append(" -\n");
CustomObjective found = null;
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-07 10:36:57 +02:00
if (co.getName().equals(objName)) {
found = co;
break;
}
}
if (found != null) {
2021-12-06 10:58:41 +01:00
text.append(ChatColor.YELLOW).append(found.getCountPrompt());
2019-10-04 01:48:35 +02:00
}
}
2021-12-06 10:58:41 +01:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
@SuppressWarnings("unchecked")
@Override
2020-08-06 11:32:43 +02:00
public Prompt acceptInput(final ConversationContext context, final String input) {
2019-10-04 01:48:35 +02:00
try {
2020-08-06 11:32:43 +02:00
final int num = Integer.parseInt(input);
final LinkedList<Integer> counts
= (LinkedList<Integer>) context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_COUNT);
final LinkedList<String> list = (LinkedList<String>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES);
2021-10-07 10:36:57 +02:00
if (counts != null && list != null && plugin != null) {
counts.set(counts.size() - 1, num);
final String objName = list.getLast();
CustomObjective found = null;
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-07 10:36:57 +02:00
if (co.getName().equals(objName)) {
found = co;
break;
}
}
if (found != null && !found.getData().isEmpty()) {
context.setSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.getDescriptions());
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2021-10-07 10:36:57 +02:00
} else {
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2020-08-06 11:32:43 +02:00
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("reqNotANumber")
.replace("<input>", input));
2023-02-27 01:05:39 +01:00
return new QuestCustomObjectiveCountPrompt();
2019-10-04 01:48:35 +02:00
}
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
private class QuestObjectiveCustomDataListPrompt extends StringPrompt {
2019-10-04 01:48:35 +02:00
@SuppressWarnings("unchecked")
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final ConversationContext context) {
2021-10-07 10:41:56 +02:00
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- ");
final LinkedList<String> list = (LinkedList<String>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES);
2021-10-07 10:36:57 +02:00
final LinkedList<Entry<String, Object>> dataMapList
2021-12-29 14:26:12 +01:00
= (LinkedList<Entry<String, Object>>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_DATA);
2021-10-07 10:36:57 +02:00
if (list != null && plugin != null) {
final String objName = list.getLast();
CustomObjective found = null;
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-07 10:36:57 +02:00
if (co.getName().equals(objName)) {
found = co;
break;
}
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
if (found == null) {
return "Could not find custom objective";
}
text.append(objName).append(" -\n");
int index = 1;
for (final Entry<String, Object> dataMap : found.getData()) {
if (dataMapList != null) {
for (final Entry<String, Object> currentData : dataMapList) {
if (currentData.getKey().equals(dataMap.getKey())) {
text.append(ChatColor.BLUE).append(ChatColor.BOLD).append(index).append(ChatColor.RESET)
.append(ChatColor.YELLOW).append(" - ").append(dataMap.getKey());
if (currentData.getValue() != null) {
text.append(ChatColor.GRAY).append(" (").append(ChatColor.AQUA)
.append(ChatColor.translateAlternateColorCodes('&',
currentData.getValue().toString())).append(ChatColor.GRAY).append(")\n");
} else {
text.append(ChatColor.GRAY).append(" (").append(BukkitLang.get("noneSet"))
2021-10-07 10:36:57 +02:00
.append(ChatColor.GRAY).append(")\n");
}
index++;
}
}
2019-10-04 01:48:35 +02:00
}
}
2021-10-07 10:36:57 +02:00
text.append(ChatColor.GREEN).append(ChatColor.BOLD).append(index).append(ChatColor.YELLOW)
.append(" - ").append(BukkitLang.get("done"));
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
return text.toString();
2019-10-04 01:48:35 +02:00
}
@SuppressWarnings("unchecked")
@Override
2020-08-06 11:32:43 +02:00
public Prompt acceptInput(final ConversationContext context, final String input) {
final LinkedList<String> list = (LinkedList<String>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES);
2021-10-07 10:36:57 +02:00
if (list != null && plugin != null) {
final String objName = list.getLast();
CustomObjective found = null;
for (final CustomObjective co : plugin.getCustomObjectives()) {
2021-10-07 10:36:57 +02:00
if (co.getName().equals(objName)) {
found = co;
break;
}
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
if (found == null) {
plugin.getLogger().severe("Could not find custom objective following input: " + input);
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2021-10-07 10:36:57 +02:00
}
final LinkedList<Entry<String, Object>> dataMapList = found.getData();
2021-10-07 10:41:56 +02:00
final int numInput;
2021-10-07 10:36:57 +02:00
try {
numInput = Integer.parseInt(input);
} catch (final NumberFormatException nfe) {
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2021-10-07 10:36:57 +02:00
}
if (numInput < 1 || numInput > dataMapList.size() + 1) {
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2021-10-07 10:36:57 +02:00
}
if (numInput < dataMapList.size() + 1) {
final LinkedList<String> dataMapKeys = new LinkedList<>();
for (final Entry<String, Object> dataMap : dataMapList) {
dataMapKeys.add(dataMap.getKey());
2019-10-04 01:48:35 +02:00
}
2021-10-07 10:36:57 +02:00
// Collections.sort(dataMapKeys);
final String selectedKey = dataMapKeys.get(numInput - 1);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_TEMP, selectedKey);
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataPrompt();
2021-10-07 10:36:57 +02:00
} else {
final LinkedList<Entry<String, Object>> dataMaps
= (LinkedList<Entry<String, Object>>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_DATA);
2021-10-07 10:36:57 +02:00
if (dataMaps != null) {
for (final Entry<String, Object> dataMap : dataMaps) {
if (dataMap.getValue() == null) {
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2021-10-07 10:36:57 +02:00
}
}
}
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
return new QuestStageMainPrompt(stageNum, context);
2019-10-04 01:48:35 +02:00
}
}
2023-02-27 01:05:39 +01:00
private class QuestObjectiveCustomDataPrompt extends StringPrompt {
2019-10-04 01:48:35 +02:00
@Override
2021-10-07 10:36:57 +02:00
public @NotNull String getPromptText(final ConversationContext context) {
2019-10-04 01:48:35 +02:00
String text = "";
final String temp = (String) context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_TEMP);
2019-10-04 01:48:35 +02:00
@SuppressWarnings("unchecked")
2020-08-06 11:32:43 +02:00
final
Map<String, String> descriptions
= (Map<String, String>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS);
2021-10-07 10:36:57 +02:00
if (descriptions != null && descriptions.get(temp) != null) {
2019-10-04 01:48:35 +02:00
text += ChatColor.GOLD + descriptions.get(temp) + "\n";
}
String msg = BukkitLang.get("stageEditorCustomDataPrompt");
msg = msg.replace("<data>", ChatColor.GOLD + temp + ChatColor.YELLOW);
2019-10-04 01:48:35 +02:00
text += ChatColor.YELLOW + msg;
return text;
}
@Override
2020-08-06 11:32:43 +02:00
public Prompt acceptInput(final ConversationContext context, final String input) {
2019-10-04 01:48:35 +02:00
@SuppressWarnings("unchecked")
2020-08-06 11:32:43 +02:00
final
2021-10-07 10:36:57 +02:00
LinkedList<Entry<String, Object>> dataMapList
2021-12-29 14:26:12 +01:00
= (LinkedList<Entry<String, Object>>) context.getSessionData(stagePrefix
+ Key.S_CUSTOM_OBJECTIVES_DATA);
2021-10-07 10:36:57 +02:00
final LinkedList<Entry<String, Object>> promptList = new LinkedList<>();
final String temp = (String) context.getSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_TEMP);
2021-10-07 10:36:57 +02:00
if (dataMapList != null) {
for (final Entry<String, Object> dataMap : dataMapList) {
if (dataMap.getKey().equals(temp)) {
promptList.add(new AbstractMap.SimpleEntry<>(dataMap.getKey(), input));
} else {
promptList.add(new AbstractMap.SimpleEntry<>(dataMap.getKey(), dataMap.getValue()));
}
2019-10-04 01:48:35 +02:00
}
}
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA, promptList);
context.setSessionData(stagePrefix + Key.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
2023-02-27 01:05:39 +01:00
return new QuestObjectiveCustomDataListPrompt();
2019-10-04 01:48:35 +02:00
}
}
2013-04-08 23:24:44 +02:00
}