*Context data names to CK class.

This commit is contained in:
Zino 2013-08-03 18:19:52 +02:00
parent 1d9b23a187
commit ae27c83253
8 changed files with 1037 additions and 905 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,8 @@ package me.blackvein.quests;
import java.util.LinkedList;
import me.blackvein.quests.util.CK;
import org.bukkit.Bukkit;
import org.bukkit.conversations.Conversable;
import org.bukkit.conversations.Conversation;
@ -145,7 +147,7 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
Player player = target.getPlayer();
Conversation conversation = factory.buildConversation((Conversable)player);
conversation.getContext().setSessionData("inviter", getLeader().getPlayer().getName());
conversation.getContext().setSessionData(CK.P_INVITER, getLeader().getPlayer().getName());
conversation.begin();
}
@ -192,7 +194,7 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
@Override
public String getPromptText(ConversationContext context) {
String text = partyPrefix + PINK + "You have been invited to " + PURPLE + ((String) context.getSessionData("inviter")) + PINK + "'s party.\n";
String text = partyPrefix + PINK + "You have been invited to " + PURPLE + ((String) context.getSessionData(CK.P_INVITER)) + PINK + "'s party.\n";
return text + YELLOW + "Accept Invite? " + GREEN + "Yes / No";
@ -205,7 +207,7 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
if (s.equalsIgnoreCase("Yes")) {
String inviterName = (String) context.getSessionData("inviter");
String inviterName = (String) context.getSessionData(CK.P_INVITER);
Quester quester = quests.getQuester(invited.getName());
members.add(quester);
@ -218,7 +220,7 @@ public class Party implements ConversationAbandonedListener, ColorUtil{
} else if (s.equalsIgnoreCase("No")) {
String inviterName = (String) context.getSessionData("inviter");
String inviterName = (String) context.getSessionData(CK.P_INVITER);
invited.sendMessage(partyPrefix + YELLOW + "Declined invite.");
Bukkit.getPlayerExact(inviterName).sendMessage(partyPrefix + GREEN + invited.getName() + YELLOW + " has declined your invitation.");

View File

@ -9,6 +9,7 @@ import java.util.Map.Entry;
import me.blackvein.quests.prompts.RequirementsPrompt;
import me.blackvein.quests.prompts.RewardsPrompt;
import me.blackvein.quests.prompts.StagesPrompt;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.CitizensAPI;
@ -58,8 +59,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override
public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) {
if (abandonedEvent.getContext().getSessionData("questName") != null) {
names.remove((String) abandonedEvent.getContext().getSessionData("questName"));
if (abandonedEvent.getContext().getSessionData(CK.Q_NAME) != null) {
names.remove((String) abandonedEvent.getContext().getSessionData(CK.Q_NAME));
}
Player player = (Player) abandonedEvent.getContext().getForWhom();
@ -152,31 +153,31 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public String getPromptText(ConversationContext context) {
String text =
GOLD + "- Quest: " + AQUA + context.getSessionData("questName") + GOLD + " -\n";
GOLD + "- Quest: " + AQUA + context.getSessionData(CK.Q_NAME) + GOLD + " -\n";
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set name\n";
if (context.getSessionData("askMessage") == null) {
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
text += BLUE + "" + BOLD + "2" + RESET + RED + " - Set ask message " + DARKRED + "(Required, none set)\n";
} else {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set ask message (\"" + context.getSessionData("askMessage") + "\")\n";
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set ask message (\"" + context.getSessionData(CK.Q_ASK_MESSAGE) + "\")\n";
}
if (context.getSessionData("finishMessage") == null) {
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
text += BLUE + "" + BOLD + "3" + RESET + RED + " - Set finish message " + DARKRED + "(Required, none set)\n";
} else {
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set finish message (\"" + context.getSessionData("finishMessage") + "\")\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set finish message (\"" + context.getSessionData(CK.Q_FINISH_MESSAGE) + "\")\n";
}
if (context.getSessionData("redoDelay") == null) {
if (context.getSessionData(CK.Q_REDO_DELAY) == null) {
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set redo delay (None set)\n";
} else {
//something here is throwing an exception
try{
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set redo delay (" + Quests.getTime((Long) context.getSessionData("redoDelay")) + ")\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set redo delay (" + Quests.getTime((Long) context.getSessionData(CK.Q_REDO_DELAY)) + ")\n";
}catch(Exception e){
e.printStackTrace();
}
@ -184,13 +185,13 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
//
}
if (context.getSessionData("npcStart") == null && quests.citizens != null) {
if (context.getSessionData(CK.Q_START_NPC) == null && quests.citizens != null) {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set NPC start (None set)\n";
} else if (quests.citizens != null) {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set NPC start (" + CitizensAPI.getNPCRegistry().getById((Integer) context.getSessionData("npcStart")).getName() + ")\n";
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set NPC start (" + CitizensAPI.getNPCRegistry().getById((Integer) context.getSessionData(CK.Q_START_NPC)).getName() + ")\n";
}
if (context.getSessionData("blockStart") == null) {
if (context.getSessionData(CK.Q_START_BLOCK) == null) {
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Block start (None set)\n";
@ -201,17 +202,17 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} else {
if (quests.citizens != null) {
Location l = (Location) context.getSessionData("blockStart");
Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Block start (" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")\n";
} else {
Location l = (Location) context.getSessionData("blockStart");
Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Block start (" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")\n";
}
}
if (context.getSessionData("initialEvent") == null) {
if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) {
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set initial Event (None set)\n";
@ -222,10 +223,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} else {
if (quests.citizens != null) {
String s = (String) context.getSessionData("initialEvent");
String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set initial Event (" + s + ")\n";
} else {
String s = (String) context.getSessionData("initialEvent");
String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set initial Event (" + s + ")\n";
}
@ -448,7 +449,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
context.setSessionData("questName", input);
context.setSessionData(CK.Q_NAME, input);
names.add(input);
return new CreateMenuPrompt();
@ -480,11 +481,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
return new SetNpcStartPrompt();
}
context.setSessionData("npcStart", input.intValue());
context.setSessionData(CK.Q_START_NPC, input.intValue());
return new CreateMenuPrompt();
} else if (input.intValue() == -1) {
context.setSessionData("npcStart", null);
context.setSessionData(CK.Q_START_NPC, null);
return new CreateMenuPrompt();
} else if (input.intValue() == -2) {
return new CreateMenuPrompt();
@ -517,7 +518,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
Block block = selectedBlockStarts.get(player);
if (block != null) {
Location loc = block.getLocation();
context.setSessionData("blockStart", loc);
context.setSessionData(CK.Q_START_BLOCK, loc);
selectedBlockStarts.remove(player);
} else {
player.sendMessage(ChatColor.RED + "You must select a block first.");
@ -534,7 +535,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} else if (input.equalsIgnoreCase("clear")) {
selectedBlockStarts.remove(player);
context.setSessionData("blockStart", null);
context.setSessionData(CK.Q_START_BLOCK, null);
return new CreateMenuPrompt();
}
@ -562,8 +563,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (q.name.equalsIgnoreCase(input)) {
String s = null;
if (context.getSessionData("edit") != null) {
s = (String) context.getSessionData("edit");
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
s = (String) context.getSessionData(CK.ED_QUEST_EDIT);
}
if (s != null && s.equalsIgnoreCase(input) == false) {
@ -586,8 +587,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
names.remove((String) context.getSessionData("questName"));
context.setSessionData("questName", input);
names.remove((String) context.getSessionData(CK.Q_NAME));
context.setSessionData(CK.Q_NAME, input);
names.add(input);
}
@ -610,7 +611,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) {
context.setSessionData("askMessage", input);
context.setSessionData(CK.Q_ASK_MESSAGE, input);
}
return new CreateMenuPrompt();
@ -631,7 +632,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) {
context.setSessionData("finishMessage", input);
context.setSessionData(CK.Q_FINISH_MESSAGE, input);
}
return new CreateMenuPrompt();
@ -679,12 +680,12 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
player.sendMessage(RED + input + YELLOW + " is not a valid event name!");
return new InitialEventPrompt();
} else {
context.setSessionData("initialEvent", found.getName());
context.setSessionData(CK.Q_INITIAL_EVENT, found.getName());
return new CreateMenuPrompt();
}
} else if (input.equalsIgnoreCase("clear")) {
context.setSessionData("initialEvent", null);
context.setSessionData(CK.Q_INITIAL_EVENT, null);
player.sendMessage(YELLOW + "Initial Event cleared.");
return new CreateMenuPrompt();
} else {
@ -709,9 +710,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (input.longValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Amount must be a positive number.");
} else if (input.longValue() == 0) {
context.setSessionData("redoDelay", null);
context.setSessionData(CK.Q_REDO_DELAY, null);
} else if (input.longValue() != -1) {
context.setSessionData("redoDelay", input.longValue());
context.setSessionData(CK.Q_REDO_DELAY, input.longValue());
}
return new CreateMenuPrompt();
@ -727,7 +728,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
String text = GREEN
+ "1 - Yes\n"
+ "2 - No";
return ChatColor.YELLOW + "Finish and save \"" + AQUA + context.getSessionData("questName") + YELLOW + "\"?\n" + text;
return ChatColor.YELLOW + "Finish and save \"" + AQUA + context.getSessionData(CK.Q_NAME) + YELLOW + "\"?\n" + text;
}
@ -736,10 +737,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) {
if (context.getSessionData("askMessage") == null) {
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
context.getForWhom().sendRawMessage(RED + "You must set an ask message!");
return new CreateMenuPrompt();
} else if (context.getSessionData("finishMessage") == null) {
} else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
context.getForWhom().sendRawMessage(RED + "You must set a finish message!");
return new CreateMenuPrompt();
} else if (StagesPrompt.getStages(context) == 0) {
@ -812,11 +813,12 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
}
public static void saveQuest(ConversationContext cc, ConfigurationSection cs) {
@SuppressWarnings("unchecked")
public static void saveQuest(ConversationContext cc, ConfigurationSection cs) {
String edit = null;
if (cc.getSessionData("edit") != null) {
edit = (String) cc.getSessionData("edit");
if (cc.getSessionData(CK.ED_QUEST_EDIT) != null) {
edit = (String) cc.getSessionData(CK.ED_QUEST_EDIT);
}
if (edit != null) {
@ -837,9 +839,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
String name = (String) cc.getSessionData("questName");
String desc = (String) cc.getSessionData("askMessage");
String finish = (String) cc.getSessionData("finishMessage");
String name = (String) cc.getSessionData(CK.Q_NAME);
String desc = (String) cc.getSessionData(CK.Q_ASK_MESSAGE);
String finish = (String) cc.getSessionData(CK.Q_FINISH_MESSAGE);
Long redo = null;
Integer npcStart = null;
String blockStart = null;
@ -865,82 +867,82 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData("redoDelay") != null) {
redo = (Long) cc.getSessionData("redoDelay");
if (cc.getSessionData(CK.Q_REDO_DELAY) != null) {
redo = (Long) cc.getSessionData(CK.Q_REDO_DELAY);
}
if (cc.getSessionData("npcStart") != null) {
npcStart = (Integer) cc.getSessionData("npcStart");
if (cc.getSessionData(CK.Q_START_NPC) != null) {
npcStart = (Integer) cc.getSessionData(CK.Q_START_NPC);
}
if (cc.getSessionData("blockStart") != null) {
blockStart = Quests.getLocationInfo((Location) cc.getSessionData("blockStart"));
if (cc.getSessionData(CK.Q_START_BLOCK) != null) {
blockStart = Quests.getLocationInfo((Location) cc.getSessionData(CK.Q_START_BLOCK));
}
if (cc.getSessionData("moneyReq") != null) {
moneyReq = (Integer) cc.getSessionData("moneyReq");
if (cc.getSessionData(CK.REQ_MONEY) != null) {
moneyReq = (Integer) cc.getSessionData(CK.REQ_MONEY);
}
if (cc.getSessionData("questPointsReq") != null) {
questPointsReq = (Integer) cc.getSessionData("questPointsReq");
if (cc.getSessionData(CK.REQ_QUEST_POINTS) != null) {
questPointsReq = (Integer) cc.getSessionData(CK.REQ_QUEST_POINTS);
}
if (cc.getSessionData("itemReqs") != null) {
itemReqs = (LinkedList<ItemStack>) cc.getSessionData("itemReqs");
removeItemReqs = (LinkedList<Boolean>) cc.getSessionData("removeItemReqs");
if (cc.getSessionData(CK.REQ_ITEMS) != null) {
itemReqs = (LinkedList<ItemStack>) cc.getSessionData(CK.REQ_ITEMS);
removeItemReqs = (LinkedList<Boolean>) cc.getSessionData(CK.REQ_ITEMS_REMOVE);
}
if (cc.getSessionData("permissionReqs") != null) {
permReqs = (LinkedList<String>) cc.getSessionData("permissionReqs");
if (cc.getSessionData(CK.REQ_PERMISSION) != null) {
permReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_PERMISSION);
}
if (cc.getSessionData("questReqs") != null) {
questReqs = (LinkedList<String>) cc.getSessionData("questReqs");
if (cc.getSessionData(CK.REQ_QUEST) != null) {
questReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_QUEST);
}
if (cc.getSessionData("questBlocks") != null) {
questBlocks = (LinkedList<String>) cc.getSessionData("questBlocks");
if (cc.getSessionData(CK.REQ_QUEST_BLOCK) != null) {
questBlocks = (LinkedList<String>) cc.getSessionData(CK.REQ_QUEST_BLOCK);
}
if (cc.getSessionData("failMessage") != null) {
failMessage = (String) cc.getSessionData("failMessage");
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
failMessage = (String) cc.getSessionData(CK.Q_FAIL_MESSAGE);
}
if (cc.getSessionData("initialEvent") != null) {
initialEvent = (String) cc.getSessionData("initialEvent");
if (cc.getSessionData(CK.Q_INITIAL_EVENT) != null) {
initialEvent = (String) cc.getSessionData(CK.Q_INITIAL_EVENT);
}
if (cc.getSessionData("moneyRew") != null) {
moneyRew = (Integer) cc.getSessionData("moneyRew");
if (cc.getSessionData(CK.REW_MONEY) != null) {
moneyRew = (Integer) cc.getSessionData(CK.REW_MONEY);
}
if (cc.getSessionData("questPointsRew") != null) {
questPointsRew = (Integer) cc.getSessionData("questPointsRew");
if (cc.getSessionData(CK.REW_QUEST_POINTS) != null) {
questPointsRew = (Integer) cc.getSessionData(CK.REW_QUEST_POINTS);
}
if (cc.getSessionData("itemRews") != null) {
for (ItemStack is : (LinkedList<ItemStack>) cc.getSessionData("itemRews")) {
if (cc.getSessionData(CK.REW_ITEMS) != null) {
for (ItemStack is : (LinkedList<ItemStack>) cc.getSessionData(CK.REW_ITEMS)) {
itemRews.add(ItemUtil.serialize(is));
}
}
if (cc.getSessionData("expRew") != null) {
expRew = (Integer) cc.getSessionData("expRew");
if (cc.getSessionData(CK.REW_EXP) != null) {
expRew = (Integer) cc.getSessionData(CK.REW_EXP);
}
if (cc.getSessionData("commandRews") != null) {
commandRews = (LinkedList<String>) cc.getSessionData("commandRews");
if (cc.getSessionData(CK.REW_COMMAND) != null) {
commandRews = (LinkedList<String>) cc.getSessionData(CK.REW_COMMAND);
}
if (cc.getSessionData("permissionRews") != null) {
permRews = (LinkedList<String>) cc.getSessionData("permissionRews");
if (cc.getSessionData(CK.REW_PERMISSION) != null) {
permRews = (LinkedList<String>) cc.getSessionData(CK.REW_PERMISSION);
}
if (cc.getSessionData("mcMMOSkillRews") != null) {
mcMMOSkillRews = (LinkedList<String>) cc.getSessionData("mcMMOSkillRews");
mcMMOSkillAmounts = (LinkedList<Integer>) cc.getSessionData("mcMMOSkillAmounts");
if (cc.getSessionData(CK.REW_MCMMO_SKILLS) != null) {
mcMMOSkillRews = (LinkedList<String>) cc.getSessionData(CK.REW_MCMMO_SKILLS);
mcMMOSkillAmounts = (LinkedList<Integer>) cc.getSessionData(CK.REW_MCMMO_AMOUNTS);
}
@ -951,7 +953,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set("redo-delay", redo);
cs.set("ask-message", desc);
cs.set("finish-message", finish);
cs.set("event", initialEvent);
cs.set(CK.S_EVENT, initialEvent);
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false)) {
@ -1104,96 +1106,96 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData(pref + "breakIds") != null) {
breakIds = (LinkedList<Integer>) cc.getSessionData(pref + "breakIds");
breakAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "breakAmounts");
if (cc.getSessionData(pref + CK.S_BREAK_IDS) != null) {
breakIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_IDS);
breakAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_AMOUNTS);
}
if (cc.getSessionData(pref + "damageIds") != null) {
damageIds = (LinkedList<Integer>) cc.getSessionData(pref + "damageIds");
damageAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "damageAmounts");
if (cc.getSessionData(pref + CK.S_DAMAGE_IDS) != null) {
damageIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DAMAGE_IDS);
damageAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS);
}
if (cc.getSessionData(pref + "placeIds") != null) {
placeIds = (LinkedList<Integer>) cc.getSessionData(pref + "placeIds");
placeAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "placeAmounts");
if (cc.getSessionData(pref + CK.S_PLACE_IDS) != null) {
placeIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_PLACE_IDS);
placeAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_PLACE_AMOUNTS);
}
if (cc.getSessionData(pref + "useIds") != null) {
useIds = (LinkedList<Integer>) cc.getSessionData(pref + "useIds");
useAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "useAmounts");
if (cc.getSessionData(pref + CK.S_USE_IDS) != null) {
useIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_USE_IDS);
useAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_USE_AMOUNTS);
}
if (cc.getSessionData(pref + "cutIds") != null) {
cutIds = (LinkedList<Integer>) cc.getSessionData(pref + "cutIds");
cutAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "cutAmounts");
if (cc.getSessionData(pref + CK.S_CUT_IDS) != null) {
cutIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_CUT_IDS);
cutAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_CUT_AMOUNTS);
}
if (cc.getSessionData(pref + "fish") != null) {
fish = (Integer) cc.getSessionData(pref + "fish");
if (cc.getSessionData(pref + CK.S_FISH) != null) {
fish = (Integer) cc.getSessionData(pref + CK.S_FISH);
}
if (cc.getSessionData(pref + "playerKill") != null) {
players = (Integer) cc.getSessionData(pref + "playerKill");
if (cc.getSessionData(pref + CK.S_PLAYER_KILL) != null) {
players = (Integer) cc.getSessionData(pref + CK.S_PLAYER_KILL);
}
if (cc.getSessionData(pref + "enchantTypes") != null) {
enchantments = (LinkedList<String>) cc.getSessionData(pref + "enchantTypes");
enchantmentIds = (LinkedList<Integer>) cc.getSessionData(pref + "enchantIds");
enchantmentAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "enchantAmounts");
if (cc.getSessionData(pref + CK.S_ENCHANT_TYPES) != null) {
enchantments = (LinkedList<String>) cc.getSessionData(pref + CK.S_ENCHANT_TYPES);
enchantmentIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_ENCHANT_IDS);
enchantmentAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
}
if (cc.getSessionData(pref + "deliveryItems") != null) {
deliveryItems = (LinkedList<ItemStack>) cc.getSessionData(pref + "deliveryItems");
deliveryNPCIds = (LinkedList<Integer>) cc.getSessionData(pref + "deliveryNPCs");
deliveryMessages = (LinkedList<String>) cc.getSessionData(pref + "deliveryMessages");
if (cc.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) {
deliveryItems = (LinkedList<ItemStack>) cc.getSessionData(pref + CK.S_DELIVERY_ITEMS);
deliveryNPCIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DELIVERY_NPCS);
deliveryMessages = (LinkedList<String>) cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES);
}
if (cc.getSessionData(pref + "npcIdsToTalkTo") != null) {
npcTalkIds = (LinkedList<Integer>) cc.getSessionData(pref + "npcIdsToTalkTo");
if (cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null) {
npcTalkIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO);
}
if (cc.getSessionData(pref + "npcIdsToKill") != null) {
npcKillIds = (LinkedList<Integer>) cc.getSessionData(pref + "npcIdsToKill");
npcKillAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "npcAmountsToKill");
if (cc.getSessionData(pref + CK.S_NPCS_TO_KILL) != null) {
npcKillIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_NPCS_TO_KILL);
npcKillAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
}
if (cc.getSessionData(pref + "bossIds") != null) {
bossIds = (LinkedList<String>) cc.getSessionData(pref + "bossIds");
bossAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "bossAmounts");
if (cc.getSessionData(pref + CK.S_BOSS_IDS) != null) {
bossIds = (LinkedList<String>) cc.getSessionData(pref + CK.S_BOSS_IDS);
bossAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BOSS_AMOUNTS);
}
if (cc.getSessionData(pref + "mobTypes") != null) {
mobs = (LinkedList<String>) cc.getSessionData(pref + "mobTypes");
mobAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "mobAmounts");
if (cc.getSessionData(pref + "killLocations") != null) {
mobLocs = (LinkedList<String>) cc.getSessionData(pref + "killLocations");
mobRadii = (LinkedList<Integer>) cc.getSessionData(pref + "killLocationRadii");
mobLocNames = (LinkedList<String>) cc.getSessionData(pref + "killLocationNames");
if (cc.getSessionData(pref + CK.S_MOB_TYPES) != null) {
mobs = (LinkedList<String>) cc.getSessionData(pref + CK.S_MOB_TYPES);
mobAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_MOB_AMOUNTS);
if (cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) {
mobLocs = (LinkedList<String>) cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS);
mobRadii = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS);
mobLocNames = (LinkedList<String>) cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES);
}
}
if (cc.getSessionData(pref + "tameTypes") != null) {
tames = (LinkedList<String>) cc.getSessionData(pref + "tameTypes");
tameAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "tameAmounts");
if (cc.getSessionData(pref + CK.S_TAME_TYPES) != null) {
tames = (LinkedList<String>) cc.getSessionData(pref + CK.S_TAME_TYPES);
tameAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_TAME_AMOUNTS);
}
if (cc.getSessionData(pref + "shearColors") != null) {
shearColors = (LinkedList<String>) cc.getSessionData(pref + "shearColors");
shearAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "shearAmounts");
if (cc.getSessionData(pref + CK.S_SHEAR_COLORS) != null) {
shearColors = (LinkedList<String>) cc.getSessionData(pref + CK.S_SHEAR_COLORS);
shearAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS);
}
if (cc.getSessionData(pref + "event") != null) {
event = (String) cc.getSessionData(pref + "event");
if (cc.getSessionData(pref + CK.S_EVENT) != null) {
event = (String) cc.getSessionData(pref + CK.S_EVENT);
}
if (cc.getSessionData(pref + "delay") != null) {
delay = (Long) cc.getSessionData(pref + "delay");
delayMessage = (String) cc.getSessionData(pref + "delayMessage");
if (cc.getSessionData(pref + CK.S_DELAY) != null) {
delay = (Long) cc.getSessionData(pref + CK.S_DELAY);
delayMessage = (String) cc.getSessionData(pref + CK.S_DELAY_MESSAGE);
}
if (cc.getSessionData(pref + "denizen") != null) {
script = (String) cc.getSessionData(pref + "denizen");
if (cc.getSessionData(pref + CK.S_DENIZEN) != null) {
script = (String) cc.getSessionData(pref + CK.S_DENIZEN);
}
if (breakIds != null && breakIds.isEmpty() == false) {
@ -1254,8 +1256,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
stage.set("sheep-to-shear", shearColors);
stage.set("sheep-amounts", shearAmounts);
stage.set("script-to-run", script);
stage.set("event", event);
stage.set("delay", delay);
stage.set(CK.S_EVENT, event);
stage.set(CK.S_DELAY, delay);
stage.set("delay-message", delayMessage);
}
@ -1281,77 +1283,77 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public static void loadQuest(ConversationContext cc, Quest q) {
cc.setSessionData("edit", q.name);
cc.setSessionData("questName", q.name);
cc.setSessionData(CK.ED_QUEST_EDIT, q.name);
cc.setSessionData(CK.Q_NAME, q.name);
if (q.npcStart != null) {
cc.setSessionData("npcStart", q.npcStart.getId());
cc.setSessionData(CK.Q_START_NPC, q.npcStart.getId());
}
cc.setSessionData("blockStart", q.blockStart);
cc.setSessionData(CK.Q_START_BLOCK, q.blockStart);
if (q.redoDelay != -1) {
cc.setSessionData("redoDelay", q.redoDelay);
cc.setSessionData(CK.Q_REDO_DELAY, q.redoDelay);
}
cc.setSessionData("askMessage", q.description);
cc.setSessionData("finishMessage", q.finished);
cc.setSessionData(CK.Q_ASK_MESSAGE, q.description);
cc.setSessionData(CK.Q_FINISH_MESSAGE, q.finished);
if (q.initialEvent != null) {
cc.setSessionData("initialEvent", q.initialEvent.getName());
cc.setSessionData(CK.Q_INITIAL_EVENT, q.initialEvent.getName());
}
//Requirements
if (q.moneyReq != 0) {
cc.setSessionData("moneyReq", q.moneyReq);
cc.setSessionData(CK.REQ_MONEY, q.moneyReq);
}
if (q.questPointsReq != 0) {
cc.setSessionData("questPointsReq", q.questPointsReq);
cc.setSessionData(CK.REQ_QUEST_POINTS, q.questPointsReq);
}
if (q.items.isEmpty() == false) {
cc.setSessionData("itemReqs", q.items);
cc.setSessionData("removeItemReqs", q.removeItems);
cc.setSessionData(CK.REQ_ITEMS, q.items);
cc.setSessionData(CK.REQ_ITEMS_REMOVE, q.removeItems);
}
if (q.neededQuests.isEmpty() == false) {
cc.setSessionData("questReqs", q.neededQuests);
cc.setSessionData(CK.REQ_QUEST, q.neededQuests);
}
if (q.blockQuests.isEmpty() == false) {
cc.setSessionData("questBlocks", q.blockQuests);
cc.setSessionData(CK.REQ_QUEST_BLOCK, q.blockQuests);
}
if (q.permissionReqs.isEmpty() == false) {
cc.setSessionData("permissionReqs", q.permissionReqs);
cc.setSessionData(CK.REQ_PERMISSION, q.permissionReqs);
}
if (q.failRequirements != null) {
cc.setSessionData("failMessage", q.failRequirements);
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
}
//
//Rewards
if (q.moneyReward != 0) {
cc.setSessionData("moneyRew", q.moneyReward);
cc.setSessionData(CK.REW_MONEY, q.moneyReward);
}
if (q.questPoints != 0) {
cc.setSessionData("questPointsRew", q.questPoints);
cc.setSessionData(CK.REW_QUEST_POINTS, q.questPoints);
}
if (q.exp != 0) {
cc.setSessionData("expRew", q.exp);
cc.setSessionData(CK.REW_EXP, q.exp);
}
if (q.commands.isEmpty() == false) {
cc.setSessionData("commandRews", q.commands);
cc.setSessionData(CK.REW_COMMAND, q.commands);
}
if (q.permissions.isEmpty() == false) {
cc.setSessionData("permissionRews", q.permissions);
cc.setSessionData(CK.REW_PERMISSION, q.permissions);
}
if (q.mcmmoSkills.isEmpty() == false) {
cc.setSessionData("mcMMOSkillRews", q.mcmmoSkills);
cc.setSessionData("mcMMOSkillAmounts", q.mcmmoAmounts);
cc.setSessionData(CK.REW_MCMMO_SKILLS, q.mcmmoSkills);
cc.setSessionData(CK.REW_MCMMO_AMOUNTS, q.mcmmoAmounts);
}
//
@ -1365,15 +1367,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Integer> ids = new LinkedList<Integer>();
LinkedList<Integer> amnts = new LinkedList<Integer>();
for (Entry e : stage.blocksToBreak.entrySet()) {
for (Entry<Material, Integer> e : stage.blocksToBreak.entrySet()) {
ids.add(((Material) e.getKey()).getId());
amnts.add((Integer) e.getValue());
}
cc.setSessionData(pref + "breakIds", ids);
cc.setSessionData(pref + "breakAmounts", amnts);
cc.setSessionData(pref + CK.S_BREAK_IDS, ids);
cc.setSessionData(pref + CK.S_BREAK_AMOUNTS, amnts);
}
@ -1383,15 +1385,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Integer> ids = new LinkedList<Integer>();
LinkedList<Integer> amnts = new LinkedList<Integer>();
for (Entry e : stage.blocksToDamage.entrySet()) {
for (Entry<Material, Integer> e : stage.blocksToDamage.entrySet()) {
ids.add(((Material) e.getKey()).getId());
amnts.add((Integer) e.getValue());
}
cc.setSessionData(pref + "damageIds", ids);
cc.setSessionData(pref + "damageAmounts", amnts);
cc.setSessionData(pref + CK.S_DAMAGE_IDS, ids);
cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amnts);
}
@ -1401,15 +1403,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Integer> ids = new LinkedList<Integer>();
LinkedList<Integer> amnts = new LinkedList<Integer>();
for (Entry e : stage.blocksToPlace.entrySet()) {
for (Entry<Material, Integer> e : stage.blocksToPlace.entrySet()) {
ids.add(((Material) e.getKey()).getId());
amnts.add((Integer) e.getValue());
}
cc.setSessionData(pref + "placeIds", ids);
cc.setSessionData(pref + "placeAmounts", amnts);
cc.setSessionData(pref + CK.S_PLACE_IDS, ids);
cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, amnts);
}
@ -1418,15 +1420,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Integer> ids = new LinkedList<Integer>();
LinkedList<Integer> amnts = new LinkedList<Integer>();
for (Entry e : stage.blocksToUse.entrySet()) {
for (Entry<Material, Integer> e : stage.blocksToUse.entrySet()) {
ids.add(((Material) e.getKey()).getId());
amnts.add((Integer) e.getValue());
}
cc.setSessionData(pref + "useIds", ids);
cc.setSessionData(pref + "useAmounts", amnts);
cc.setSessionData(pref + CK.S_USE_IDS, ids);
cc.setSessionData(pref + CK.S_USE_AMOUNTS, amnts);
}
@ -1436,26 +1438,26 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Integer> ids = new LinkedList<Integer>();
LinkedList<Integer> amnts = new LinkedList<Integer>();
for (Entry e : stage.blocksToCut.entrySet()) {
for (Entry<Material, Integer> e : stage.blocksToCut.entrySet()) {
ids.add(((Material) e.getKey()).getId());
amnts.add((Integer) e.getValue());
}
cc.setSessionData(pref + "cutIds", ids);
cc.setSessionData(pref + "cutAmounts", amnts);
cc.setSessionData(pref + CK.S_CUT_IDS, ids);
cc.setSessionData(pref + CK.S_CUT_AMOUNTS, amnts);
}
if (stage.fishToCatch != null) {
cc.setSessionData(pref + "fish", stage.fishToCatch);
cc.setSessionData(pref + CK.S_FISH, stage.fishToCatch);
}
if (stage.playersToKill != null) {
cc.setSessionData(pref + "playerKill", stage.playersToKill);
cc.setSessionData(pref + CK.S_PLAYER_KILL, stage.playersToKill);
}
@ -1477,9 +1479,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
cc.setSessionData(pref + "enchantTypes", enchants);
cc.setSessionData(pref + "enchantIds", ids);
cc.setSessionData(pref + "enchantAmounts", amounts);
cc.setSessionData(pref + CK.S_ENCHANT_TYPES, enchants);
cc.setSessionData(pref + CK.S_ENCHANT_IDS, ids);
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts);
}
@ -1497,9 +1499,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
npcs.add(n.getId());
}
cc.setSessionData(pref + "deliveryItems", items);
cc.setSessionData(pref + "deliveryNPCs", npcs);
cc.setSessionData(pref + "deliveryMessages", stage.deliverMessages);
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
cc.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
cc.setSessionData(pref + CK.S_DELIVERY_MESSAGES, stage.deliverMessages);
}
@ -1511,7 +1513,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
npcs.add(n.getId());
}
cc.setSessionData(pref + "npcIdsToTalkTo", npcs);
cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
}
@ -1523,16 +1525,16 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
npcs.add(n.getId());
}
cc.setSessionData(pref + "npcIdsToKill", npcs);
cc.setSessionData(pref + "npcAmountsToKill", stage.citizenNumToKill);
cc.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
cc.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, stage.citizenNumToKill);
}
if (stage.bossesToKill.isEmpty() == false) {
cc.setSessionData(pref + "bossIds", stage.bossesToKill);
cc.setSessionData(pref + "bossAmounts", stage.bossAmountsToKill);
cc.setSessionData(pref + CK.S_BOSS_IDS, stage.bossesToKill);
cc.setSessionData(pref + CK.S_BOSS_AMOUNTS, stage.bossAmountsToKill);
}
@ -1544,8 +1546,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
mobs.add(Quester.prettyMobString(et));
}
cc.setSessionData(pref + "mobTypes", mobs);
cc.setSessionData(pref + "mobAmounts", stage.mobNumToKill);
cc.setSessionData(pref + CK.S_MOB_TYPES, mobs);
cc.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.mobNumToKill);
if (stage.locationsToKillWithin.isEmpty() == false) {
@ -1554,9 +1556,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
locs.add(Quests.getLocationInfo(l));
}
cc.setSessionData(pref + "killLocations", locs);
cc.setSessionData(pref + "killLocationRadii", stage.radiiToKillWithin);
cc.setSessionData(pref + "killLocationNames", stage.areaNames);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locs);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, stage.radiiToKillWithin);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, stage.areaNames);
}
@ -1570,9 +1572,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
locs.add(Quests.getLocationInfo(l));
}
cc.setSessionData(pref + "reachLocations", locs);
cc.setSessionData(pref + "reachLocationRadii", stage.radiiToReachWithin);
cc.setSessionData(pref + "reachLocationNames", stage.locationNames);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS, locs);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, stage.radiiToReachWithin);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.locationNames);
}
@ -1589,8 +1591,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
cc.setSessionData(pref + "tameTypes", mobs);
cc.setSessionData(pref + "tameAmounts", amnts);
cc.setSessionData(pref + CK.S_TAME_TYPES, mobs);
cc.setSessionData(pref + CK.S_TAME_AMOUNTS, amnts);
}
@ -1605,26 +1607,26 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
amnts.add(e.getValue());
}
cc.setSessionData(pref + "shearColors", colors);
cc.setSessionData(pref + "shearAmounts", amnts);
cc.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
cc.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amnts);
}
if (stage.event != null) {
cc.setSessionData(pref + "event", stage.event.getName());
cc.setSessionData(pref + CK.S_EVENT, stage.event.getName());
}
if (stage.delay != -1) {
cc.setSessionData(pref + "delay", stage.delay);
cc.setSessionData(pref + CK.S_DELAY, stage.delay);
if (stage.delayMessage != null) {
cc.setSessionData(pref + "delayMessage", stage.delayMessage);
cc.setSessionData(pref + CK.S_DELAY_MESSAGE, stage.delayMessage);
}
}
if (stage.script != null) {
cc.setSessionData(pref + "denizen", stage.script);
cc.setSessionData(pref + CK.S_DENIZEN, stage.script);
}
}
@ -1670,10 +1672,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (used.isEmpty()) {
context.setSessionData("delQuest", quest.name);
context.setSessionData(CK.ED_QUEST_DELETE, quest.name);
return new DeletePrompt();
} else {
((Player) context.getForWhom()).sendMessage(RED + "The following Quests have \"" + PURPLE + context.getSessionData("delQuest") + RED + "\" as a requirement:");
((Player) context.getForWhom()).sendMessage(RED + "The following Quests have \"" + PURPLE + context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\" as a requirement:");
for (String s : used) {
((Player) context.getForWhom()).sendMessage(RED + "- " + DARKRED + s);
}
@ -1700,7 +1702,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public String getPromptText(ConversationContext context) {
String text =
RED + "Are you sure you want to delete the Quest " + " \"" + GOLD + (String) context.getSessionData("delQuest") + RED + "\"?\n";
RED + "Are you sure you want to delete the Quest " + " \"" + GOLD + (String) context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\"?\n";
text += YELLOW + Lang.get("yes") + "/" + Lang.get("no");
return text;
@ -1734,7 +1736,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
return;
}
String quest = (String) context.getSessionData("delQuest");
String quest = (String) context.getSessionData(CK.ED_QUEST_DELETE);
ConfigurationSection sec = data.getConfigurationSection("quests");
for (String key : sec.getKeys(false)) {

File diff suppressed because it is too large Load Diff

View File

@ -5,15 +5,20 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import org.bukkit.Material;
import org.bukkit.conversations.*;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.inventory.ItemStack;
@ -36,28 +41,28 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
String text;
text = DARKAQUA + "- " + AQUA + context.getSessionData("questName") + AQUA + " | Requirements -\n";
text = DARKAQUA + "- " + AQUA + context.getSessionData(CK.Q_NAME) + AQUA + " | Requirements -\n";
if(context.getSessionData("moneyReq") == null)
if(context.getSessionData(CK.REQ_MONEY) == null)
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money requirement " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{
int moneyReq = (Integer) context.getSessionData("moneyReq");
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money requirement (" + moneyReq + " " + (moneyReq > 1 ? Quests.getCurrency(true) : Quests.getCurrency(false)) + ")\n";
}
if(context.getSessionData("questPointsReq") == null)
if(context.getSessionData(CK.REQ_QUEST_POINTS) == null)
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + "(" + AQUA + context.getSessionData("questPointsReq") + " Quest Points" + GRAY + ")\n";
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + "(" + AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " Quest Points" + GRAY + ")\n";
}
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set item requirements\n";
if(context.getSessionData("permissionReqs") == null)
if(context.getSessionData(CK.REQ_PERMISSION) == null)
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements\n";
List<String> perms = (List<String>) context.getSessionData("permissionReqs");
List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION);
for(String s : perms){
@ -66,11 +71,11 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
}
if(context.getSessionData("questReqs") == null)
if(context.getSessionData(CK.REQ_QUEST) == null)
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements\n";
List<String> qs = (List<String>) context.getSessionData("questReqs");
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST);
for(String s : qs){
@ -79,11 +84,11 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
}
if(context.getSessionData("questBlocks") == null)
if(context.getSessionData(CK.REQ_QUEST_BLOCK) == null)
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest that mustn't be done " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest requirements\n";
List<String> qs = (List<String>) context.getSessionData("questBlocks");
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
for(String s : qs){
@ -92,12 +97,12 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
}
if(context.getSessionData("moneyReq") == null && context.getSessionData("questPointsReq") == null && context.getSessionData("itemReqs") == null && context.getSessionData("permissionReqs") == null && context.getSessionData("questReqs") == null && context.getSessionData("questBlocks") == null){
if(context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null){
text += GRAY + "" + BOLD + "7 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
}else if(context.getSessionData("failMessage") == null){
}else if(context.getSessionData(CK.Q_FAIL_MESSAGE) == null){
text += RED + "" + BOLD + "7 - " + RESET + RED + "Set fail requirements message (Required)\n";
}else{
text += BLUE + "" + BOLD + "7 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData("failMessage") + "\"" + GRAY + ")\n";
text += BLUE + "" + BOLD + "7 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n";
}
text += GREEN + "" + BOLD + "8" + RESET + YELLOW + " - Done";
@ -125,9 +130,9 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}else if(input.equalsIgnoreCase("7")){
return new FailMessagePrompt();
}else if(input.equalsIgnoreCase("8")){
if(context.getSessionData("moneyReq") != null || context.getSessionData("questPointsReq") != null || context.getSessionData("itemReqs") != null || context.getSessionData("permissionReqs") != null || context.getSessionData("questReqs") != null || context.getSessionData("questBlocks") != null){
if(context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null || context.getSessionData(CK.REQ_PERMISSION) != null || context.getSessionData(CK.REQ_QUEST) != null || context.getSessionData(CK.REQ_QUEST_BLOCK) != null){
if(context.getSessionData("failMessage") == null){
if(context.getSessionData(CK.Q_FAIL_MESSAGE) == null){
context.getForWhom().sendRawMessage(RED + "You must set a fail requirements message!");
return new RequirementsPrompt(quests, factory);
}
@ -158,11 +163,11 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}else if(input.intValue() == -1){
return new RequirementsPrompt(quests, factory);
}else if(input.intValue() == 0){
context.setSessionData("moneyReq", null);
context.setSessionData(CK.REQ_MONEY, null);
return new RequirementsPrompt(quests, factory);
}
context.setSessionData("moneyReq", input.intValue());
context.setSessionData(CK.REQ_MONEY, input.intValue());
return new RequirementsPrompt(quests, factory);
}
@ -187,11 +192,11 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}else if(input.intValue() == -1){
return new RequirementsPrompt(quests, factory);
}else if(input.intValue() == 0){
context.setSessionData("questPointsReq", null);
context.setSessionData(CK.REQ_QUEST_POINTS, null);
return new RequirementsPrompt(quests, factory);
}
context.setSessionData("questPointsReq", input.intValue());
context.setSessionData(CK.REQ_QUEST_POINTS, input.intValue());
return new RequirementsPrompt(quests, factory);
}
@ -276,17 +281,17 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
});
if (isRequiredQuest) {
context.setSessionData("questReqs", questNames);
context.setSessionData(CK.REQ_QUEST, questNames);
} else {
context.setSessionData("questBlocks", questNames);
context.setSessionData(CK.REQ_QUEST_BLOCK, questNames);
}
}else if(input.equalsIgnoreCase("clear")){
if (isRequiredQuest) {
context.setSessionData("questReqs", null);
context.setSessionData(CK.REQ_QUEST, null);
} else {
context.setSessionData("questBlocks", null);
context.setSessionData(CK.REQ_QUEST_BLOCK, null);
}
}
@ -310,14 +315,14 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
// Check/add newly made item
if(context.getSessionData("newItem") != null){
if(context.getSessionData("itemReqs") != null){
if(context.getSessionData(CK.REQ_ITEMS) != null){
List<ItemStack> itemRews = getItems(context);
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData("itemReqs", itemRews);
context.setSessionData(CK.REQ_ITEMS, itemRews);
}else{
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData("itemReqs", itemRews);
context.setSessionData(CK.REQ_ITEMS, itemRews);
}
context.setSessionData("newItem", null);
@ -326,7 +331,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
String text = GOLD + "- Item Requirements -\n";
if(context.getSessionData("itemReqs") == null){
if(context.getSessionData(CK.REQ_ITEMS) == null){
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n";
text += GRAY + "2 - Set remove items (No items set)\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n";
@ -342,7 +347,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n";
if(context.getSessionData("removeItemReqs") == null){
if(context.getSessionData(CK.REQ_ITEMS_REMOVE) == null){
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set remove items (No values set)\n";
}else{
@ -370,7 +375,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
if(input.equalsIgnoreCase("1")){
return new ItemStackPrompt(ItemListPrompt.this);
}else if(input.equalsIgnoreCase("2")){
if(context.getSessionData("itemReqs") == null){
if(context.getSessionData(CK.REQ_ITEMS) == null){
context.getForWhom().sendRawMessage(RED + "You must add at least one item first!");
return new ItemListPrompt();
}else{
@ -378,21 +383,21 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
}else if(input.equalsIgnoreCase("3")){
context.getForWhom().sendRawMessage(YELLOW + "Item requirements cleared.");
context.setSessionData("itemReqs", null);
context.setSessionData("removeItemReqs", null);
context.setSessionData(CK.REQ_ITEMS, null);
context.setSessionData(CK.REQ_ITEMS_REMOVE, null);
return new ItemListPrompt();
}else if(input.equalsIgnoreCase("4")){
int one;
int two;
if(context.getSessionData("itemReqs") != null)
one = ((List<ItemStack>) context.getSessionData("itemReqs")).size();
if(context.getSessionData(CK.REQ_ITEMS) != null)
one = ((List<ItemStack>) context.getSessionData(CK.REQ_ITEMS)).size();
else
one = 0;
if(context.getSessionData("removeItemReqs") != null)
two = ((List<Boolean>) context.getSessionData("removeItemReqs")).size();
if(context.getSessionData(CK.REQ_ITEMS_REMOVE) != null)
two = ((List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE)).size();
else
two = 0;
@ -408,11 +413,11 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
private List<ItemStack> getItems(ConversationContext context){
return (List<ItemStack>) context.getSessionData("itemReqs");
return (List<ItemStack>) context.getSessionData(CK.REQ_ITEMS);
}
private List<Boolean> getRemoveItems(ConversationContext context){
return (List<Boolean>) context.getSessionData("removeItemReqs");
return (List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE);
}
}
@ -445,7 +450,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
context.setSessionData("removeItemReqs", booleans);
context.setSessionData(CK.REQ_ITEMS_REMOVE, booleans);
}
@ -472,10 +477,10 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
LinkedList<String> permissions = new LinkedList<String>();
permissions.addAll(Arrays.asList(args));
context.setSessionData("permissionReqs", permissions);
context.setSessionData(CK.REQ_PERMISSION, permissions);
}else if(input.equalsIgnoreCase("clear")){
context.setSessionData("permissionReqs", null);
context.setSessionData(CK.REQ_PERMISSION, null);
}
return new RequirementsPrompt(quests, factory);
@ -495,7 +500,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
public Prompt acceptInput(ConversationContext context, String input){
if(input.equalsIgnoreCase("cancel") == false)
context.setSessionData("failMessage", input);
context.setSessionData(CK.Q_FAIL_MESSAGE, input);
return new RequirementsPrompt(quests, factory);

View File

@ -3,13 +3,20 @@ package me.blackvein.quests.prompts;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import org.bukkit.conversations.*;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.inventory.ItemStack;
@ -32,34 +39,34 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
String text;
text = DARKAQUA + "- " + AQUA + context.getSessionData("questName") + AQUA + " | Rewards -\n";
text = DARKAQUA + "- " + AQUA + context.getSessionData(CK.Q_NAME) + AQUA + " | Rewards -\n";
if(context.getSessionData("moneyRew") == null)
if(context.getSessionData(CK.REW_MONEY) == null)
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money reward (None set)\n";
else{
int moneyRew = (Integer) context.getSessionData("moneyRew");
int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY);
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money reward (" + moneyRew + " " + (moneyRew > 1 ? Quests.getCurrency(true) : Quests.getCurrency(false)) + ")\n";
}
if(context.getSessionData("questPointsRew") == null)
if(context.getSessionData(CK.REW_QUEST_POINTS) == null)
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points reward (None set)\n";
else{
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points reward (" + context.getSessionData("questPointsRew") + " Quest Points)\n";
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points reward (" + context.getSessionData(CK.REW_QUEST_POINTS) + " Quest Points)\n";
}
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set item rewards\n";
if(context.getSessionData("expRew") == null)
if(context.getSessionData(CK.REW_EXP) == null)
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set experience reward (None set)\n";
else{
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set experience reward (" + context.getSessionData("expRew") + " points)\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set experience reward (" + context.getSessionData(CK.REW_EXP) + " points)\n";
}
if(context.getSessionData("commandRews") == null)
if(context.getSessionData(CK.REW_COMMAND) == null)
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set command rewards (None set)\n";
else{
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set command rewards\n";
List<String> commands = (List<String>) context.getSessionData("commandRews");
List<String> commands = (List<String>) context.getSessionData(CK.REW_COMMAND);
for(String cmd : commands){
@ -68,11 +75,11 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
}
if(context.getSessionData("permissionRews") == null)
if(context.getSessionData(CK.REW_PERMISSION) == null)
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set permission rewards (None set)\n";
else{
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set permission rewards\n";
List<String> permissions = (List<String>) context.getSessionData("permissionRews");
List<String> permissions = (List<String>) context.getSessionData(CK.REW_PERMISSION);
for(String perm : permissions){
@ -85,12 +92,12 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
if(Quests.mcmmo != null){
if(context.getSessionData("mcMMOSkillRews") == null)
if(context.getSessionData(CK.REW_MCMMO_SKILLS) == null)
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO skill rewards (None set)\n";
else{
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO skill rewards\n";
List<String> skills = (List<String>) context.getSessionData("mcMMOSkillRews");
List<Integer> amounts = (List<Integer>) context.getSessionData("mcMMOSkillAmounts");
List<String> skills = (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS);
for(String skill : skills){
@ -159,9 +166,9 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
context.getForWhom().sendRawMessage(RED + "Amount must be positive!");
return new MoneyPrompt();
}else if(input.intValue() == 0)
context.setSessionData("moneyRew", null);
context.setSessionData(CK.REW_MONEY, null);
else if(input.intValue() != -1)
context.setSessionData("moneyRew", input.intValue());
context.setSessionData(CK.REW_MONEY, input.intValue());
return new RewardsPrompt(quests, factory);
@ -185,9 +192,9 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
context.getForWhom().sendRawMessage(RED + "Amount must be positive!");
return new ExperiencePrompt();
}else if(input.intValue() == -1)
context.setSessionData("expRew", null);
context.setSessionData(CK.REW_EXP, null);
else if(input.intValue() != 0)
context.setSessionData("expRew", input.intValue());
context.setSessionData(CK.REW_EXP, input.intValue());
return new RewardsPrompt(quests, factory);
@ -211,16 +218,16 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
context.getForWhom().sendRawMessage(RED + "Amount must be positive!");
return new QuestPointsPrompt();
}else if(input.intValue() == -1)
context.setSessionData("questPointsRew", null);
context.setSessionData(CK.REW_QUEST_POINTS, null);
else if(input.intValue() != 0)
context.setSessionData("questPointsRew", input.intValue());
context.setSessionData(CK.REW_QUEST_POINTS, input.intValue());
return new RewardsPrompt(quests, factory);
}
}
}
private class ItemListPrompt extends FixedSetPrompt {
public ItemListPrompt(){
@ -234,14 +241,14 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
// Check/add newly made item
if(context.getSessionData("newItem") != null){
if(context.getSessionData("itemRews") != null){
if(context.getSessionData(CK.REW_ITEMS) != null){
List<ItemStack> itemRews = getItems(context);
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData("itemRews", itemRews);
context.setSessionData(CK.REW_ITEMS, itemRews);
}else{
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData("itemRews", itemRews);
context.setSessionData(CK.REW_ITEMS, itemRews);
}
context.setSessionData("newItem", null);
@ -250,7 +257,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
String text = GOLD + "- Item Rewards -\n";
if(context.getSessionData("itemRews") == null){
if(context.getSessionData(CK.REW_ITEMS) == null){
text += GRAY + " (" + Lang.get("noneSet") + ")\n";
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n";
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Clear\n";
@ -280,7 +287,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemStackPrompt(ItemListPrompt.this);
}else if(input.equalsIgnoreCase("2")){
context.getForWhom().sendRawMessage(YELLOW + "Item rewards cleared.");
context.setSessionData("itemRews", null);
context.setSessionData(CK.REW_ITEMS, null);
return new ItemListPrompt();
}else if(input.equalsIgnoreCase("3")){
return new RewardsPrompt(quests, factory);
@ -290,7 +297,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
private List<ItemStack> getItems(ConversationContext context){
return (List<ItemStack>) context.getSessionData("itemRews");
return (List<ItemStack>) context.getSessionData(CK.REW_ITEMS);
}
}
@ -411,10 +418,10 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
context.setSessionData("commandRews", commands);
context.setSessionData(CK.REW_COMMAND, commands);
}else if(input.equalsIgnoreCase("clear")){
context.setSessionData("commandRews", null);
context.setSessionData(CK.REW_COMMAND, null);
}
return new RewardsPrompt(quests, factory);
@ -439,10 +446,10 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
LinkedList<String> permissions = new LinkedList<String>();
permissions.addAll(Arrays.asList(args));
context.setSessionData("permissionRews", permissions);
context.setSessionData(CK.REW_PERMISSION, permissions);
}else if(input.equalsIgnoreCase("clear")){
context.setSessionData("permissionRews", null);
context.setSessionData(CK.REW_PERMISSION, null);
}
return new RewardsPrompt(quests, factory);
@ -469,7 +476,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
public String getPromptText(ConversationContext context){
String text = GOLD + "- mcMMO Rewards -\n";
if(context.getSessionData("mcMMOSkillRews") == null){
if(context.getSessionData(CK.REW_MCMMO_SKILLS) == null){
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set skills (None set)\n";
text += GRAY + "2 - Set skill amounts (No skills set)\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n";
@ -483,7 +490,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
if(context.getSessionData("mcMMOAmountRews") == null){
if(context.getSessionData(CK.REW_MCMMO_AMOUNTS) == null){
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set skill amounts (None set)\n";
}else{
@ -511,7 +518,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
if(input.equalsIgnoreCase("1")){
return new mcMMOSkillsPrompt();
}else if(input.equalsIgnoreCase("2")){
if(context.getSessionData("mcMMOSkillRews") == null){
if(context.getSessionData(CK.REW_MCMMO_SKILLS) == null){
context.getForWhom().sendRawMessage(RED + "You must set skills first!");
return new mcMMOListPrompt();
}else{
@ -519,21 +526,21 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
}else if(input.equalsIgnoreCase("3")){
context.getForWhom().sendRawMessage(YELLOW + "mcMMO rewards cleared.");
context.setSessionData("mcMMOSkillRews", null);
context.setSessionData("mcMMOAmountRews", null);
context.setSessionData(CK.REW_MCMMO_SKILLS, null);
context.setSessionData(CK.REW_MCMMO_AMOUNTS, null);
return new mcMMOListPrompt();
}else if(input.equalsIgnoreCase("4")){
int one;
int two;
if(context.getSessionData("mcMMOSkillRews") != null)
one = ((List<Integer>) context.getSessionData("mcMMOSkillRews")).size();
if(context.getSessionData(CK.REW_MCMMO_SKILLS) != null)
one = ((List<Integer>) context.getSessionData(CK.REW_MCMMO_SKILLS)).size();
else
one = 0;
if(context.getSessionData("mcMMOAmountRews") != null)
two = ((List<Integer>) context.getSessionData("mcMMOAmountRews")).size();
if(context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null)
two = ((List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS)).size();
else
two = 0;
@ -549,11 +556,11 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
private List<String> getSkills(ConversationContext context){
return (List<String>) context.getSessionData("mcMMOSkillRews");
return (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS);
}
private List<Integer> getSkillAmounts(ConversationContext context){
return (List<Integer>) context.getSessionData("mcMMOAmountRews");
return (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS);
}
}
@ -607,7 +614,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
context.setSessionData("mcMMOSkillRews", skills);
context.setSessionData(CK.REW_MCMMO_SKILLS, skills);
}
@ -649,7 +656,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
}
context.setSessionData("mcMMOSkillAmounts", amounts);
context.setSessionData(CK.REW_MCMMO_AMOUNTS, amounts);
}

View File

@ -2,6 +2,8 @@ package me.blackvein.quests.prompts;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.util.CK;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
@ -105,118 +107,118 @@ public class StagesPrompt extends StringPrompt implements ColorUtil{
pref = "stage" + current;
newPref = "stage" + (current - 1);
cc.setSessionData(newPref + "breakIds", cc.getSessionData(pref + "breakIds"));
cc.setSessionData(newPref + "breakAmounts", cc.getSessionData(pref + "breakAmounts"));
cc.setSessionData(newPref + "breakIds", cc.getSessionData(pref + CK.S_BREAK_IDS));
cc.setSessionData(newPref + "breakAmounts", cc.getSessionData(pref + CK.S_BREAK_AMOUNTS));
cc.setSessionData(newPref + "damageIds", cc.getSessionData(pref + "damageIds"));
cc.setSessionData(newPref + "damageAmounts", cc.getSessionData(pref + "damageAmounts"));
cc.setSessionData(newPref + "damageIds", cc.getSessionData(pref + CK.S_DAMAGE_IDS));
cc.setSessionData(newPref + "damageAmounts", cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
cc.setSessionData(newPref + "placeIds", cc.getSessionData(pref + "placeIds"));
cc.setSessionData(newPref + "placeAmounts", cc.getSessionData(pref + "placeAmounts"));
cc.setSessionData(newPref + "placeIds", cc.getSessionData(pref + CK.S_PLACE_IDS));
cc.setSessionData(newPref + "placeAmounts", cc.getSessionData(pref + CK.S_PLACE_AMOUNTS));
cc.setSessionData(newPref + "useIds", cc.getSessionData(pref + "useIds"));
cc.setSessionData(newPref + "useAmounts", cc.getSessionData(pref + "useAmounts"));
cc.setSessionData(newPref + "useIds", cc.getSessionData(pref + CK.S_USE_IDS));
cc.setSessionData(newPref + "useAmounts", cc.getSessionData(pref + CK.S_USE_AMOUNTS));
cc.setSessionData(newPref + "cutIds", cc.getSessionData(pref + "cutIds"));
cc.setSessionData(newPref + "cutAmounts", cc.getSessionData(pref + "cutAmounts"));
cc.setSessionData(newPref + "cutIds", cc.getSessionData(pref + CK.S_CUT_IDS));
cc.setSessionData(newPref + "cutAmounts", cc.getSessionData(pref + CK.S_CUT_AMOUNTS));
cc.setSessionData(newPref + "fish", cc.getSessionData(pref + "fish"));
cc.setSessionData(newPref + "fish", cc.getSessionData(pref + CK.S_FISH));
cc.setSessionData(newPref + "playerKill", cc.getSessionData(pref + "playerKill"));
cc.setSessionData(newPref + "playerKill", cc.getSessionData(pref + CK.S_PLAYER_KILL));
cc.setSessionData(newPref + "enchantTypes", cc.getSessionData(pref + "enchantTypes"));
cc.setSessionData(newPref + "enchantIds", cc.getSessionData(pref + "enchantIds"));
cc.setSessionData(newPref + "enchantAmounts", cc.getSessionData(pref + "enchantAmounts"));
cc.setSessionData(newPref + "enchantTypes", cc.getSessionData(pref + CK.S_ENCHANT_TYPES));
cc.setSessionData(newPref + "enchantIds", cc.getSessionData(pref + CK.S_ENCHANT_IDS));
cc.setSessionData(newPref + "enchantAmounts", cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
cc.setSessionData(newPref + "deliveryItems", cc.getSessionData(pref + "deliveryItems"));
cc.setSessionData(newPref + "deliveryNPCs", cc.getSessionData(pref + "deliveryNPCs"));
cc.setSessionData(newPref + "deliveryMessages", cc.getSessionData(pref + "deliveryMessages"));
cc.setSessionData(newPref + "deliveryItems", cc.getSessionData(pref + CK.S_DELIVERY_ITEMS));
cc.setSessionData(newPref + "deliveryNPCs", cc.getSessionData(pref + CK.S_DELIVERY_NPCS));
cc.setSessionData(newPref + "deliveryMessages", cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
cc.setSessionData(newPref + "npcIdsToTalkTo", cc.getSessionData(pref + "npcIdsToTalkTo"));
cc.setSessionData(newPref + "npcIdsToTalkTo", cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
cc.setSessionData(newPref + "npcIdsToKill", cc.getSessionData(pref + "npcIdsToKill"));
cc.setSessionData(newPref + "npcAmountsToKill", cc.getSessionData(pref + "npcAmountsToKill"));
cc.setSessionData(newPref + "npcIdsToKill", cc.getSessionData(pref + CK.S_NPCS_TO_KILL));
cc.setSessionData(newPref + "npcAmountsToKill", cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
cc.setSessionData(newPref + "mobTypes", cc.getSessionData(pref + "mobTypes"));
cc.setSessionData(newPref + "mobAmounts", cc.getSessionData(pref + "mobAmounts"));
cc.setSessionData(newPref + "killLocations", cc.getSessionData(pref + "killLocations"));
cc.setSessionData(newPref + "killLocationRadii", cc.getSessionData(pref + "killLocationRadii"));
cc.setSessionData(newPref + "killLocationNames", cc.getSessionData(pref + "killLocationNames"));
cc.setSessionData(newPref + "mobTypes", cc.getSessionData(pref + CK.S_MOB_TYPES));
cc.setSessionData(newPref + "mobAmounts", cc.getSessionData(pref + CK.S_MOB_AMOUNTS));
cc.setSessionData(newPref + "killLocations", cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
cc.setSessionData(newPref + "killLocationRadii", cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
cc.setSessionData(newPref + "killLocationNames", cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
cc.setSessionData(newPref + "reachLocations", cc.getSessionData(pref + "reachLocations"));
cc.setSessionData(newPref + "reachLocationRadii", cc.getSessionData(pref + "reachLocationRadii"));
cc.setSessionData(newPref + "reachLocationNames", cc.getSessionData(pref + "reachLocationNames"));
cc.setSessionData(newPref + "reachLocations", cc.getSessionData(pref + CK.S_REACH_LOCATIONS));
cc.setSessionData(newPref + "reachLocationRadii", cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
cc.setSessionData(newPref + "reachLocationNames", cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
cc.setSessionData(newPref + "tameTypes", cc.getSessionData(pref + "tameTypes"));
cc.setSessionData(newPref + "tameAmounts", cc.getSessionData(pref + "tameAmounts"));
cc.setSessionData(newPref + "tameTypes", cc.getSessionData(pref + CK.S_TAME_TYPES));
cc.setSessionData(newPref + "tameAmounts", cc.getSessionData(pref + CK.S_TAME_AMOUNTS));
cc.setSessionData(newPref + "shearColors", cc.getSessionData(pref + "shearColors"));
cc.setSessionData(newPref + "shearAmounts", cc.getSessionData(pref + "shearAmounts"));
cc.setSessionData(newPref + "shearColors", cc.getSessionData(pref + CK.S_SHEAR_COLORS));
cc.setSessionData(newPref + "shearAmounts", cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
cc.setSessionData(newPref + "event", cc.getSessionData(pref + "event"));
cc.setSessionData(newPref + "event", cc.getSessionData(pref + CK.S_EVENT));
cc.setSessionData(newPref + "delay", cc.getSessionData(pref + "delay"));
cc.setSessionData(newPref + "delayMessage", cc.getSessionData(pref + "delayMessage"));
cc.setSessionData(newPref + "delay", cc.getSessionData(pref + CK.S_DELAY));
cc.setSessionData(newPref + "delayMessage", cc.getSessionData(pref + CK.S_DELAY_MESSAGE));
cc.setSessionData(newPref + "denizen", cc.getSessionData(pref + "denizen"));
cc.setSessionData(newPref + "denizen", cc.getSessionData(pref + CK.S_DENIZEN));
}
cc.setSessionData(pref + "breakIds", null);
cc.setSessionData(pref + "breakAmounts", null);
cc.setSessionData(pref + CK.S_BREAK_IDS, null);
cc.setSessionData(pref + CK.S_BREAK_AMOUNTS, null);
cc.setSessionData(pref + "damageIds", null);
cc.setSessionData(pref + "damageAmounts", null);
cc.setSessionData(pref + CK.S_DAMAGE_IDS, null);
cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null);
cc.setSessionData(pref + "placeIds", null);
cc.setSessionData(pref + "placeAmounts", null);
cc.setSessionData(pref + CK.S_PLACE_IDS, null);
cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, null);
cc.setSessionData(pref + "useIds", null);
cc.setSessionData(pref + "useAmounts", null);
cc.setSessionData(pref + CK.S_USE_IDS, null);
cc.setSessionData(pref + CK.S_USE_AMOUNTS, null);
cc.setSessionData(pref + "cutIds", null);
cc.setSessionData(pref + "cutAmounts", null);
cc.setSessionData(pref + CK.S_CUT_IDS, null);
cc.setSessionData(pref + CK.S_CUT_AMOUNTS, null);
cc.setSessionData(pref + "fish", null);
cc.setSessionData(pref + CK.S_FISH, null);
cc.setSessionData(pref + "playerKill", null);
cc.setSessionData(pref + CK.S_PLAYER_KILL, null);
cc.setSessionData(pref + "enchantTypes", null);
cc.setSessionData(pref + "enchantIds", null);
cc.setSessionData(pref + "enchantAmounts", null);
cc.setSessionData(pref + CK.S_ENCHANT_TYPES, null);
cc.setSessionData(pref + CK.S_ENCHANT_IDS, null);
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null);
cc.setSessionData(pref + "deliveryItems", null);
cc.setSessionData(pref + "deliveryNPCs", null);
cc.setSessionData(pref + "deliveryMessages", null);
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, null);
cc.setSessionData(pref + CK.S_DELIVERY_NPCS, null);
cc.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null);
cc.setSessionData(pref + "npcIdsToTalkTo", null);
cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
cc.setSessionData(pref + "npcIdsToKill", null);
cc.setSessionData(pref + "npcAmountsToKill", null);
cc.setSessionData(pref + CK.S_NPCS_TO_KILL, null);
cc.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null);
cc.setSessionData(pref + "mobTypes", null);
cc.setSessionData(pref + "mobAmounts", null);
cc.setSessionData(pref + "killLocations", null);
cc.setSessionData(pref + "killLocationRadii", null);
cc.setSessionData(pref + "killLocationNames", null);
cc.setSessionData(pref + CK.S_MOB_TYPES, null);
cc.setSessionData(pref + CK.S_MOB_AMOUNTS, null);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null);
cc.setSessionData(pref + "reachLocations", null);
cc.setSessionData(pref + "reachLocationRadii", null);
cc.setSessionData(pref + "reachLocationNames", null);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS, null);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null);
cc.setSessionData(pref + "tameTypes", null);
cc.setSessionData(pref + "tameAmounts", null);
cc.setSessionData(pref + CK.S_TAME_TYPES, null);
cc.setSessionData(pref + CK.S_TAME_AMOUNTS, null);
cc.setSessionData(pref + "shearColors", null);
cc.setSessionData(pref + "shearAmounts", null);
cc.setSessionData(pref + CK.S_SHEAR_COLORS, null);
cc.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null);
cc.setSessionData(pref + "event", null);
cc.setSessionData(pref + CK.S_EVENT, null);
cc.setSessionData(pref + "delay", null);
cc.setSessionData(pref + "delayMessage", null);
cc.setSessionData(pref + CK.S_DELAY, null);
cc.setSessionData(pref + CK.S_DELAY_MESSAGE, null);
cc.setSessionData(pref + "denizen", null);
cc.setSessionData(pref + CK.S_DENIZEN, null);
if(last)
break;

View File

@ -0,0 +1,111 @@
package me.blackvein.quests.util;
import me.blackvein.quests.Quests;
public class CK {
public static String ED_QUEST_EDIT = "edit";
public static String ED_QUEST_DELETE = "delQuest";
public static String ED_EVENT_DELETE = "delEvent";
//Quests
public static String Q_NAME = "questName";
public static String Q_ASK_MESSAGE = "askMessage";
public static String Q_FINISH_MESSAGE = "finishMessage";
public static String Q_REDO_DELAY = "redoDelay";
public static String Q_START_NPC = "npcStart";
public static String Q_START_BLOCK= "blockStart";
public static String Q_FAIL_MESSAGE = "failMessage";
public static String Q_INITIAL_EVENT = "initialEvent";
//Requirements
public static String REQ_MONEY = "moneyReq";
public static String REQ_QUEST_POINTS = "questPointsReq";
public static String REQ_ITEMS = "itemReqs";
public static String REQ_ITEMS_REMOVE = "removeItemReqs";
public static String REQ_PERMISSION = "permissionReqs";
public static String REQ_QUEST = "questReqs";
public static String REQ_QUEST_BLOCK= "questBlocks";
//Rewards
public static String REW_MONEY = "moneyRew";
public static String REW_QUEST_POINTS = "questPointsRew";
public static String REW_ITEMS = "itemRews";
public static String REW_EXP = "expRew";
public static String REW_COMMAND = "commandRews";
public static String REW_PERMISSION = "permissionRews";
public static String REW_MCMMO_SKILLS = "mcMMOSkillRews";
public static String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
//Stages
public static String S_BREAK_IDS = "breakIds";
public static String S_BREAK_AMOUNTS = "breakAmounts";
public static String S_DAMAGE_IDS = "damageIds";
public static String S_DAMAGE_AMOUNTS = "damageAmounts";
public static String S_PLACE_IDS = "placeIds";
public static String S_PLACE_AMOUNTS = "placeAmounts";
public static String S_USE_IDS = "useIds";
public static String S_USE_AMOUNTS = "useAmounts";
public static String S_CUT_IDS = "useIds";
public static String S_CUT_AMOUNTS = "cutAmounts";
public static String S_FISH = "fish";
public static String S_PLAYER_KILL = "playerKill";
public static String S_ENCHANT_TYPES = "enchantTypes";
public static String S_ENCHANT_IDS = "enchantIds";
public static String S_ENCHANT_AMOUNTS = "enchantAmounts";
public static String S_DELIVERY_ITEMS = "deliveryItems";
public static String S_DELIVERY_NPCS = "deliveryNPCs";
public static String S_DELIVERY_MESSAGES = "deliveryMessages";
public static String S_NPCS_TO_TALK_TO = "npcIdsToTalkTo";
public static String S_NPCS_TO_KILL = "npcIdsToKill";
public static String S_NPCS_TO_KILL_AMOUNTS = "npcAmountsToKill";
public static String S_BOSS_IDS = "bossIds";
public static String S_BOSS_AMOUNTS = "bossAmounts";
public static String S_MOB_TYPES = "mobTypes";
public static String S_MOB_AMOUNTS = "mobAmounts";
public static String S_MOB_KILL_LOCATIONS = "killLocations";
public static String S_MOB_KILL_LOCATIONS_RADIUS = "killLocationRadii";
public static String S_MOB_KILL_LOCATIONS_NAMES = "killLocationNames";
public static String S_REACH_LOCATIONS = "reachLocations";
public static String S_REACH_LOCATIONS_RADIUS = "reachLocationRadii";
public static String S_REACH_LOCATIONS_NAMES = "reachLocationNames";
public static String S_TAME_TYPES = "tameTypes";
public static String S_TAME_AMOUNTS = "tameAmounts";
public static String S_SHEAR_COLORS = "shearColors";
public static String S_SHEAR_AMOUNTS = "shearAmounts";
public static String S_EVENT = "event";
public static String S_DELAY = "delay";
public static String S_DELAY_MESSAGE = "delayMessage";
public static String S_DENIZEN = "denizen";
//Events
public static String E_OLD_EVENT = "oldEvent";
public static String E_NAME = "evtName";
public static String E_MESSAGE = "evtMessage";
public static String E_CLEAR_INVENTORY = "evtClearInv";
public static String E_ITEMS = "evtItems";
public static String E_ITEMS_AMOUNTS = "evtItemAmounts";
public static String E_EXPLOSIONS = "evtExplosions";
public static String E_EFFECTS = "evtEffects";
public static String E_EFFECTS_LOCATIONS = "evtEffectLocations";
public static String E_WORLD_STORM = "evtStormWorld";
public static String E_WORLD_STORM_DURATION = "evtStormDuration";
public static String E_WORLD_THUNDER = "evtThunderWorld";
public static String E_WORLD_THUNDER_DURATION = "evtThunderDuration";
public static String E_MOB_TYPES = "evtMobTypes";
public static String E_MOB_AMOUNTS = "evtMobAmounts";
public static String E_MOB_LOCATIONS = "evtMobLocations";
public static String E_LIGHTNING = "evtLightningStrikes";
public static String E_POTION_TYPES = "evtPotionTypes";
public static String E_POTION_DURATIONS = "evtPotionDurations";
public static String E_POTION_STRENGHT = "evtPotionMagnitudes";
public static String E_HUNGER = "evtHunger";
public static String E_SATURATION = "evtSaturation";
public static String E_HEALTH = "evtHealth";
public static String E_TELEPORT = "evtTeleportLocation";
public static String E_COMMANDS = "evtCommands";
//Party
public static String P_INVITER = "inviter";
}