mirror of https://github.com/PikaMug/Quests.git
841 lines
35 KiB
Java
841 lines
35 KiB
Java
/*
|
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
package me.blackvein.quests.convo.quests.objectives;
|
|
|
|
import me.blackvein.quests.Quests;
|
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
|
import me.blackvein.quests.convo.quests.stages.QuestStageMainPrompt;
|
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
|
import me.blackvein.quests.util.CK;
|
|
import me.blackvein.quests.util.ItemUtil;
|
|
import me.blackvein.quests.util.Lang;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.conversations.ConversationContext;
|
|
import org.bukkit.conversations.Prompt;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
public class QuestItemsPrompt extends QuestsEditorNumericPrompt {
|
|
|
|
private final Quests plugin;
|
|
private final int stageNum;
|
|
private final String pref;
|
|
|
|
public QuestItemsPrompt(final int stageNum, final ConversationContext context) {
|
|
super(context);
|
|
this.plugin = (Quests)context.getPlugin();
|
|
this.stageNum = stageNum;
|
|
this.pref = "stage" + stageNum;
|
|
}
|
|
|
|
private final int size = 6;
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return size;
|
|
}
|
|
|
|
@Override
|
|
public String getTitle(final ConversationContext context) {
|
|
return Lang.get("stageEditorItems");
|
|
}
|
|
|
|
@Override
|
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
|
switch (number) {
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
return ChatColor.BLUE;
|
|
case 6:
|
|
return ChatColor.GREEN;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSelectionText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorCraftItems");
|
|
case 2:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorSmeltItems");
|
|
case 3:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorEnchantItems");
|
|
case 4:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorBrewPotions");
|
|
case 5:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorConsumeItems");
|
|
case 6:
|
|
return ChatColor.GREEN + Lang.get("done");
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final LinkedList<ItemStack> items
|
|
= (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
|
if (items != null) {
|
|
for (final ItemStack item : items) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
|
|
.append(ItemUtil.getName(item)).append(ChatColor.GRAY).append(" x ")
|
|
.append(ChatColor.AQUA).append(item.getAmount());
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 2:
|
|
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final LinkedList<ItemStack> items
|
|
= (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
|
|
if (items != null) {
|
|
for (final ItemStack item : items) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
|
|
.append(ItemUtil.getName(item)).append(ChatColor.GRAY).append(" x ")
|
|
.append(ChatColor.AQUA).append(item.getAmount());
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 3:
|
|
if (context.getSessionData(pref + CK.S_ENCHANT_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_ENCHANT_ITEMS);
|
|
if (items != null) {
|
|
for (final ItemStack item : items) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
|
|
.append(ItemUtil.getName(item)).append(ChatColor.GRAY).append(" x ")
|
|
.append(ChatColor.AQUA).append(item.getAmount());
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 4:
|
|
if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final LinkedList<ItemStack> items
|
|
= (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
|
|
if (items != null) {
|
|
for (final ItemStack item : items) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
|
|
.append(ItemUtil.getName(item)).append(ChatColor.GRAY).append(" x ")
|
|
.append(ChatColor.AQUA).append(item.getAmount());
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 5:
|
|
if (context.getSessionData(pref + CK.S_CONSUME_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final LinkedList<ItemStack> items
|
|
= (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS);
|
|
if (items != null) {
|
|
for (final ItemStack item : items) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
|
|
.append(ItemUtil.getName(item)).append(ChatColor.GRAY).append(" x ")
|
|
.append(ChatColor.AQUA).append(item.getAmount());
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 6:
|
|
return "";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public @NotNull String getBasicPromptText(final ConversationContext context) {
|
|
// Check/add newly made item
|
|
if (context.getSessionData("tempStack") != null) {
|
|
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
|
|
}
|
|
} else if (context.getSessionData(pref + CK.S_SMELT_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
|
|
}
|
|
}
|
|
ItemStackPrompt.clearSessionData(context);
|
|
}
|
|
|
|
final QuestsEditorPostOpenNumericPromptEvent event
|
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
plugin.getServer().getPluginManager().callEvent(event);
|
|
|
|
final StringBuilder text = new StringBuilder(ChatColor.AQUA + "- " + getTitle(context) + " -");
|
|
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));
|
|
}
|
|
return text.toString();
|
|
}
|
|
|
|
@Override
|
|
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
|
switch(input.intValue()) {
|
|
case 1:
|
|
return new QuestItemsCraftListPrompt(context);
|
|
case 2:
|
|
return new QuestItemsSmeltListPrompt(context);
|
|
case 3:
|
|
return new QuestItemsEnchantListPrompt(context);
|
|
case 4:
|
|
return new QuestItemsBrewListPrompt(context);
|
|
case 5:
|
|
return new QuestItemsConsumeListPrompt(context);
|
|
case 6:
|
|
try {
|
|
return new QuestStageMainPrompt(stageNum, context);
|
|
} catch (final Exception e) {
|
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
|
return Prompt.END_OF_CONVERSATION;
|
|
}
|
|
default:
|
|
return new QuestItemsPrompt(stageNum, context);
|
|
}
|
|
}
|
|
|
|
public class QuestItemsCraftListPrompt extends QuestsEditorNumericPrompt {
|
|
|
|
public QuestItemsCraftListPrompt(final ConversationContext context) {
|
|
super(context);
|
|
}
|
|
|
|
private final int size = 3;
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return size;
|
|
}
|
|
|
|
@Override
|
|
public String getTitle(final ConversationContext context) {
|
|
return Lang.get("stageEditorCraftItems");
|
|
}
|
|
|
|
@Override
|
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
|
switch (number) {
|
|
case 1:
|
|
return ChatColor.BLUE;
|
|
case 2:
|
|
return ChatColor.RED;
|
|
case 3:
|
|
return ChatColor.GREEN;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSelectionText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
|
case 2:
|
|
return ChatColor.RED + Lang.get("clear");
|
|
case 3:
|
|
return ChatColor.GREEN + Lang.get("done");
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final List<ItemStack> craftItems
|
|
= (List<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
|
if (craftItems != null) {
|
|
for (final ItemStack is : craftItems) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ")
|
|
.append(ItemUtil.getDisplayString(is));
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 2:
|
|
case 3:
|
|
return "";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public @NotNull String getBasicPromptText(final ConversationContext context) {
|
|
// Check/add newly made item
|
|
if (context.getSessionData("tempStack") != null) {
|
|
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
|
|
}
|
|
} else {
|
|
final LinkedList<ItemStack> items = new LinkedList<>();
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
|
|
}
|
|
ItemStackPrompt.clearSessionData(context);
|
|
}
|
|
|
|
final QuestsEditorPostOpenNumericPromptEvent event
|
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
plugin.getServer().getPluginManager().callEvent(event);
|
|
|
|
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context) + " -");
|
|
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));
|
|
}
|
|
return text.toString();
|
|
}
|
|
|
|
@Override
|
|
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
|
switch(input.intValue()) {
|
|
case 1:
|
|
return new ItemStackPrompt(context, QuestItemsCraftListPrompt.this);
|
|
case 2:
|
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
|
context.setSessionData(pref + CK.S_CRAFT_ITEMS, null);
|
|
return new QuestItemsCraftListPrompt(context);
|
|
default:
|
|
return new QuestItemsPrompt(stageNum, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class QuestItemsSmeltListPrompt extends QuestsEditorNumericPrompt {
|
|
|
|
public QuestItemsSmeltListPrompt(final ConversationContext context) {
|
|
super(context);
|
|
}
|
|
|
|
private final int size = 3;
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return size;
|
|
}
|
|
|
|
@Override
|
|
public String getTitle(final ConversationContext context) {
|
|
return Lang.get("stageEditorSmeltItems");
|
|
}
|
|
|
|
@Override
|
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
|
switch (number) {
|
|
case 1:
|
|
return ChatColor.BLUE;
|
|
case 2:
|
|
return ChatColor.RED;
|
|
case 3:
|
|
return ChatColor.GREEN;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSelectionText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
|
case 2:
|
|
return ChatColor.RED + Lang.get("clear");
|
|
case 3:
|
|
return ChatColor.GREEN + Lang.get("done");
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final List<ItemStack> smeltItems
|
|
= (List<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
|
|
if (smeltItems != null) {
|
|
for (final ItemStack is : smeltItems) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ")
|
|
.append(ItemUtil.getDisplayString(is));
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 2:
|
|
case 3:
|
|
return "";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public @NotNull String getBasicPromptText(final ConversationContext context) {
|
|
// Check/add newly made item
|
|
if (context.getSessionData("tempStack") != null) {
|
|
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
|
|
}
|
|
} else {
|
|
final LinkedList<ItemStack> items = new LinkedList<>();
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_SMELT_ITEMS, items);
|
|
}
|
|
ItemStackPrompt.clearSessionData(context);
|
|
}
|
|
|
|
final QuestsEditorPostOpenNumericPromptEvent event
|
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
plugin.getServer().getPluginManager().callEvent(event);
|
|
|
|
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context) + " -");
|
|
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));
|
|
}
|
|
return text.toString();
|
|
}
|
|
|
|
@Override
|
|
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
|
switch(input.intValue()) {
|
|
case 1:
|
|
return new ItemStackPrompt(context, QuestItemsSmeltListPrompt.this);
|
|
case 2:
|
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
|
context.setSessionData(pref + CK.S_SMELT_ITEMS, null);
|
|
return new QuestItemsSmeltListPrompt(context);
|
|
default:
|
|
return new QuestItemsPrompt(stageNum, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class QuestItemsEnchantListPrompt extends QuestsEditorNumericPrompt {
|
|
|
|
public QuestItemsEnchantListPrompt(final ConversationContext context) {
|
|
super(context);
|
|
}
|
|
|
|
private final int size = 3;
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return size;
|
|
}
|
|
|
|
@Override
|
|
public String getTitle(final ConversationContext context) {
|
|
return Lang.get("stageEditorEnchantItems");
|
|
}
|
|
|
|
@Override
|
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
|
switch (number) {
|
|
case 1:
|
|
return ChatColor.BLUE;
|
|
case 2:
|
|
return ChatColor.RED;
|
|
case 3:
|
|
return ChatColor.GREEN;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSelectionText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
|
case 2:
|
|
return ChatColor.RED + Lang.get("clear");
|
|
case 3:
|
|
return ChatColor.GREEN + Lang.get("done");
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
if (context.getSessionData(pref + CK.S_ENCHANT_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final List<ItemStack> enchantItems
|
|
= (List<ItemStack>) context.getSessionData(pref + CK.S_ENCHANT_ITEMS);
|
|
if (enchantItems != null) {
|
|
for (final ItemStack is : enchantItems) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ")
|
|
.append(ItemUtil.getDisplayString(is));
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 2:
|
|
case 3:
|
|
return "";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public @NotNull String getBasicPromptText(final ConversationContext context) {
|
|
// Check/add newly made item
|
|
if (context.getSessionData("tempStack") != null) {
|
|
if (context.getSessionData(pref + CK.S_ENCHANT_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_ENCHANT_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items);
|
|
}
|
|
} else {
|
|
final LinkedList<ItemStack> items = new LinkedList<>();
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items);
|
|
}
|
|
ItemStackPrompt.clearSessionData(context);
|
|
}
|
|
|
|
final QuestsEditorPostOpenNumericPromptEvent event
|
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
plugin.getServer().getPluginManager().callEvent(event);
|
|
|
|
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context) + " -");
|
|
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));
|
|
}
|
|
return text.toString();
|
|
}
|
|
|
|
@Override
|
|
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
|
switch(input.intValue()) {
|
|
case 1:
|
|
return new ItemStackPrompt(context, QuestItemsEnchantListPrompt.this);
|
|
case 2:
|
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
|
context.setSessionData(pref + CK.S_ENCHANT_ITEMS, null);
|
|
return new QuestItemsEnchantListPrompt(context);
|
|
default:
|
|
return new QuestItemsPrompt(stageNum, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class QuestItemsBrewListPrompt extends QuestsEditorNumericPrompt {
|
|
|
|
public QuestItemsBrewListPrompt(final ConversationContext context) {
|
|
super(context);
|
|
}
|
|
|
|
private final int size = 3;
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return size;
|
|
}
|
|
|
|
@Override
|
|
public String getTitle(final ConversationContext context) {
|
|
return Lang.get("stageEditorBrewPotions");
|
|
}
|
|
|
|
@Override
|
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
|
switch (number) {
|
|
case 1:
|
|
return ChatColor.BLUE;
|
|
case 2:
|
|
return ChatColor.RED;
|
|
case 3:
|
|
return ChatColor.GREEN;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSelectionText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
|
case 2:
|
|
return ChatColor.RED + Lang.get("clear");
|
|
case 3:
|
|
return ChatColor.GREEN + Lang.get("done");
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final List<ItemStack> brewItems = (List<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
|
|
if (brewItems != null) {
|
|
for (final ItemStack is : brewItems) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ")
|
|
.append(ItemUtil.getDisplayString(is));
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 2:
|
|
case 3:
|
|
return "";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public @NotNull String getBasicPromptText(final ConversationContext context) {
|
|
// Check/add newly made item
|
|
if (context.getSessionData("tempStack") != null) {
|
|
if (context.getSessionData(pref + CK.S_BREW_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
|
|
}
|
|
} else {
|
|
final LinkedList<ItemStack> items = new LinkedList<>();
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
|
|
}
|
|
ItemStackPrompt.clearSessionData(context);
|
|
}
|
|
|
|
final QuestsEditorPostOpenNumericPromptEvent event
|
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
plugin.getServer().getPluginManager().callEvent(event);
|
|
|
|
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context) + " -");
|
|
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));
|
|
}
|
|
return text.toString();
|
|
}
|
|
|
|
@Override
|
|
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
|
switch(input.intValue()) {
|
|
case 1:
|
|
return new ItemStackPrompt(context, QuestItemsBrewListPrompt.this);
|
|
case 2:
|
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
|
context.setSessionData(pref + CK.S_BREW_ITEMS, null);
|
|
return new QuestItemsBrewListPrompt(context);
|
|
default:
|
|
return new QuestItemsPrompt(stageNum, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class QuestItemsConsumeListPrompt extends QuestsEditorNumericPrompt {
|
|
|
|
public QuestItemsConsumeListPrompt(final ConversationContext context) {
|
|
super(context);
|
|
}
|
|
|
|
private final int size = 3;
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return size;
|
|
}
|
|
|
|
@Override
|
|
public String getTitle(final ConversationContext context) {
|
|
return Lang.get("stageEditorConsumeItems");
|
|
}
|
|
|
|
@Override
|
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
|
switch (number) {
|
|
case 1:
|
|
return ChatColor.BLUE;
|
|
case 2:
|
|
return ChatColor.RED;
|
|
case 3:
|
|
return ChatColor.GREEN;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSelectionText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
|
case 2:
|
|
return ChatColor.RED + Lang.get("clear");
|
|
case 3:
|
|
return ChatColor.GREEN + Lang.get("done");
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SuppressWarnings("unchecked")
|
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
|
switch(number) {
|
|
case 1:
|
|
if (context.getSessionData(pref + CK.S_CONSUME_ITEMS) == null) {
|
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
|
} else {
|
|
final StringBuilder text = new StringBuilder();
|
|
final List<ItemStack> consumeItems
|
|
= (List<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS);
|
|
if (consumeItems != null) {
|
|
for (final ItemStack is : consumeItems) {
|
|
text.append("\n").append(ChatColor.GRAY).append(" - ")
|
|
.append(ItemUtil.getDisplayString(is));
|
|
}
|
|
}
|
|
return text.toString();
|
|
}
|
|
case 2:
|
|
case 3:
|
|
return "";
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public @NotNull String getBasicPromptText(final ConversationContext context) {
|
|
// Check/add newly made item
|
|
if (context.getSessionData("tempStack") != null) {
|
|
if (context.getSessionData(pref + CK.S_CONSUME_ITEMS) != null) {
|
|
final List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS);
|
|
if (items != null) {
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
|
|
}
|
|
} else {
|
|
final LinkedList<ItemStack> items = new LinkedList<>();
|
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
|
|
}
|
|
ItemStackPrompt.clearSessionData(context);
|
|
}
|
|
|
|
final QuestsEditorPostOpenNumericPromptEvent event
|
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
plugin.getServer().getPluginManager().callEvent(event);
|
|
|
|
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context) + " -");
|
|
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));
|
|
}
|
|
return text.toString();
|
|
}
|
|
|
|
@Override
|
|
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
|
switch(input.intValue()) {
|
|
case 1:
|
|
return new ItemStackPrompt(context, QuestItemsConsumeListPrompt.this);
|
|
case 2:
|
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, null);
|
|
return new QuestItemsConsumeListPrompt(context);
|
|
default:
|
|
return new QuestItemsPrompt(stageNum, context);
|
|
}
|
|
}
|
|
}
|
|
}
|