mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-20 23:31:36 +01:00
Improve code syntax, part 3
This commit is contained in:
parent
7531e20d4e
commit
e3b449ed8b
File diff suppressed because it is too large
Load Diff
@ -12,16 +12,15 @@
|
||||
|
||||
package me.blackvein.quests.convo.generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import me.blackvein.quests.util.MiscUtil;
|
||||
import me.blackvein.quests.util.RomanNumeral;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -31,15 +30,17 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import me.blackvein.quests.util.MiscUtil;
|
||||
import me.blackvein.quests.util.RomanNumeral;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Stores ItemStack in "tempStack" context data<p>
|
||||
@ -73,7 +74,6 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 0:
|
||||
@ -85,7 +85,7 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
case 6:
|
||||
return ChatColor.BLUE;
|
||||
case 7:
|
||||
if ((LinkedHashMap<String, Object>) context.getSessionData("tempMeta") != null) {
|
||||
if (context.getSessionData("tempMeta") != null) {
|
||||
return ChatColor.BLUE;
|
||||
} else {
|
||||
return ChatColor.GRAY;
|
||||
@ -100,7 +100,6 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public String getSelectionText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 0:
|
||||
@ -118,7 +117,7 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
case 6:
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateSetLore");
|
||||
case 7:
|
||||
if ((LinkedHashMap<String, Object>) context.getSessionData("tempMeta") != null) {
|
||||
if (context.getSessionData("tempMeta") != null) {
|
||||
return ChatColor.DARK_GREEN + Lang.get("itemCreateSetClearMeta");
|
||||
} else {
|
||||
return ChatColor.GRAY + Lang.get("itemCreateSetClearMeta");
|
||||
@ -137,6 +136,8 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 0:
|
||||
case 8:
|
||||
case 9:
|
||||
return "";
|
||||
case 1:
|
||||
if (context.getSessionData("tempName") == null) {
|
||||
@ -149,26 +150,28 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
if (context.getSessionData("tempAmount") == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
final int text = (Integer) context.getSessionData("tempAmount");
|
||||
final Integer text = (Integer) context.getSessionData("tempAmount");
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + text + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 3:
|
||||
if (context.getSessionData("tempData") == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
final short text = (Short) context.getSessionData("tempData");
|
||||
final Short text = (Short) context.getSessionData("tempData");
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + text + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 4:
|
||||
if (context.getSessionData("tempEnchantments") == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
String text = "";
|
||||
final StringBuilder text = new StringBuilder();
|
||||
final Map<Enchantment, Integer> map
|
||||
= (Map<Enchantment, Integer>) context.getSessionData("tempEnchantments");
|
||||
for (final Entry<Enchantment, Integer> e : map.entrySet()) {
|
||||
text += "\n" + ItemUtil.getPrettyEnchantmentName(e.getKey()) + " "
|
||||
+ RomanNumeral.getNumeral(e.getValue());
|
||||
if (map != null) {
|
||||
for (final Entry<Enchantment, Integer> e : map.entrySet()) {
|
||||
text.append("\n").append(ItemUtil.getPrettyEnchantmentName(e.getKey())).append(" ")
|
||||
.append(RomanNumeral.getNumeral(e.getValue()));
|
||||
}
|
||||
}
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + text + ChatColor.GRAY + ")";
|
||||
}
|
||||
@ -183,10 +186,12 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
if (context.getSessionData("tempLore") == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
String text = "";
|
||||
final StringBuilder text = new StringBuilder();
|
||||
final List<String> list = (List<String>) context.getSessionData("tempLore");
|
||||
for (final String s : list) {
|
||||
text += "\n" + s;
|
||||
if (list != null) {
|
||||
for (final String s : list) {
|
||||
text.append("\n").append(s);
|
||||
}
|
||||
}
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + text + ChatColor.GRAY + ")";
|
||||
}
|
||||
@ -194,26 +199,23 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
if (context.getSessionData("tempMeta") == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
String text = "";
|
||||
final StringBuilder text = new StringBuilder();
|
||||
final LinkedHashMap<String, Object> map
|
||||
= (LinkedHashMap<String, Object>) context.getSessionData("tempMeta");
|
||||
if (!map.isEmpty()) {
|
||||
if (map != null && !map.isEmpty()) {
|
||||
for (final String key : map.keySet()) {
|
||||
if (key.equals("pages")) {
|
||||
final List<String> pages = (List<String>) map.get(key);
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.DARK_GREEN + key + "="
|
||||
+ pages.size();
|
||||
text.append("\n").append(ChatColor.GRAY).append("\u2515 ").append(ChatColor.DARK_GREEN)
|
||||
.append(key).append("=").append(pages.size());
|
||||
} else {
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.DARK_GREEN + key + "="
|
||||
+ map.get(key);
|
||||
text.append("\n").append(ChatColor.GRAY).append("\u2515 ").append(ChatColor.DARK_GREEN)
|
||||
.append(key).append("=").append(map.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -221,48 +223,46 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + getTitle(context);
|
||||
final StringBuilder text = new StringBuilder(ChatColor.GOLD + getTitle(context));
|
||||
if (context.getSessionData("tempName") != null) {
|
||||
final String stackData = getItemData(context);
|
||||
if (stackData != null) {
|
||||
text += "\n" + stackData;
|
||||
text.append("\n").append(stackData);
|
||||
if (context.getSessionData("tempMeta") != null) {
|
||||
final LinkedHashMap<String, Object> map
|
||||
= (LinkedHashMap<String, Object>) context.getSessionData("tempMeta");
|
||||
if (!map.isEmpty()) {
|
||||
if (map != null && !map.isEmpty()) {
|
||||
for (final String key : map.keySet()) {
|
||||
if (key.equals("pages")) {
|
||||
final List<String> pages = (List<String>) map.get(key);
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.DARK_GREEN + key + "="
|
||||
+ pages.size();
|
||||
text.append("\n").append(ChatColor.GRAY).append("\u2515 ").append(ChatColor.DARK_GREEN)
|
||||
.append(key).append("=").append(pages.size());
|
||||
} else {
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.DARK_GREEN + key + "="
|
||||
+ map.get(key);
|
||||
text.append("\n").append(ChatColor.GRAY).append("\u2515 ").append(ChatColor.DARK_GREEN)
|
||||
.append(key).append("=").append(map.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /*else {
|
||||
text += "\n";
|
||||
}*/
|
||||
}
|
||||
int start = 0;
|
||||
if (!(context.getForWhom() instanceof Player)) {
|
||||
start = 1;
|
||||
}
|
||||
for (int i = start; i <= size-1; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i)/* + " " + getAdditionalText(context, i)*/;
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
|
||||
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i));
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final @NotNull Number input) {
|
||||
return acceptValidatedInput(context, input, null);
|
||||
}
|
||||
|
||||
@ -275,9 +275,8 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
|
||||
final Player player = (Player) context.getForWhom();
|
||||
final ItemStack is = item == null ? player.getItemInHand() : item;
|
||||
if (is == null || is.getType().equals(Material.AIR)) {
|
||||
if (is.getType().equals(Material.AIR)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get("itemCreateNoItem"));
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
} else {
|
||||
context.setSessionData("tempName", is.getType().name());
|
||||
context.setSessionData("tempAmount", is.getAmount());
|
||||
@ -288,38 +287,31 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
if (is.getDurability() != 0) {
|
||||
context.setSessionData("tempData", is.getDurability());
|
||||
}
|
||||
if (is.getEnchantments() != null && is.getEnchantments().isEmpty() == false) {
|
||||
context.setSessionData("tempEnchantments", new HashMap<Enchantment, Integer>(is.getEnchantments()));
|
||||
if (!is.getEnchantments().isEmpty()) {
|
||||
context.setSessionData("tempEnchantments", new HashMap<>(is.getEnchantments()));
|
||||
}
|
||||
if (is.hasItemMeta()) {
|
||||
final ItemMeta meta = is.getItemMeta();
|
||||
if (meta.hasDisplayName()) {
|
||||
if (meta != null) {
|
||||
final String display = meta.getDisplayName().replace(ChatColor.COLOR_CHAR, '&');
|
||||
context.setSessionData("tempDisplay", display);
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
final LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.addAll(meta.getLore());
|
||||
context.setSessionData("tempLore", lore);
|
||||
}
|
||||
final LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
map.putAll(meta.serialize());
|
||||
if (map.containsKey("lore")) {
|
||||
if (meta.getLore() != null) {
|
||||
final LinkedList<String> lore = new LinkedList<>(meta.getLore());
|
||||
context.setSessionData("tempLore", lore);
|
||||
}
|
||||
final LinkedHashMap<String, Object> map = new LinkedHashMap<>(meta.serialize());
|
||||
map.remove("lore");
|
||||
}
|
||||
if (map.containsKey("display-name")) {
|
||||
map.remove("display-name");
|
||||
}
|
||||
if (map != null && !map.isEmpty()) {
|
||||
context.setSessionData("tempMeta", map);
|
||||
if (!map.isEmpty()) {
|
||||
context.setSessionData("tempMeta", map);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
}
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("consoleError"));
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
}
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
case 1:
|
||||
context.setSessionData("tempMeta", null);
|
||||
return new ItemNamePrompt(context);
|
||||
@ -361,19 +353,18 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
case 7:
|
||||
if (context.getSessionData("tempName") != null && context.getSessionData("tempAmount") != null) {
|
||||
context.setSessionData("tempMeta", null);
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
}
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
case 8:
|
||||
clearSessionData(context);
|
||||
return oldPrompt;
|
||||
case 9:
|
||||
if (context.getSessionData("tempName") != null && context.getSessionData("tempAmount") != null) {
|
||||
final String name = (String) context.getSessionData("tempName");
|
||||
final int amount = (Integer) context.getSessionData("tempAmount");
|
||||
short data = -1;
|
||||
final Integer amount = (Integer) context.getSessionData("tempAmount");
|
||||
Short data = -1;
|
||||
Map<Enchantment, Integer> enchs = null;
|
||||
String display = null;
|
||||
List<String> lore = null;
|
||||
@ -384,41 +375,47 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
enchs = (Map<Enchantment, Integer>) context.getSessionData("tempEnchantments");
|
||||
}
|
||||
if (context.getSessionData("tempDisplay") != null) {
|
||||
display = ChatColor.translateAlternateColorCodes('&', (String) context.getSessionData("tempDisplay"));
|
||||
display = ChatColor.translateAlternateColorCodes('&',
|
||||
(String) Objects.requireNonNull(context.getSessionData("tempDisplay")));
|
||||
}
|
||||
if (context.getSessionData("tempLore") != null) {
|
||||
lore = new ArrayList<String>();
|
||||
lore = new ArrayList<>();
|
||||
final LinkedList<String> loadedLore = (LinkedList<String>) context.getSessionData("tempLore");
|
||||
for (final String line : loadedLore) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
if (loadedLore != null) {
|
||||
for (final String line : loadedLore) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final ItemStack stack = new ItemStack(Material.matchMaterial(name), amount);
|
||||
|
||||
if (data != -1) {
|
||||
stack.setDurability(data);
|
||||
}
|
||||
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
if ((Map<String, Object>) context.getSessionData("tempMeta") != null) {
|
||||
meta = ItemUtil.deserializeItemMeta(meta.getClass(),
|
||||
(Map<String, Object>) context.getSessionData("tempMeta"));
|
||||
}
|
||||
if (enchs != null) {
|
||||
for (final Entry<Enchantment, Integer> e : enchs.entrySet()) {
|
||||
meta.addEnchant(e.getKey(), e.getValue(), true);
|
||||
|
||||
if (name != null && amount != null && data != null) {
|
||||
final ItemStack stack = new ItemStack(Objects.requireNonNull(Material.matchMaterial(name)), amount);
|
||||
if (data != -1) {
|
||||
stack.setDurability(data);
|
||||
}
|
||||
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (context.getSessionData("tempMeta") != null) {
|
||||
meta = ItemUtil.deserializeItemMeta(meta.getClass(),
|
||||
(Map<String, Object>) context.getSessionData("tempMeta"));
|
||||
}
|
||||
if (enchs != null) {
|
||||
for (final Entry<Enchantment, Integer> e : enchs.entrySet()) {
|
||||
meta.addEnchant(e.getKey(), e.getValue(), true);
|
||||
}
|
||||
}
|
||||
if (display != null) {
|
||||
meta.setDisplayName(display);
|
||||
}
|
||||
if (lore != null) {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
context.setSessionData("tempStack", stack);
|
||||
}
|
||||
if (display != null) {
|
||||
meta.setDisplayName(display);
|
||||
}
|
||||
if (lore != null) {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
|
||||
stack.setItemMeta(meta);
|
||||
context.setSessionData("tempStack", stack);
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(context, oldPrompt);
|
||||
@ -450,13 +447,16 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
final String s = input.replace(":", "");
|
||||
final Material mat = Material.matchMaterial(s.toUpperCase().replace(" ", "_"));
|
||||
if (mat == null) {
|
||||
@ -499,13 +499,16 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
try {
|
||||
final int amt = Integer.parseInt(input);
|
||||
if (amt < 1 || amt > 64) {
|
||||
@ -543,14 +546,16 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
try {
|
||||
final int amt = Integer.parseInt(input);
|
||||
if (amt < 1) {
|
||||
@ -592,20 +597,22 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String text = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n");
|
||||
for (final Enchantment e : Enchantment.values()) {
|
||||
text += ChatColor.GREEN + ItemUtil.getPrettyEnchantmentName(e) + ", ";
|
||||
text.append(ChatColor.GREEN).append(ItemUtil.getPrettyEnchantmentName(e)).append(", ");
|
||||
}
|
||||
text = text.substring(0, text.length() - 2);
|
||||
text = new StringBuilder(text.substring(0, text.length() - 2));
|
||||
return text + "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
final String s = input.replace(":", "");
|
||||
if (s.equalsIgnoreCase(Lang.get("cmdClear")) == false
|
||||
&& s.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
if (!s.equalsIgnoreCase(Lang.get("cmdClear")) && !s.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
final Enchantment e = ItemUtil.getEnchantmentFromPrettyName(MiscUtil.getCapitalized(s));
|
||||
if (e != null) {
|
||||
context.setSessionData("tempEnchant", e);
|
||||
@ -641,12 +648,12 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
return ChatColor.AQUA + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
try {
|
||||
final int num = Integer.parseInt(input);
|
||||
if (num < 1) {
|
||||
@ -659,10 +666,12 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
final
|
||||
Map<Enchantment, Integer> enchs
|
||||
= (Map<Enchantment, Integer>) context.getSessionData("tempEnchantments");
|
||||
enchs.put((Enchantment) context.getSessionData("tempEnchant"), num);
|
||||
context.setSessionData("tempEnchantments", enchs);
|
||||
if (enchs != null) {
|
||||
enchs.put((Enchantment) context.getSessionData("tempEnchant"), num);
|
||||
context.setSessionData("tempEnchantments", enchs);
|
||||
}
|
||||
} else {
|
||||
final Map<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>();
|
||||
final Map<Enchantment, Integer> enchs = new HashMap<>();
|
||||
enchs.put((Enchantment) context.getSessionData("tempEnchant"), num);
|
||||
context.setSessionData("tempEnchantments", enchs);
|
||||
}
|
||||
@ -692,15 +701,17 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
String s = input.replace(":", "");
|
||||
if (s.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||
&& s.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
if (!s.equalsIgnoreCase(Lang.get("cmdCancel")) && !s.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
s = ConfigUtil.parseString(s);
|
||||
context.setSessionData("tempDisplay", s);
|
||||
} else if (s.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
@ -727,18 +738,19 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
String s = input.replace(":", "");
|
||||
if (s.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||
&& s.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
if (!s.equalsIgnoreCase(Lang.get("cmdCancel")) && !s.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
s = ConfigUtil.parseString(s);
|
||||
final LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.addAll(Arrays.asList(s.split(Lang.get("charSemi"))));
|
||||
final LinkedList<String> lore = new LinkedList<>(Arrays.asList(s.split(Lang.get("charSemi"))));
|
||||
context.setSessionData("tempLore", lore);
|
||||
} else if (s.equalsIgnoreCase("clear")) {
|
||||
context.setSessionData("tempLore", null);
|
||||
@ -749,54 +761,59 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
||||
|
||||
private String getItemData(final ConversationContext context) {
|
||||
if (context.getSessionData("tempName") != null) {
|
||||
String item;
|
||||
final StringBuilder item;
|
||||
if (context.getSessionData("tempDisplay") == null) {
|
||||
final String name = (String) context.getSessionData("tempName");
|
||||
item = ChatColor.AQUA + ItemUtil.getPrettyItemName(name);
|
||||
item = new StringBuilder(ChatColor.AQUA + ItemUtil.getPrettyItemName(name));
|
||||
if (context.getSessionData("tempData") != null) {
|
||||
item += ":" + ChatColor.BLUE + context.getSessionData("tempData");
|
||||
item.append(":").append(ChatColor.BLUE).append(context.getSessionData("tempData"));
|
||||
}
|
||||
} else {
|
||||
item = ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + (String) context.getSessionData("tempDisplay")
|
||||
+ ChatColor.RESET + "" + ChatColor.GRAY + " (";
|
||||
item = new StringBuilder(ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC
|
||||
+ context.getSessionData("tempDisplay") + ChatColor.RESET + "" + ChatColor.GRAY + " (");
|
||||
final String name = (String) context.getSessionData("tempName");
|
||||
item += ChatColor.AQUA + ItemUtil.getPrettyItemName(name);
|
||||
item.append(ChatColor.AQUA).append(ItemUtil.getPrettyItemName(name));
|
||||
if (context.getSessionData("tempData") != null) {
|
||||
item += ":" + ChatColor.BLUE + context.getSessionData("tempData");
|
||||
item.append(":").append(ChatColor.BLUE).append(context.getSessionData("tempData"));
|
||||
}
|
||||
item += ChatColor.GRAY + ")";
|
||||
item.append(ChatColor.GRAY).append(")");
|
||||
}
|
||||
if (context.getSessionData("tempAmount") != null) {
|
||||
item += ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + context.getSessionData("tempAmount");
|
||||
item.append(ChatColor.GRAY).append(" x ").append(ChatColor.DARK_AQUA)
|
||||
.append(context.getSessionData("tempAmount"));
|
||||
} else {
|
||||
item += ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + "1";
|
||||
item.append(ChatColor.GRAY).append(" x ").append(ChatColor.DARK_AQUA).append("1");
|
||||
}
|
||||
item += "\n";
|
||||
item.append("\n");
|
||||
if (context.getSessionData("tempEnchantments") != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final
|
||||
Map<Enchantment, Integer> enchantments
|
||||
= (Map<Enchantment, Integer>) context.getSessionData("tempEnchantments");
|
||||
for (final Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||
item += ChatColor.GRAY + " - " + ChatColor.RED + ItemUtil.getPrettyEnchantmentName(e.getKey())
|
||||
+ " " + RomanNumeral.getNumeral(e.getValue()) + "\n";
|
||||
if (enchantments != null) {
|
||||
for (final Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||
item.append(ChatColor.GRAY).append(" - ").append(ChatColor.RED)
|
||||
.append(ItemUtil.getPrettyEnchantmentName(e.getKey())).append(" ")
|
||||
.append(RomanNumeral.getNumeral(e.getValue())).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (context.getSessionData("tempLore") != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final
|
||||
List<String> lore = (List<String>) context.getSessionData("tempLore");
|
||||
item += ChatColor.DARK_GREEN + "(Lore)\n\"";
|
||||
for (final String s : lore) {
|
||||
if (lore.indexOf(s) != (lore.size() - 1)) {
|
||||
item += ChatColor.DARK_GREEN + "" + ChatColor.ITALIC + s + "\n";
|
||||
} else {
|
||||
item += ChatColor.DARK_GREEN + "" + ChatColor.ITALIC + s + "\"\n";
|
||||
final List<String> lore = (List<String>) context.getSessionData("tempLore");
|
||||
item.append(ChatColor.DARK_GREEN).append("(Lore)\n\"");
|
||||
if (lore != null) {
|
||||
for (final String s : lore) {
|
||||
if (lore.indexOf(s) != (lore.size() - 1)) {
|
||||
item.append(ChatColor.DARK_GREEN).append(ChatColor.ITALIC).append(s).append("\n");
|
||||
} else {
|
||||
item.append(ChatColor.DARK_GREEN).append(ChatColor.ITALIC).append(s).append("\"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
item += "\n";
|
||||
return item;
|
||||
item.append("\n");
|
||||
return item.toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.conversations.Prompt;
|
||||
|
||||
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OverridePrompt extends QuestsEditorStringPrompt {
|
||||
private final Prompt oldPrompt;
|
||||
@ -48,9 +49,12 @@ public class OverridePrompt extends QuestsEditorStringPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
if (context.getPlugin() != null) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
||||
super(null);
|
||||
}
|
||||
|
||||
public NpcOfferQuestPrompt(ConversationContext context) {
|
||||
public NpcOfferQuestPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@ -53,25 +53,27 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
final String npc = (String) context.getSessionData("npc");
|
||||
return Lang.get("questNPCListTitle").replace("<npc>", npc);
|
||||
return Lang.get("questNPCListTitle").replace("<npc>", npc != null ? npc : "NPC");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||
final Quests plugin = (Quests)context.getPlugin();
|
||||
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
|
||||
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN;
|
||||
} else {
|
||||
if (plugin != null) {
|
||||
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN;
|
||||
} else {
|
||||
return ChatColor.GOLD;
|
||||
}
|
||||
} else if (number == (quests.size() + 1)) {
|
||||
//return ChatColor.RED;
|
||||
return ChatColor.GOLD;
|
||||
}
|
||||
} else if (number == (quests.size() + 1)) {
|
||||
//return ChatColor.RED;
|
||||
return ChatColor.GOLD;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -81,17 +83,19 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
||||
public String getSelectionText(final ConversationContext context, final int number) {
|
||||
final Quests plugin = (Quests)context.getPlugin();
|
||||
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
|
||||
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName();
|
||||
} else {
|
||||
return ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName();
|
||||
if (plugin != null) {
|
||||
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName();
|
||||
} else {
|
||||
return ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName();
|
||||
}
|
||||
} else if (number == (quests.size() + 1)) {
|
||||
return ChatColor.GRAY + Lang.get("cancel");
|
||||
}
|
||||
} else if (number == (quests.size() + 1)) {
|
||||
return ChatColor.GRAY + Lang.get("cancel");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -101,12 +105,14 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
final Quests plugin = (Quests)context.getPlugin();
|
||||
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
|
||||
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN + "" + Lang.get("redoCompleted");
|
||||
if (plugin != null) {
|
||||
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||
if (quests != null && number > 0) {
|
||||
if (number < (quests.size() + 1)) {
|
||||
final Quest quest = quests.get(number - 1);
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
return ChatColor.GREEN + "" + Lang.get("redoCompleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,14 +137,15 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
||||
final MiscPostNpcOfferQuestEvent event = new MiscPostNpcOfferQuestEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.WHITE + getTitle(context);
|
||||
final StringBuilder text = new StringBuilder(ChatColor.WHITE + getTitle(context));
|
||||
size = quests.size();
|
||||
for (int i = 1; i <= size + 1; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ". " + ChatColor.RESET
|
||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, i);
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i).append(". ")
|
||||
.append(ChatColor.RESET).append(getSelectionText(context, i)).append(" ")
|
||||
.append(getAdditionalText(context, i));
|
||||
}
|
||||
text += "\n" + ChatColor.WHITE + getQueryText(context);
|
||||
return text;
|
||||
text.append("\n").append(ChatColor.WHITE).append(getQueryText(context));
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -42,6 +42,7 @@ import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -80,6 +81,11 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return ChatColor.BLUE;
|
||||
case 5:
|
||||
if (context.getForWhom() instanceof Player) {
|
||||
@ -99,12 +105,6 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
} else {
|
||||
return ChatColor.GRAY;
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return ChatColor.BLUE;
|
||||
case 13:
|
||||
return ChatColor.GREEN;
|
||||
case 14:
|
||||
@ -170,6 +170,13 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
return "";
|
||||
case 2:
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET
|
||||
@ -182,8 +189,12 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
!= null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else if (plugin.getDependencies().getCitizens() != null) {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + CitizensAPI.getNPCRegistry().getById((Integer) context
|
||||
.getSessionData(CK.Q_START_NPC)).getName() + ChatColor.RESET + ChatColor.GRAY + ")";
|
||||
final Integer id = (Integer) context.getSessionData(CK.Q_START_NPC);
|
||||
if (id != null) {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + CitizensAPI.getNPCRegistry().getById(id).getName()
|
||||
+ ChatColor.RESET + ChatColor.GRAY + ")";
|
||||
}
|
||||
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||
}
|
||||
@ -192,15 +203,17 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
final Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + l.getWorld().getName() + ", " + l.getBlockX() + ", "
|
||||
+ l.getBlockY() + ", " + l.getBlockZ() + ChatColor.RESET + ChatColor.GRAY + ")";
|
||||
if (l != null && l.getWorld() != null) {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + l.getWorld().getName() + ", " + l.getBlockX() + ", "
|
||||
+ l.getBlockY() + ", " + l.getBlockZ() + ChatColor.RESET + ChatColor.GRAY + ")";
|
||||
}
|
||||
}
|
||||
case 6:
|
||||
if (plugin.getDependencies().getWorldGuardApi() != null) {
|
||||
if (context.getSessionData(CK.Q_REGION) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + (String) context.getSessionData(CK.Q_REGION)
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.Q_REGION)
|
||||
+ ChatColor.RESET + ChatColor.GRAY + ")";
|
||||
}
|
||||
} else {
|
||||
@ -217,35 +230,26 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA)
|
||||
+ ChatColor.GOLD + " -";
|
||||
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": "
|
||||
+ ChatColor.AQUA) + ChatColor.GOLD + " -");
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, 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;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
return new QuestNamePrompt(context);
|
||||
@ -317,7 +321,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@ -325,15 +329,18 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
for (final Quest q : plugin.getLoadedQuests()) {
|
||||
if (q.getName().equalsIgnoreCase(input)) {
|
||||
String s = null;
|
||||
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
|
||||
s = (String) context.getSessionData(CK.ED_QUEST_EDIT);
|
||||
}
|
||||
if (s != null && s.equalsIgnoreCase(input) == false) {
|
||||
if (s != null && !s.equalsIgnoreCase(input)) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
|
||||
return new QuestNamePrompt(context);
|
||||
}
|
||||
@ -348,7 +355,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
|
||||
return new QuestNamePrompt(context);
|
||||
}
|
||||
questNames.remove(context.getSessionData(CK.Q_NAME));
|
||||
questNames.remove((String) context.getSessionData(CK.Q_NAME));
|
||||
context.setSessionData(CK.Q_NAME, input);
|
||||
questNames.add(input);
|
||||
plugin.getQuestFactory().setNamesOfQuestsBeingEdited(questNames);
|
||||
@ -374,7 +381,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@ -382,8 +389,11 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
if (input.startsWith("++")) {
|
||||
if (context.getSessionData(CK.Q_ASK_MESSAGE) != null) {
|
||||
context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " "
|
||||
@ -414,7 +424,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@ -422,8 +432,11 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
if (input.startsWith("++")) {
|
||||
if (context.getSessionData(CK.Q_FINISH_MESSAGE) != null) {
|
||||
context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " "
|
||||
@ -454,7 +467,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@ -470,9 +483,11 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
try {
|
||||
final int i = Integer.parseInt(input);
|
||||
if (i > -1) {
|
||||
@ -522,7 +537,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@ -530,7 +545,10 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
final Player player = (Player) context.getForWhom();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdDone")) || input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdDone"))) {
|
||||
@ -580,42 +598,48 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.AQUA + getTitle(context) + "\n";
|
||||
StringBuilder text = new StringBuilder(ChatColor.AQUA + getTitle(context) + "\n");
|
||||
boolean any = false;
|
||||
for (final World world : plugin.getServer().getWorlds()) {
|
||||
final WorldGuardAPI api = plugin.getDependencies().getWorldGuardApi();
|
||||
final RegionManager rm = api.getRegionManager(world);
|
||||
for (final String region : rm.getRegions().keySet()) {
|
||||
any = true;
|
||||
text += ChatColor.GREEN + region + ", ";
|
||||
final RegionManager regionManager = api.getRegionManager(world);
|
||||
if (regionManager != null) {
|
||||
for (final String region : regionManager.getRegions().keySet()) {
|
||||
any = true;
|
||||
text.append(ChatColor.GREEN).append(region).append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (any) {
|
||||
text = text.substring(0, text.length() - 2) + "\n";
|
||||
text = new StringBuilder(text.substring(0, text.length() - 2) + "\n");
|
||||
} else {
|
||||
text += ChatColor.GRAY + "(" + Lang.get("none") + ")\n";
|
||||
text.append(ChatColor.GRAY).append("(").append(Lang.get("none")).append(")\n");
|
||||
}
|
||||
return text + ChatColor.YELLOW + getQueryText(context);
|
||||
return text.toString() + ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
String found = null;
|
||||
boolean done = false;
|
||||
for (final World world : plugin.getServer().getWorlds()) {
|
||||
final WorldGuardAPI api = plugin.getDependencies().getWorldGuardApi();
|
||||
final RegionManager rm = api.getRegionManager(world);
|
||||
for (final String region : rm.getRegions().keySet()) {
|
||||
if (region.equalsIgnoreCase(input)) {
|
||||
found = region;
|
||||
done = true;
|
||||
break;
|
||||
final RegionManager regionManager = api.getRegionManager(world);
|
||||
if (regionManager != null) {
|
||||
for (final String region : regionManager.getRegions().keySet()) {
|
||||
if (region.equalsIgnoreCase(input)) {
|
||||
found = region;
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
@ -696,7 +720,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final ConversationContext context) {
|
||||
// Check/add newly made item
|
||||
if (context.getSessionData("tempStack") != null) {
|
||||
final ItemStack stack = (ItemStack) context.getSessionData("tempStack");
|
||||
@ -717,26 +741,27 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
ItemStackPrompt.clearSessionData(context);
|
||||
}
|
||||
|
||||
final QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||
|
||||
if (context.getPlugin() != null) {
|
||||
final QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
final StringBuilder text = new StringBuilder(ChatColor.GOLD + getTitle(context) + "\n");
|
||||
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
||||
final ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
|
||||
text += " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n";
|
||||
text.append(" ").append(ChatColor.RESET).append(ItemUtil.getDisplayString(stack)).append("\n");
|
||||
} else {
|
||||
text += " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||
text.append(" ").append(ChatColor.GRAY).append("(").append(Lang.get("noneSet")).append(")\n");
|
||||
}
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i);
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i).append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i));
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
return new ItemStackPrompt(context, QuestGuiDisplayPrompt.this);
|
||||
@ -797,21 +822,24 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.YELLOW + getQueryText(context);
|
||||
final StringBuilder text = new StringBuilder(ChatColor.YELLOW + getQueryText(context));
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i);
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
|
||||
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i));
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("modeDeny")
|
||||
@ -835,7 +863,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
if (questSection == null) {
|
||||
questSection = data.createSection("quests");
|
||||
}
|
||||
ConfigurationSection newSection;
|
||||
ConfigurationSection newSection = null;
|
||||
if (context.getSessionData(CK.Q_ID) == null) {
|
||||
// Creating
|
||||
int customNum = 1;
|
||||
@ -849,16 +877,19 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
newSection = questSection.createSection("custom" + customNum);
|
||||
} else {
|
||||
// Editing
|
||||
newSection = questSection.createSection((String)context.getSessionData(CK.Q_ID));
|
||||
final String qid = (String)context.getSessionData(CK.Q_ID);
|
||||
if (qid != null) {
|
||||
newSection = questSection.createSection(qid);
|
||||
}
|
||||
}
|
||||
plugin.getQuestFactory().saveQuest(context, newSection);
|
||||
data.save(new File(plugin.getDataFolder(), "quests.yml"));
|
||||
context.getForWhom().sendRawMessage(ChatColor.GREEN
|
||||
+ Lang.get("questEditorSaved").replace("<command>", "/questadmin "
|
||||
+ Lang.get("COMMAND_QUESTADMIN_RELOAD")));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final InvalidConfigurationException e) {
|
||||
if (newSection != null) {
|
||||
plugin.getQuestFactory().saveQuest(context, newSection);
|
||||
data.save(new File(plugin.getDataFolder(), "quests.yml"));
|
||||
context.getForWhom().sendRawMessage(ChatColor.GREEN
|
||||
+ Lang.get("questEditorSaved").replace("<command>", "/questadmin "
|
||||
+ Lang.get("COMMAND_QUESTADMIN_RELOAD")));
|
||||
}
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
@ -915,21 +946,24 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.YELLOW + getQueryText(context);
|
||||
final StringBuilder text = new StringBuilder(ChatColor.YELLOW + getQueryText(context));
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i);
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
|
||||
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i));
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.BOLD + "" + ChatColor.YELLOW + Lang.get("exited"));
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
|
@ -12,15 +12,6 @@
|
||||
|
||||
package me.blackvein.quests.convo.quests.menu;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||
@ -30,6 +21,15 @@ import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromp
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||
|
||||
@ -88,16 +88,16 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenNumericPromptEvent event
|
||||
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
String text = ChatColor.GOLD + getTitle(context);
|
||||
final StringBuilder text = new StringBuilder(ChatColor.GOLD + getTitle(context));
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i);
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
|
||||
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i));
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -150,23 +150,22 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
final String text = ChatColor.GOLD + getTitle(context)+ "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||
return text;
|
||||
|
||||
return ChatColor.GOLD + getTitle(context)+ "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, String input) {
|
||||
if (input == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new QuestSelectCreatePrompt(context);
|
||||
}
|
||||
input = input.trim();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
for (final Quest q : plugin.getLoadedQuests()) {
|
||||
if (q.getName().equalsIgnoreCase(input)) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
|
||||
@ -215,26 +214,29 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||
final StringBuilder text = new StringBuilder(ChatColor.GOLD + getTitle(context) + "\n");
|
||||
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList());
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
text += ChatColor.AQUA + names.get(i);
|
||||
text.append(ChatColor.AQUA).append(names.get(i));
|
||||
if (i < (names.size() - 1)) {
|
||||
text += ChatColor.GRAY + ", ";
|
||||
text.append(ChatColor.GRAY).append(", ");
|
||||
}
|
||||
}
|
||||
text += "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||
return text;
|
||||
text.append("\n").append(ChatColor.YELLOW).append(getQueryText(context));
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
final Quest q = plugin.getQuest(input);
|
||||
if (q != null) {
|
||||
plugin.getQuestFactory().loadQuest(context, q);
|
||||
@ -264,27 +266,31 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList());
|
||||
final StringBuilder text = new StringBuilder(ChatColor.GOLD + getTitle(context) + "\n");
|
||||
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName)
|
||||
.collect(Collectors.toList());
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
text += ChatColor.AQUA + names.get(i);
|
||||
text.append(ChatColor.AQUA).append(names.get(i));
|
||||
if (i < (names.size() - 1)) {
|
||||
text += ChatColor.GRAY + ", ";
|
||||
text.append(ChatColor.GRAY).append(", ");
|
||||
}
|
||||
}
|
||||
text += "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||
return text;
|
||||
text.append("\n").append(ChatColor.YELLOW).append(getQueryText(context));
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
final LinkedList<String> used = new LinkedList<String>();
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
final LinkedList<String> used = new LinkedList<>();
|
||||
final Quest found = plugin.getQuest(input);
|
||||
if (found != null) {
|
||||
for (final Quest q : plugin.getLoadedQuests()) {
|
||||
@ -362,22 +368,25 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.RED + getQueryText(context) + " (" + ChatColor.YELLOW
|
||||
+ (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n";
|
||||
final StringBuilder text = new StringBuilder(ChatColor.RED + getQueryText(context) + " (" + ChatColor.YELLOW
|
||||
+ context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n");
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += "\n" + getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i);
|
||||
text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i)
|
||||
.append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i));
|
||||
}
|
||||
return text;
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
plugin.getQuestFactory().deleteQuest(context);
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,18 +24,6 @@ public class QuestFormatException extends Exception {
|
||||
this.questId = questId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of this class with the afflicted.
|
||||
*
|
||||
* @deprecated Use {@link#QuestFormatException(String, String)}
|
||||
* @param quest The quest that an invalid value was set within.
|
||||
*/
|
||||
@Deprecated
|
||||
public QuestFormatException(final String questId) {
|
||||
this.message = "Failed to load quest of ID " + questId;
|
||||
this.questId = questId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message associated with this exception.
|
||||
*
|
||||
|
@ -28,20 +28,6 @@ public class StageFormatException extends Exception {
|
||||
this.quest = quest;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of this class with the afflicted quest and stage number.
|
||||
*
|
||||
* @deprecated Use {@link#StageFormatException(String, Quest, int)}
|
||||
* @param quest The quest that an invalid stage id was set within.
|
||||
* @param stage The invalid stage id that was set.
|
||||
*/
|
||||
@Deprecated
|
||||
public StageFormatException(final Quest quest, final int stage) {
|
||||
this.message = "Failed to load quest " + quest.getName() + " stage " + stage;
|
||||
this.quest = quest;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message associated with this exception.
|
||||
|
Loading…
Reference in New Issue
Block a user