Improve code for saving quests

This commit is contained in:
PikaMug 2020-03-15 03:13:08 -04:00
parent 7c5b32dc0c
commit 1c20d05cbe

View File

@ -1514,14 +1514,13 @@ public class QuestFactory implements ConversationAbandonedListener {
} }
} }
@SuppressWarnings("unchecked") public void saveQuest(ConversationContext context, ConfigurationSection section) {
public void saveQuest(ConversationContext context, ConfigurationSection cs) {
String edit = null; String edit = null;
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) { if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
edit = (String) context.getSessionData(CK.ED_QUEST_EDIT); edit = (String) context.getSessionData(CK.ED_QUEST_EDIT);
} }
if (edit != null) { if (edit != null) {
ConfigurationSection questList = cs.getParent(); ConfigurationSection questList = section.getParent();
for (String key : questList.getKeys(false)) { for (String key : questList.getKeys(false)) {
String name = questList.getString(key + ".name"); String name = questList.getString(key + ".name");
if (name != null) { if (name != null) {
@ -1532,561 +1531,170 @@ public class QuestFactory implements ConversationAbandonedListener {
} }
} }
} }
String name = (String) context.getSessionData(CK.Q_NAME); section.set("name", context.getSessionData(CK.Q_NAME) != null
String desc = (String) context.getSessionData(CK.Q_ASK_MESSAGE); ? (String) context.getSessionData(CK.Q_NAME) : null);
String finish = (String) context.getSessionData(CK.Q_FINISH_MESSAGE); section.set("ask-message", context.getSessionData(CK.Q_ASK_MESSAGE) != null
Integer npcStart = null; ? (String) context.getSessionData(CK.Q_ASK_MESSAGE) : null);
String blockStart = null; section.set("finish-message", context.getSessionData(CK.Q_FINISH_MESSAGE) != null
String initialEvent = null; ? (String) context.getSessionData(CK.Q_FINISH_MESSAGE) : null);
String region = null; section.set("npc-giver-id", context.getSessionData(CK.Q_START_NPC) != null
ItemStack guiDisplay = null; ? (Integer) context.getSessionData(CK.Q_START_NPC) : null);
Integer moneyReq = null; section.set("block-start", context.getSessionData(CK.Q_START_BLOCK) != null
Integer questPointsReq = null; ? ConfigUtil.getLocationInfo((Location) context.getSessionData(CK.Q_START_BLOCK)) : null);
List<ItemStack> itemReqs = null; section.set("event", context.getSessionData(CK.Q_INITIAL_EVENT) != null
List<Boolean> removeItemReqs = null; ? (String) context.getSessionData(CK.Q_INITIAL_EVENT) : null);
List<String> permReqs = null; section.set("region", context.getSessionData(CK.Q_REGION) != null
List<String> questReqs = null; ? (String) context.getSessionData(CK.Q_REGION) : null);
List<String> questBlocks = null; section.set("gui-display", context.getSessionData(CK.Q_GUIDISPLAY) != null
List<String> mcMMOSkillReqs = null; ? (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY) : null);
List<Integer> mcMMOAmountReqs = null; saveRequirements(context, section);
String heroesPrimaryReq = null; saveStages(context, section);
String heroesSecondaryReq = null; saveRewards(context, section);
LinkedList<String> customReqs = null; savePlanner(context, section);
LinkedList<Map<String, Object>> customReqsData = null; saveOptions(context, section);
List<String> detailsOverrideReqs = null; }
Integer moneyRew = null;
Integer questPointsRew = null; @SuppressWarnings("unchecked")
List<ItemStack> itemRews = null; private void saveRequirements(ConversationContext context, ConfigurationSection section) {
List<Integer> RPGItemRews = null; ConfigurationSection reqs = section.createSection("requirements");
List<Integer> RPGItemAmounts = null; reqs.set("money", context.getSessionData(CK.REQ_MONEY) != null
Integer expRew = null; ? (Integer) context.getSessionData(CK.REQ_MONEY) : null);
List<String> commandRews = null; reqs.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null
List<String> commandDisplayOverrideRews = null; ? (Integer) context.getSessionData(CK.REQ_QUEST_POINTS) : null);
List<String> permRews = null; reqs.set("items", context.getSessionData(CK.REQ_ITEMS) != null
List<String> permWorldRews = null; ? (List<ItemStack>) context.getSessionData(CK.REQ_ITEMS) : null);
List<String> mcMMOSkillRews = null; reqs.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null
List<Integer> mcMMOSkillAmounts = null; ? (List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE) : null);
List<String> heroesClassRews = null; reqs.set("permissions", context.getSessionData(CK.REQ_PERMISSION) != null
List<Double> heroesExpRews = null; ? (List<String>) context.getSessionData(CK.REQ_PERMISSION) : null);
List<String> phatLootRews = null; reqs.set("quests", context.getSessionData(CK.REQ_QUEST) != null
LinkedList<String> customRews = null; ? (List<String>) context.getSessionData(CK.REQ_QUEST) : null);
LinkedList<Map<String, Object>> customRewsData = null; reqs.set("quest-blocks", context.getSessionData(CK.REQ_QUEST_BLOCK) != null
List<String> detailsOverrideRews = null; ? (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK) : null);
String startDatePln = null; reqs.set("mcmmo-skills", context.getSessionData(CK.REQ_MCMMO_SKILLS) != null
String endDatePln = null; ? (List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS) : null);
Long repeatCyclePln = null; reqs.set("mcmmo-amounts", context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) != null
Long cooldownPln = null; ? (List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) : null);
boolean allowCommandsOpt = true; reqs.set("heroes-primary-class", context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null
boolean allowQuittingOpt = true; ? (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) : null);
boolean useDungeonsXLPluginOpt = false; reqs.set("heroes-secondary-class", context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null
boolean usePartiesPluginOpt = true; ? (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) : null);
Integer shareProgressLevelOpt = 1; LinkedList<String> customReqs = context.getSessionData(CK.REQ_CUSTOM) != null
boolean requireSameQuestOpt = true; ? (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM) : null;
if (context.getSessionData(CK.Q_START_NPC) != null) { LinkedList<Map<String, Object>> customReqsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null
npcStart = (Integer) context.getSessionData(CK.Q_START_NPC); ? (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA) : null;
} if (customReqs != null) {
if (context.getSessionData(CK.Q_START_BLOCK) != null) { ConfigurationSection customReqsSec = reqs.createSection("custom-requirements");
blockStart = ConfigUtil.getLocationInfo((Location) context.getSessionData(CK.Q_START_BLOCK)); for (int i = 0; i < customReqs.size(); i++) {
} ConfigurationSection customReqSec = customReqsSec.createSection("req" + (i + 1));
if (context.getSessionData(CK.REQ_MONEY) != null) { customReqSec.set("name", customReqs.get(i));
moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY); customReqSec.set("data", customReqsData.get(i));
}
if (context.getSessionData(CK.REQ_QUEST_POINTS) != null) {
questPointsReq = (Integer) context.getSessionData(CK.REQ_QUEST_POINTS);
}
if (context.getSessionData(CK.REQ_ITEMS) != null) {
itemReqs = new LinkedList<ItemStack>();
removeItemReqs = new LinkedList<Boolean>();
itemReqs.addAll((List<ItemStack>) context.getSessionData(CK.REQ_ITEMS));
removeItemReqs.addAll((List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE));
}
if (context.getSessionData(CK.REQ_PERMISSION) != null) {
permReqs = new LinkedList<String>();
permReqs.addAll((List<String>) context.getSessionData(CK.REQ_PERMISSION));
}
if (context.getSessionData(CK.REQ_QUEST) != null) {
questReqs = new LinkedList<String>();
questReqs.addAll((List<String>) context.getSessionData(CK.REQ_QUEST));
}
if (context.getSessionData(CK.REQ_QUEST_BLOCK) != null) {
questBlocks = new LinkedList<String>();
questBlocks.addAll((List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK));
}
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) != null) {
mcMMOSkillReqs = new LinkedList<String>();
mcMMOAmountReqs = new LinkedList<Integer>();
mcMMOSkillReqs.addAll((List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS));
mcMMOAmountReqs.addAll((List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS));
}
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) {
heroesPrimaryReq = (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS);
}
if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
heroesSecondaryReq = (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS);
}
if (context.getSessionData(CK.REQ_CUSTOM) != null) {
customReqs = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
customReqsData = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
}
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) != null) {
detailsOverrideReqs = new LinkedList<String>();
detailsOverrideReqs.addAll((List<String>)context.getSessionData(CK.REQ_FAIL_MESSAGE));
}
if (context.getSessionData(CK.Q_INITIAL_EVENT) != null) {
initialEvent = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
}
if (context.getSessionData(CK.Q_REGION) != null) {
region = (String) context.getSessionData(CK.Q_REGION);
}
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
guiDisplay = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
}
if (context.getSessionData(CK.REW_MONEY) != null) {
moneyRew = (Integer) context.getSessionData(CK.REW_MONEY);
}
if (context.getSessionData(CK.REW_QUEST_POINTS) != null) {
questPointsRew = (Integer) context.getSessionData(CK.REW_QUEST_POINTS);
}
if (context.getSessionData(CK.REW_ITEMS) != null) {
itemRews = (List<ItemStack>) context.getSessionData(CK.REW_ITEMS);
}
if (context.getSessionData(CK.REW_EXP) != null) {
expRew = (Integer) context.getSessionData(CK.REW_EXP);
}
if (context.getSessionData(CK.REW_COMMAND) != null) {
commandRews = new LinkedList<String>();
commandRews.addAll((List<String>)context.getSessionData(CK.REW_COMMAND));
}
if (context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null) {
commandDisplayOverrideRews = new LinkedList<String>();
commandDisplayOverrideRews.addAll((List<String>)context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY));
}
if (context.getSessionData(CK.REW_PERMISSION) != null) {
permRews = new LinkedList<String>();
permRews.addAll((List<String>) context.getSessionData(CK.REW_PERMISSION));
}
if (context.getSessionData(CK.REW_PERMISSION_WORLDS) != null) {
permWorldRews = new LinkedList<String>();
permWorldRews.addAll((List<String>) context.getSessionData(CK.REW_PERMISSION_WORLDS));
}
if (context.getSessionData(CK.REW_MCMMO_SKILLS) != null) {
mcMMOSkillRews = new LinkedList<String>();
mcMMOSkillAmounts = new LinkedList<Integer>();
mcMMOSkillRews.addAll((List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS));
mcMMOSkillAmounts.addAll((List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS));
}
if (context.getSessionData(CK.REW_HEROES_CLASSES) != null) {
heroesClassRews = new LinkedList<String>();
heroesExpRews = new LinkedList<Double>();
heroesClassRews.addAll((List<String>) context.getSessionData(CK.REW_HEROES_CLASSES));
heroesExpRews.addAll((List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS));
}
if (context.getSessionData(CK.REW_PHAT_LOOTS) != null) {
phatLootRews = new LinkedList<String>();
phatLootRews.addAll((List<String>) context.getSessionData(CK.REW_PHAT_LOOTS));
}
if (context.getSessionData(CK.REW_CUSTOM) != null) {
customRews = (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM);
customRewsData = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA);
}
if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) {
detailsOverrideRews = new LinkedList<String>();
detailsOverrideRews.addAll((List<String>)context.getSessionData(CK.REW_DETAILS_OVERRIDE));
}
if (context.getSessionData(CK.PLN_START_DATE) != null) {
startDatePln = (String) context.getSessionData(CK.PLN_START_DATE);
}
if (context.getSessionData(CK.PLN_END_DATE) != null) {
endDatePln = (String) context.getSessionData(CK.PLN_END_DATE);
}
if (context.getSessionData(CK.PLN_REPEAT_CYCLE) != null) {
repeatCyclePln = (Long) context.getSessionData(CK.PLN_REPEAT_CYCLE);
}
if (context.getSessionData(CK.PLN_COOLDOWN) != null) {
cooldownPln = (Long) context.getSessionData(CK.PLN_COOLDOWN);
}
if (context.getSessionData(CK.OPT_ALLOW_COMMANDS) != null) {
allowCommandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS);
}
if (context.getSessionData(CK.OPT_ALLOW_QUITTING) != null) {
allowQuittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING);
}
if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null) {
useDungeonsXLPluginOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
}
if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null) {
usePartiesPluginOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
}
if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null) {
shareProgressLevelOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
}
if (context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST) != null) {
requireSameQuestOpt = (Boolean) context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST);
}
cs.set("name", name);
cs.set("npc-giver-id", npcStart);
cs.set("block-start", blockStart);
cs.set("ask-message", desc);
cs.set("finish-message", finish);
cs.set("event", initialEvent);
cs.set("region", region);
cs.set("gui-display", guiDisplay);
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)
|| (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false)
|| heroesPrimaryReq != null || heroesSecondaryReq != null || customReqs != null) {
ConfigurationSection reqs = cs.createSection("requirements");
reqs.set("items", itemReqs);
reqs.set("remove-items", removeItemReqs);
reqs.set("money", moneyReq);
reqs.set("quest-points", questPointsReq);
reqs.set("permissions", permReqs);
reqs.set("quests", questReqs);
reqs.set("quest-blocks", questBlocks);
reqs.set("mcmmo-skills", mcMMOSkillReqs);
reqs.set("mcmmo-amounts", mcMMOAmountReqs);
reqs.set("heroes-primary-class", heroesPrimaryReq);
reqs.set("heroes-secondary-class", heroesSecondaryReq);
if (customReqs != null) {
ConfigurationSection customReqsSec = reqs.createSection("custom-requirements");
for (int i = 0; i < customReqs.size(); i++) {
ConfigurationSection customReqSec = customReqsSec.createSection("req" + (i + 1));
customReqSec.set("name", customReqs.get(i));
customReqSec.set("data", customReqsData.get(i));
}
} }
reqs.set("fail-requirement-message", detailsOverrideReqs);
} else {
cs.set("requirements", null);
} }
ConfigurationSection stages = cs.createSection("stages"); reqs.set("fail-requirement-message", context.getSessionData(CK.REQ_FAIL_MESSAGE) != null
? (List<String>)context.getSessionData(CK.REQ_FAIL_MESSAGE) : null);
if (reqs.getKeys(false).isEmpty()) {
section.set("requirements", null);
}
}
@SuppressWarnings("unchecked")
private void saveStages(ConversationContext context, ConfigurationSection section) {
ConfigurationSection stages = section.createSection("stages");
ConfigurationSection ordered = stages.createSection("ordered"); ConfigurationSection ordered = stages.createSection("ordered");
String pref; String pref;
LinkedList<Integer> breakNames;
LinkedList<Integer> breakAmounts;
LinkedList<Short> breakDurability;
LinkedList<Integer> damageNames;
LinkedList<Integer> damageAmounts;
LinkedList<Short> damageDurability;
LinkedList<Integer> placeNames;
LinkedList<Integer> placeAmounts;
LinkedList<Short> placeDurability;
LinkedList<Integer> useNames;
LinkedList<Integer> useAmounts;
LinkedList<Short> useDurability;
LinkedList<Integer> cutNames;
LinkedList<Integer> cutAmounts;
LinkedList<Short> cutDurability;
LinkedList<ItemStack> craftItems;
LinkedList<ItemStack> smeltItems;
LinkedList<String> enchantments;
LinkedList<Integer> enchantmentIds;
LinkedList<Integer> enchantmentAmounts;
LinkedList<ItemStack> brewItems;
Integer cows;
Integer fish;
Integer players;
LinkedList<ItemStack> deliveryItems;
LinkedList<Integer> deliveryNPCIds;
LinkedList<String> deliveryMessages;
LinkedList<Integer> npcTalkIds;
LinkedList<Integer> npcKillIds;
LinkedList<Integer> npcKillAmounts;
LinkedList<String> mobs;
LinkedList<Integer> mobAmounts;
LinkedList<String> mobLocs;
LinkedList<Integer> mobRadii;
LinkedList<String> mobLocNames;
LinkedList<String> reachLocs;
LinkedList<Integer> reachRadii;
LinkedList<String> reachNames;
LinkedList<String> tames;
LinkedList<Integer> tameAmounts;
LinkedList<String> shearColors;
LinkedList<Integer> shearAmounts;
LinkedList<String> passDisplays;
LinkedList<LinkedList<String>> passPhrases;
LinkedList<String> customObjs;
LinkedList<Integer> customObjCounts;
LinkedList<Entry<String, Object>> customObjsData;
String script;
String startEvent;
String finishEvent;
String deathEvent;
String disconnectEvent;
LinkedList<String> chatEvents;
LinkedList<String> chatEventTriggers;
LinkedList<String> commandEvents;
LinkedList<String> commandEventTriggers;
Long delay;
LinkedList<String> overrideDisplay;
String delayMessage;
String startMessage;
String completeMessage;
for (int i = 1; i <= new StageMenuPrompt(plugin, context, this).getStages(context); i++) { for (int i = 1; i <= new StageMenuPrompt(plugin, context, this).getStages(context); i++) {
pref = "stage" + i; pref = "stage" + i;
ConfigurationSection stage = ordered.createSection("" + i); ConfigurationSection stage = ordered.createSection("" + i);
breakNames = null; stage.set("break-block-names", context.getSessionData(pref + CK.S_BREAK_NAMES) != null
breakAmounts = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_NAMES) : null);
breakDurability = null; stage.set("break-block-amounts", context.getSessionData(pref + CK.S_BREAK_AMOUNTS) != null
damageNames = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_AMOUNTS) : null);
damageAmounts = null; stage.set("break-block-durability", context.getSessionData(pref + CK.S_BREAK_DURABILITY) != null
damageDurability = null; ? (LinkedList<Short>) context.getSessionData(pref + CK.S_BREAK_DURABILITY) : null);
placeNames = null; stage.set("damage-block-names", context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null
placeAmounts = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_NAMES) : null);
placeDurability = null; stage.set("damage-block-amounts", context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) != null
useNames = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) : null);
useAmounts = null; stage.set("damage-block-durability", context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) != null
useDurability = null; ? (LinkedList<Short>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) : null);
cutNames = null; stage.set("place-block-names", context.getSessionData(pref + CK.S_PLACE_NAMES) != null
cutAmounts = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_NAMES) : null);
cutDurability = null; stage.set("place-block-amounts", context.getSessionData(pref + CK.S_PLACE_AMOUNTS) != null
craftItems = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_AMOUNTS) : null);
smeltItems = null; stage.set("place-block-durability", context.getSessionData(pref + CK.S_PLACE_DURABILITY) != null
enchantments = null; ? (LinkedList<Short>) context.getSessionData(pref + CK.S_PLACE_DURABILITY) : null);
enchantmentIds = null; stage.set("use-block-names", context.getSessionData(pref + CK.S_USE_NAMES) != null
enchantmentAmounts = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_NAMES) : null);
brewItems = null; stage.set("use-block-amounts", context.getSessionData(pref + CK.S_USE_AMOUNTS) != null
cows = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_AMOUNTS) : null);
fish = null; stage.set("use-block-durability", context.getSessionData(pref + CK.S_USE_DURABILITY) != null
players = null; ? (LinkedList<Short>) context.getSessionData(pref + CK.S_USE_DURABILITY) : null);
deliveryItems = null; stage.set("cut-block-names", context.getSessionData(pref + CK.S_CUT_NAMES) != null
deliveryNPCIds = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_NAMES) : null);
deliveryMessages = null; stage.set("cut-block-amounts", context.getSessionData(pref + CK.S_CUT_AMOUNTS) != null
npcTalkIds = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_AMOUNTS) : null);
npcKillIds = null; stage.set("cut-block-durability", context.getSessionData(pref + CK.S_CUT_DURABILITY) != null
npcKillAmounts = null; ? (LinkedList<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY) : null);
mobs = null; stage.set("items-to-craft", context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null
mobAmounts = null; ? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS) : null);
mobLocs = null; stage.set("items-to-smelt", context.getSessionData(pref + CK.S_SMELT_ITEMS) != null
mobRadii = null; ? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS) : null);
mobLocNames = null; stage.set("enchantments", context.getSessionData(pref + CK.S_ENCHANT_TYPES) != null
reachLocs = null; ? (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES) : null);
reachRadii = null; stage.set("enchantment-item-names", context.getSessionData(pref + CK.S_ENCHANT_NAMES) != null
reachNames = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_NAMES) : null);
tames = null; stage.set("enchantment-amounts", context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS) != null
tameAmounts = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS) : null);
shearColors = null; stage.set("items-to-brew", context.getSessionData(pref + CK.S_BREW_ITEMS) != null
shearAmounts = null; ? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS) : null);
passDisplays = null; stage.set("cows-to-milk", context.getSessionData(pref + CK.S_COW_MILK) != null
passPhrases = null; ? (Integer) context.getSessionData(pref + CK.S_COW_MILK) : null);
customObjs = null; stage.set("fish-to-catch", context.getSessionData(pref + CK.S_FISH) != null
customObjCounts = null; ? (Integer) context.getSessionData(pref + CK.S_FISH) : null);
customObjsData = null; stage.set("players-to-kill", context.getSessionData(pref + CK.S_PLAYER_KILL) != null
script = null; ? (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL) : null);
startEvent = null; stage.set("items-to-deliver", context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null
finishEvent = null; ? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS) : null);
deathEvent = null; stage.set("npc-delivery-ids", context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null
disconnectEvent = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS) : null);
chatEvents = null; stage.set("delivery-messages", context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) != null
chatEventTriggers = null; ? (LinkedList<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) : null);
commandEvents = null; stage.set("npc-ids-to-talk-to", context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null
commandEventTriggers = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) : null);
delay = null; stage.set("npc-ids-to-kill", context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null
overrideDisplay = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL) : null);
delayMessage = null; stage.set("npc-kill-amounts", context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null
startMessage = null; ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) : null);
completeMessage = null; stage.set("mobs-to-kill", context.getSessionData(pref + CK.S_MOB_TYPES) != null
if (context.getSessionData(pref + CK.S_BREAK_NAMES) != null) { ? (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES) : null);
breakNames = (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_NAMES); stage.set("mob-amounts", context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null
breakAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_AMOUNTS); ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS) : null);
breakDurability = (LinkedList<Short>) context.getSessionData(pref + CK.S_BREAK_DURABILITY); stage.set("locations-to-kill", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null
} ? (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) : null);
if (context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null) { stage.set("kill-location-radii", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) != null
damageNames = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_NAMES); ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) : null);
damageAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS); stage.set("kill-location-names", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) != null
damageDurability = (LinkedList<Short>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY); ? (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) : null);
} stage.set("locations-to-reach", context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null
if (context.getSessionData(pref + CK.S_PLACE_NAMES) != null) { ? (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS) : null);
placeNames = (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_NAMES); stage.set("reach-location-radii", context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) != null
placeAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_AMOUNTS); ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) : null);
placeDurability = (LinkedList<Short>) context.getSessionData(pref + CK.S_PLACE_DURABILITY); stage.set("reach-location-names", context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) != null
} ? (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) : null);
if (context.getSessionData(pref + CK.S_USE_NAMES) != null) { stage.set("mobs-to-tame", context.getSessionData(pref + CK.S_TAME_TYPES) != null
useNames = (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_NAMES); ? (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES) : null);
useAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_AMOUNTS); stage.set("mob-tame-amounts", context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null
useDurability = (LinkedList<Short>) context.getSessionData(pref + CK.S_USE_DURABILITY); ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS) : null);
} stage.set("sheep-to-shear", context.getSessionData(pref + CK.S_SHEAR_COLORS) != null
if (context.getSessionData(pref + CK.S_CUT_NAMES) != null) { ? (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS) : null);
cutNames = (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_NAMES); stage.set("sheep-amounts", context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null
cutAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_AMOUNTS); ? (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) : null);
cutDurability = (LinkedList<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY); stage.set("password-displays", context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null
} ? (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) : null);
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) { LinkedList<LinkedList<String>> passPhrases
craftItems = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS); = (LinkedList<LinkedList<String>>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES);
} if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) {
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) != null) {
smeltItems = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
}
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) != null) {
enchantments = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
enchantmentIds = (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_NAMES);
enchantmentAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
}
if (context.getSessionData(pref + CK.S_BREW_ITEMS) != null) {
brewItems = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
}
if (context.getSessionData(pref + CK.S_COW_MILK) != null) {
cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK);
}
if (context.getSessionData(pref + CK.S_FISH) != null) {
fish = (Integer) context.getSessionData(pref + CK.S_FISH);
}
if (context.getSessionData(pref + CK.S_PLAYER_KILL) != null) {
players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL);
}
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) {
deliveryItems = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
deliveryNPCIds = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
deliveryMessages = (LinkedList<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES);
}
if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null) {
npcTalkIds = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO);
}
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null) {
npcKillIds = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
npcKillAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
}
if (context.getSessionData(pref + CK.S_MOB_TYPES) != null) {
mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES);
mobAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS);
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) {
mobLocs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS);
mobRadii = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS);
mobLocNames = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES);
}
}
if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) {
reachLocs = (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS);
reachRadii = (LinkedList<Integer>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS);
reachNames = (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES);
}
if (context.getSessionData(pref + CK.S_TAME_TYPES) != null) {
tames = (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES);
tameAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS);
}
if (context.getSessionData(pref + CK.S_SHEAR_COLORS) != null) {
shearColors = (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS);
shearAmounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS);
}
if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null) {
passDisplays = (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS);
passPhrases = (LinkedList<LinkedList<String>>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES);
}
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) {
customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
customObjCounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT);
customObjsData
= (LinkedList<Entry<String, Object>>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA);
}
if (context.getSessionData(pref + CK.S_START_EVENT) != null) {
startEvent = (String) context.getSessionData(pref + CK.S_START_EVENT);
}
if (context.getSessionData(pref + CK.S_FINISH_EVENT) != null) {
finishEvent = (String) context.getSessionData(pref + CK.S_FINISH_EVENT);
}
if (context.getSessionData(pref + CK.S_DEATH_EVENT) != null) {
deathEvent = (String) context.getSessionData(pref + CK.S_DEATH_EVENT);
}
if (context.getSessionData(pref + CK.S_DISCONNECT_EVENT) != null) {
disconnectEvent = (String) context.getSessionData(pref + CK.S_DISCONNECT_EVENT);
}
if (context.getSessionData(pref + CK.S_CHAT_EVENTS) != null) {
chatEvents = (LinkedList<String>) context.getSessionData(pref + CK.S_CHAT_EVENTS);
chatEventTriggers = (LinkedList<String>) context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS);
}
if (context.getSessionData(pref + CK.S_COMMAND_EVENTS) != null) {
commandEvents = (LinkedList<String>) context.getSessionData(pref + CK.S_COMMAND_EVENTS);
commandEventTriggers = (LinkedList<String>) context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS);
}
if (context.getSessionData(pref + CK.S_DELAY) != null) {
delay = (Long) context.getSessionData(pref + CK.S_DELAY);
delayMessage = (String) context.getSessionData(pref + CK.S_DELAY_MESSAGE);
}
if (context.getSessionData(pref + CK.S_DENIZEN) != null) {
script = (String) context.getSessionData(pref + CK.S_DENIZEN);
}
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) != null) {
overrideDisplay = (LinkedList<String>) context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY);
}
if (context.getSessionData(pref + CK.S_START_MESSAGE) != null) {
startMessage = (String) context.getSessionData(pref + CK.S_START_MESSAGE);
}
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) != null) {
completeMessage = (String) context.getSessionData(pref + CK.S_COMPLETE_MESSAGE);
}
if (breakNames != null && breakNames.isEmpty() == false) {
stage.set("break-block-names", breakNames);
stage.set("break-block-amounts", breakAmounts);
stage.set("break-block-durability", breakDurability);
}
if (damageNames != null && damageNames.isEmpty() == false) {
stage.set("damage-block-names", damageNames);
stage.set("damage-block-amounts", damageAmounts);
stage.set("damage-block-durability", damageDurability);
}
if (placeNames != null && placeNames.isEmpty() == false) {
stage.set("place-block-names", placeNames);
stage.set("place-block-amounts", placeAmounts);
stage.set("place-block-durability", placeDurability);
}
if (useNames != null && useNames.isEmpty() == false) {
stage.set("use-block-names", useNames);
stage.set("use-block-amounts", useAmounts);
stage.set("use-block-durability", useDurability);
}
if (cutNames != null && cutNames.isEmpty() == false) {
stage.set("cut-block-names", cutNames);
stage.set("cut-block-amounts", cutAmounts);
stage.set("cut-block-durability", cutDurability);
}
if (craftItems != null && craftItems.isEmpty() == false) {
stage.set("items-to-craft", craftItems);
} else {
stage.set("items-to-craft", null);
}
if (smeltItems != null && smeltItems.isEmpty() == false) {
stage.set("items-to-smelt", smeltItems);
} else {
stage.set("items-to-smelt", null);
}
stage.set("enchantments", enchantments);
stage.set("enchantment-item-names", enchantmentIds);
stage.set("enchantment-amounts", enchantmentAmounts);
if (brewItems != null && brewItems.isEmpty() == false) {
stage.set("items-to-brew", brewItems);
} else {
stage.set("items-to-brew", null);
}
stage.set("cows-to-milk", cows);
stage.set("fish-to-catch", fish);
stage.set("players-to-kill", players);
if (deliveryItems != null && deliveryItems.isEmpty() == false) {
stage.set("items-to-deliver", deliveryItems);
} else {
stage.set("items-to-deliver", null);
}
stage.set("npc-delivery-ids", deliveryNPCIds);
stage.set("delivery-messages", deliveryMessages);
stage.set("npc-ids-to-talk-to", npcTalkIds);
stage.set("npc-ids-to-kill", npcKillIds);
stage.set("npc-kill-amounts", npcKillAmounts);
stage.set("mobs-to-kill", mobs);
stage.set("mob-amounts", mobAmounts);
stage.set("locations-to-kill", mobLocs);
stage.set("kill-location-radii", mobRadii);
stage.set("kill-location-names", mobLocNames);
stage.set("locations-to-reach", reachLocs);
stage.set("reach-location-radii", reachRadii);
stage.set("reach-location-names", reachNames);
stage.set("mobs-to-tame", tames);
stage.set("mob-tame-amounts", tameAmounts);
stage.set("sheep-to-shear", shearColors);
stage.set("sheep-amounts", shearAmounts);
stage.set("password-displays", passDisplays);
if (passPhrases != null) {
LinkedList<String> toPut = new LinkedList<String>(); LinkedList<String> toPut = new LinkedList<String>();
for (LinkedList<String> list : passPhrases) { for (LinkedList<String> list : passPhrases) {
String combine = ""; String combine = "";
@ -2101,7 +1709,12 @@ public class QuestFactory implements ConversationAbandonedListener {
} }
stage.set("password-phrases", toPut); stage.set("password-phrases", toPut);
} }
if (customObjs != null && customObjs.isEmpty() == false) { LinkedList<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
LinkedList<Integer> customObjCounts
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT);
LinkedList<Entry<String, Object>> customObjsData
= (LinkedList<Entry<String, Object>>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA);
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) {
ConfigurationSection sec = stage.createSection("custom-objectives"); ConfigurationSection sec = stage.createSection("custom-objectives");
for (int index = 0; index < customObjs.size(); index++) { for (int index = 0; index < customObjs.size(); index++) {
ConfigurationSection sec2 = sec.createSection("custom" + (index + 1)); ConfigurationSection sec2 = sec.createSection("custom" + (index + 1));
@ -2124,87 +1737,125 @@ public class QuestFactory implements ConversationAbandonedListener {
} }
} }
} }
stage.set("script-to-run", script); stage.set("script-to-run", context.getSessionData(pref + CK.S_DENIZEN) != null
stage.set("start-event", startEvent); ? context.getSessionData(pref + CK.S_DENIZEN) : null);
stage.set("finish-event", finishEvent); stage.set("start-event", context.getSessionData(pref + CK.S_START_EVENT) != null
stage.set("death-event", deathEvent); ? context.getSessionData(pref + CK.S_START_EVENT) : null);
stage.set("disconnect-event", disconnectEvent); stage.set("finish-event", context.getSessionData(pref + CK.S_FINISH_EVENT) != null
if (chatEvents != null && chatEvents.isEmpty() == false) { ? context.getSessionData(pref + CK.S_FINISH_EVENT) : null);
stage.set("chat-events", chatEvents); stage.set("death-event", context.getSessionData(pref + CK.S_DEATH_EVENT) != null
stage.set("chat-event-triggers", chatEventTriggers); ? context.getSessionData(pref + CK.S_DEATH_EVENT) : null);
} stage.set("disconnect-event", context.getSessionData(pref + CK.S_DISCONNECT_EVENT) != null
if (commandEvents != null && commandEvents.isEmpty() == false) { ? context.getSessionData(pref + CK.S_DISCONNECT_EVENT) : null);
stage.set("command-events", commandEvents); stage.set("chat-events", context.getSessionData(pref + CK.S_CHAT_EVENTS) != null
stage.set("command-event-triggers", commandEventTriggers); ? context.getSessionData(pref + CK.S_CHAT_EVENTS) : null);
} stage.set("chat-event-triggers", context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS) != null
if (delay != null) { ? context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS) : null);
stage.set("command-events", context.getSessionData(pref + CK.S_COMMAND_EVENTS) != null
? context.getSessionData(pref + CK.S_COMMAND_EVENTS) : null);
stage.set("command-event-triggers", context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS) != null
? context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS) : null);
Long delay = (Long) context.getSessionData(pref + CK.S_DELAY);
if (context.getSessionData(pref + CK.S_DELAY) != null) {
stage.set("delay", delay.intValue() / 1000); stage.set("delay", delay.intValue() / 1000);
} }
stage.set("delay-message", delayMessage == null ? delayMessage : delayMessage.replace("\\n", "\n")); String delayMessage = (String) context.getSessionData(pref + CK.S_DELAY_MESSAGE);
stage.set("objective-override", overrideDisplay); if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) != null) {
stage.set("start-message", startMessage == null ? startMessage : startMessage.replace("\\n", "\n")); stage.set("delay-message", delayMessage == null ? delayMessage : delayMessage.replace("\\n", "\n"));
stage.set("complete-message", completeMessage == null ? completeMessage }
: completeMessage.replace("\\n", "\n")); String startMessage = (String) context.getSessionData(pref + CK.S_START_MESSAGE);
if (context.getSessionData(pref + CK.S_START_MESSAGE) != null) {
stage.set("start-message", startMessage == null ? startMessage : startMessage.replace("\\n", "\n"));
}
String completeMessage = (String) context.getSessionData(pref + CK.S_COMPLETE_MESSAGE);
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) != null) {
stage.set("complete-message", completeMessage == null ? completeMessage
: completeMessage.replace("\\n", "\n"));
}
stage.set("objective-override", context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) != null
? context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) : null);
} }
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false }
|| permRews != null && permRews.isEmpty() == false || expRew != null
|| commandRews != null && commandRews.isEmpty() == false @SuppressWarnings("unchecked")
|| commandDisplayOverrideRews != null && commandDisplayOverrideRews.isEmpty() == false private void saveRewards(ConversationContext context, ConfigurationSection section) {
|| mcMMOSkillRews != null || RPGItemRews != null ConfigurationSection rews = section.createSection("rewards");
|| heroesClassRews != null && heroesClassRews.isEmpty() == false rews.set("items", context.getSessionData(CK.REW_MONEY) != null
|| phatLootRews != null && phatLootRews.isEmpty() == false ? (Integer) context.getSessionData(CK.REW_MONEY) : null);
|| customRews != null && customRews.isEmpty() == false) { rews.set("money", context.getSessionData(CK.REW_QUEST_POINTS) != null
ConfigurationSection rews = cs.createSection("rewards"); ? (Integer) context.getSessionData(CK.REW_QUEST_POINTS) : null);
rews.set("items", (itemRews != null && itemRews.isEmpty() == false) ? itemRews : null); rews.set("quest-points", context.getSessionData(CK.REW_ITEMS) != null
rews.set("money", moneyRew); ? (List<ItemStack>) context.getSessionData(CK.REW_ITEMS) : null);
rews.set("quest-points", questPointsRew); rews.set("exp", context.getSessionData(CK.REW_EXP) != null
rews.set("exp", expRew); ? (Integer) context.getSessionData(CK.REW_EXP) : null);
rews.set("permissions", permRews); rews.set("permissions", context.getSessionData(CK.REW_COMMAND) != null
rews.set("permission-worlds", permWorldRews); ? (List<String>)context.getSessionData(CK.REW_COMMAND) : null);
rews.set("commands", commandRews); rews.set("permission-worlds", context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null
rews.set("commands-override-display", commandDisplayOverrideRews); ? (List<String>)context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) : null);
rews.set("mcmmo-skills", mcMMOSkillRews); rews.set("commands", context.getSessionData(CK.REW_PERMISSION) != null
rews.set("mcmmo-levels", mcMMOSkillAmounts); ? (List<String>) context.getSessionData(CK.REW_PERMISSION) : null);
rews.set("rpgitem-names", RPGItemRews); rews.set("commands-override-display", context.getSessionData(CK.REW_PERMISSION_WORLDS) != null
rews.set("rpgitem-amounts", RPGItemAmounts); ? (List<String>) context.getSessionData(CK.REW_PERMISSION_WORLDS) : null);
rews.set("heroes-exp-classes", heroesClassRews); rews.set("mcmmo-skills", context.getSessionData(CK.REW_MCMMO_SKILLS) != null
rews.set("heroes-exp-amounts", heroesExpRews); ? (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS) : null);
rews.set("phat-loots", phatLootRews); rews.set("mcmmo-levels", context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null
if (customRews != null) { ? (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS) : null);
ConfigurationSection customRewsSec = rews.createSection("custom-rewards"); rews.set("heroes-exp-classes", context.getSessionData(CK.REW_HEROES_CLASSES) != null
for (int i = 0; i < customRews.size(); i++) { ? (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES) : null);
ConfigurationSection customRewSec = customRewsSec.createSection("req" + (i + 1)); rews.set("heroes-exp-amounts", context.getSessionData(CK.REW_HEROES_AMOUNTS) != null
customRewSec.set("name", customRews.get(i)); ? (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS) : null);
customRewSec.set("data", customRewsData.get(i)); rews.set("phat-loots", context.getSessionData(CK.REW_PHAT_LOOTS) != null
} ? (List<String>) context.getSessionData(CK.REW_PHAT_LOOTS) : null);
LinkedList<String> customRews = context.getSessionData(CK.REW_CUSTOM) != null
? (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM) : null;
LinkedList<Map<String, Object>> customRewsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null
? (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA) : null;
if (customRews != null) {
ConfigurationSection customRewsSec = rews.createSection("custom-rewards");
for (int i = 0; i < customRews.size(); i++) {
ConfigurationSection customRewSec = customRewsSec.createSection("req" + (i + 1));
customRewSec.set("name", customRews.get(i));
customRewSec.set("data", customRewsData.get(i));
} }
rews.set("details-override", detailsOverrideRews);
} else {
cs.set("rewards", null);
} }
if (startDatePln != null || endDatePln != null || repeatCyclePln != null || cooldownPln != null) { rews.set("details-override", context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null
ConfigurationSection sch = cs.createSection("planner"); ? (List<String>)context.getSessionData(CK.REW_DETAILS_OVERRIDE) : null);
if (startDatePln != null) { if (rews.getKeys(false).isEmpty()) {
sch.set("start", startDatePln); section.set("rewards", null);
} }
if (endDatePln != null) { }
sch.set("end", endDatePln);
} private void savePlanner(ConversationContext context, ConfigurationSection section) {
if (repeatCyclePln != null) { ConfigurationSection pln = section.createSection("planner");
sch.set("repeat", repeatCyclePln.intValue() / 1000); pln.set("start", context.getSessionData(CK.PLN_START_DATE) != null
} ? (String) context.getSessionData(CK.PLN_START_DATE) : null);
if (cooldownPln != null) { pln.set("end", context.getSessionData(CK.PLN_END_DATE) != null
sch.set("cooldown", cooldownPln.intValue() / 1000); ? (String) context.getSessionData(CK.PLN_END_DATE) : null);
} pln.set("repeat", context.getSessionData(CK.PLN_REPEAT_CYCLE) != null
} else { ? (Long) context.getSessionData(CK.PLN_REPEAT_CYCLE) : null);
cs.set("planner", null); pln.set("cooldown", context.getSessionData(CK.PLN_COOLDOWN) != null
? (Long) context.getSessionData(CK.PLN_COOLDOWN) : null);
if (pln.getKeys(false).isEmpty()) {
section.set("planner", null);
}
}
private void saveOptions(ConversationContext context, ConfigurationSection section) {
ConfigurationSection opts = section.createSection("options");
opts.set("allow-commands", context.getSessionData(CK.OPT_ALLOW_COMMANDS) != null
? (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS) : null);
opts.set("allow-quitting", context.getSessionData(CK.OPT_ALLOW_QUITTING) != null
? (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING) : null);
opts.set("use-dungeonsxl-plugin", context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null
? (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) : null);
opts.set("use-parties-plugin", context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null
? (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) : null);
opts.set("share-progress-level", context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null
? (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) : null);
opts.set("require-same-quest", context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST) != null
? (Boolean) context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST) : null);
if (opts.getKeys(false).isEmpty()) {
section.set("options", null);
} }
ConfigurationSection sch = cs.createSection("options");
sch.set("allow-commands", allowCommandsOpt);
sch.set("allow-quitting", allowQuittingOpt);
sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt);
sch.set("use-parties-plugin", usePartiesPluginOpt);
sch.set("share-progress-level", shareProgressLevelOpt);
sch.set("require-same-quest", requireSameQuestOpt);
} }
} }