Finished Heroes Support

This commit is contained in:
Blackvein 2013-11-06 16:50:02 -08:00
parent 96d4885468
commit 5b90901f37
15 changed files with 908 additions and 311 deletions

View File

@ -120,6 +120,8 @@
<version>2.3.2</version>
<configuration>
<showDeprecation>true</showDeprecation>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>

View File

@ -1,5 +1,6 @@
package me.blackvein.quests;
import me.blackvein.quests.util.ColorUtil;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;

View File

@ -0,0 +1,7 @@
Heroes support
Requirements
heroes-primary-class:
heroes-secondary-class:
Rewards
heroes-exp-classes:
heroes-exp-amounts:

View File

@ -2,6 +2,7 @@ package me.blackvein.quests;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.characters.Hero;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.util.ItemUtil;
@ -50,10 +51,10 @@ public class Quest {
LinkedList<ItemStack> itemRewards = new LinkedList<ItemStack>();
LinkedList<Integer> rpgItemRewardIDs = new LinkedList<Integer>();
LinkedList<Integer> rpgItemRewardAmounts = new LinkedList<Integer>();
//mcMMO
List<String> mcmmoSkills = new LinkedList<String>();
List<Integer> mcmmoAmounts = new LinkedList<Integer>();
//
List<String> heroesClasses = new LinkedList<String>();
List<Double> heroesAmounts = new LinkedList<Double>();
//
public void nextStage(Quester q) {
@ -179,26 +180,29 @@ public class Quest {
}
for(String s : mcMMOSkillReqs) {
for (String s : mcMMOSkillReqs) {
final SkillType st = Quests.getMcMMOSkill(s);
final int lvl = mcMMOAmountReqs.get(mcMMOSkillReqs.indexOf(s));
if(UserManager.getPlayer(player).getProfile().getSkillLevel(st) < lvl)
if (UserManager.getPlayer(player).getProfile().getSkillLevel(st) < lvl) {
return false;
}
}
if(heroesPrimaryClassReq != null){
if (heroesPrimaryClassReq != null) {
if(plugin.testPrimaryHeroesClass(heroesPrimaryClassReq, player.getName()) == false)
if (plugin.testPrimaryHeroesClass(heroesPrimaryClassReq, player.getName()) == false) {
return false;
}
}
if(heroesSecondaryClassReq != null){
if (heroesSecondaryClassReq != null) {
if(plugin.testSecondaryHeroesClass(heroesSecondaryClassReq, player.getName()) == false)
if (plugin.testSecondaryHeroesClass(heroesSecondaryClassReq, player.getName()) == false) {
return false;
}
}
@ -276,6 +280,14 @@ public class Quest {
}
for (String s : heroesClasses) {
Hero hero = plugin.getHero(player.getName());
hero.addExp(heroesAmounts.get(heroesClasses.indexOf(s)), Quests.heroes.getClassManager().getClass(s), player.getLocation());
none = null;
}
if (exp > 0) {
player.giveExp(exp);
none = null;
@ -328,6 +340,12 @@ public class Quest {
}
}
if (heroesClasses.isEmpty() == false) {
for (String s : heroesClasses) {
player.sendMessage("- " + ChatColor.AQUA + heroesAmounts.get(heroesClasses.indexOf(s)) + " " + ChatColor.BLUE + s + " Experience");
}
}
if (none != null) {
player.sendMessage(none);
}
@ -444,6 +462,14 @@ public class Quest {
return false;
}
if (other.heroesClasses.equals(heroesClasses) == false) {
return false;
}
if (other.heroesAmounts.equals(heroesAmounts) == false) {
return false;
}
if (other.moneyReq != moneyReq) {
return false;
}
@ -522,7 +548,6 @@ public class Quest {
return false;
}
if (other.stages.equals(stages) == false) {
return false;
}

View File

@ -1,5 +1,6 @@
package me.blackvein.quests;
import me.blackvein.quests.util.ColorUtil;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
@ -828,7 +829,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
}
@SuppressWarnings("unchecked")
public static void saveQuest(ConversationContext cc, ConfigurationSection cs) {
String edit = null;
@ -871,6 +871,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<String> questBlocks = null;
LinkedList<String> mcMMOSkillReqs = null;
LinkedList<Integer> mcMMOAmountReqs = null;
String heroesPrimaryReq = null;
String heroesSecondaryReq = null;
String failMessage = null;
Integer moneyRew = null;
@ -883,7 +885,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<String> permRews = null;
LinkedList<String> mcMMOSkillRews = null;
LinkedList<Integer> mcMMOSkillAmounts = null;
LinkedList<String> heroesClassRews = null;
LinkedList<Double> heroesExpRews = null;
if (cc.getSessionData(CK.Q_REDO_DELAY) != null) {
redo = (Long) cc.getSessionData(CK.Q_REDO_DELAY);
}
@ -925,6 +930,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
mcMMOSkillReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_MCMMO_SKILLS);
mcMMOAmountReqs = (LinkedList<Integer>) cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
}
if (cc.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) {
heroesPrimaryReq = (String) cc.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS);
}
if (cc.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
heroesSecondaryReq = (String) cc.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS);
}
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
failMessage = (String) cc.getSessionData(CK.Q_FAIL_MESSAGE);
@ -976,6 +989,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
mcMMOSkillRews = (LinkedList<String>) cc.getSessionData(CK.REW_MCMMO_SKILLS);
mcMMOSkillAmounts = (LinkedList<Integer>) cc.getSessionData(CK.REW_MCMMO_AMOUNTS);
}
if (cc.getSessionData(CK.REW_HEROES_CLASSES) != null) {
heroesClassRews = (LinkedList<String>) cc.getSessionData(CK.REW_HEROES_CLASSES);
heroesExpRews = (LinkedList<Double>) cc.getSessionData(CK.REW_HEROES_AMOUNTS);
}
cs.set("name", name);
cs.set("npc-giver-id", npcStart);
@ -985,7 +1003,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set("finish-message", finish);
cs.set(CK.S_FINISH_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) || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false)) {
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) {
ConfigurationSection reqs = cs.createSection("requirements");
List<String> items = new LinkedList<String>();
@ -1006,6 +1024,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
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);
reqs.set("fail-requirement-message", failMessage);
} else {
@ -1341,11 +1361,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false || permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false || mcMMOSkillRews != null || RPGItemRews != null) {
System.out.println("HERE 1");
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false || permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false || mcMMOSkillRews != null || RPGItemRews != null || heroesClassRews != null && heroesClassRews.isEmpty() == false) {
System.out.println("HERE 2");
ConfigurationSection rews = cs.createSection("rewards");
rews.set("items", (itemRews.isEmpty() == false) ? itemRews : null);
rews.set("items", (itemRews != null && itemRews.isEmpty() == false) ? itemRews : null);
rews.set("money", moneyRew);
rews.set("quest-points", questPointsRew);
rews.set("exp", expRew);
@ -1355,10 +1379,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
rews.set("mcmmo-levels", mcMMOSkillAmounts);
rews.set("rpgitem-ids", RPGItemRews);
rews.set("rpgitem-amounts", RPGItemAmounts);
rews.set("heroes-exp-classes", heroesClassRews);
rews.set("heroes-exp-amounts", heroesExpRews);
} else {
cs.set("rewards", null);
}
System.out.println("HERE 3");
}
@ -1454,11 +1482,21 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cc.setSessionData(CK.REW_MCMMO_SKILLS, q.mcmmoSkills);
cc.setSessionData(CK.REW_MCMMO_AMOUNTS, q.mcmmoAmounts);
}
if (q.heroesClasses.isEmpty() == false) {
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses);
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts);
}
if (q.rpgItemRewardIDs.isEmpty() == false) {
cc.setSessionData(CK.REW_RPG_ITEM_IDS, q.rpgItemRewardIDs);
cc.setSessionData(CK.REW_RPG_ITEM_AMOUNTS, q.rpgItemRewardAmounts);
}
if(q.heroesClasses.isEmpty() == false) {
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses);
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts);
}
//
//Stages

View File

@ -1,5 +1,6 @@
package me.blackvein.quests;
import me.blackvein.quests.util.ColorUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
@ -566,9 +567,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if(quest.heroesPrimaryClassReq != null){
if(this.testPrimaryHeroesClass(quest.heroesPrimaryClassReq, player.getName())){
cs.sendMessage(BOLD + "" + DARKRED + quest.heroesPrimaryClassReq + RESET + "" + RED + " class");
}else{
cs.sendMessage(BOLD + "" + GREEN + quest.heroesPrimaryClassReq + RESET + "" + DARKGREEN + " class");
}else{
cs.sendMessage(BOLD + "" + DARKRED + quest.heroesPrimaryClassReq + RESET + "" + RED + " class");
}
}
@ -3408,27 +3409,34 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (Quests.checkList(config.getList("quests." + s + ".rewards.mcmmo-skills"), String.class)) {
if (config.contains("quests." + s + ".rewards.mcmmo-levels")) {
if(Quests.checkList(config.getList("quests." + s + ".rewards.mcmmo-levels"), Integer.class)){
boolean failed = false;
for (String skill : config.getStringList("quests." + s + ".rewards.mcmmo-skills")) {
boolean failed = false;
for (String skill : config.getStringList("quests." + s + ".rewards.mcmmo-skills")) {
if (Quests.getMcMMOSkill(skill) == null) {
printSevere("[Quests] " + skill + " in mcmmo-skills: Reward in Quest " + quest.name + " is not a valid mcMMO skill name!");
failed = true;
break;
if (Quests.getMcMMOSkill(skill) == null) {
printSevere("[Quests] " + skill + " in mcmmo-skills: Reward in Quest " + quest.name + " is not a valid mcMMO skill name!");
failed = true;
break;
}
}
if (failed) {
continue;
}
}
if (failed) {
quest.mcmmoSkills.clear();
quest.mcmmoAmounts.clear();
quest.mcmmoSkills.addAll(config.getStringList("quests." + s + ".rewards.mcmmo-skills"));
quest.mcmmoAmounts.addAll(config.getIntegerList("quests." + s + ".rewards.mcmmo-levels"));
} else {
printSevere("[Quests] mcmmo-levels: Reward in Quest " + quest.name + " is not a list of numbers!");
continue;
}
quest.mcmmoSkills.clear();
quest.mcmmoAmounts.clear();
quest.mcmmoSkills.addAll(config.getStringList("quests." + s + ".rewards.mcmmo-skills"));
quest.mcmmoAmounts.addAll(config.getIntegerList("quests." + s + ".rewards.mcmmo-levels"));
} else {
printSevere("[Quests] Rewards for Quest " + quest.name + " is missing mcmmo-levels:");
continue;
@ -3439,6 +3447,50 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
continue;
}
}
if (config.contains("quests." + s + ".rewards.heroes-exp-classes")) {
if (Quests.checkList(config.getList("quests." + s + ".rewards.heroes-exp-classes"), String.class)) {
if (config.contains("quests." + s + ".rewards.heroes-exp-amounts")) {
if (Quests.checkList(config.getList("quests." + s + ".rewards.heroes-exp-amounts"), Double.class)) {
boolean failed = false;
for (String heroClass : config.getStringList("quests." + s + ".rewards.heroes-exp-classes")) {
if (Quests.heroes.getClassManager().getClass(heroClass) == null) {
printSevere("[Quests] " + heroClass + " in heroes-exp-classes: Reward in Quest " + quest.name + " is not a valid Heroes class name!");
failed = true;
break;
}
}
if (failed) {
continue;
}
quest.heroesClasses.clear();
quest.heroesAmounts.clear();
quest.heroesClasses.addAll(config.getStringList("quests." + s + ".rewards.heroes-exp-classes"));
quest.heroesAmounts.addAll(config.getDoubleList("quests." + s + ".rewards.heroes-exp-amounts"));
} else {
printSevere("[Quests] heroes-exp-amounts: Reward in Quest " + quest.name + " is not a list of experience amounts (decimal numbers)!");
continue;
}
} else {
printSevere("[Quests] Rewards for Quest " + quest.name + " is missing heroes-exp-amounts:");
continue;
}
} else {
printSevere("[Quests] heroes-exp-classes: Reward in Quest " + quest.name + " is not a list of Heroes classes!");
continue;
}
}
//
quests.add(quest);

View File

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import me.ThaH3lper.com.Mobs.EpicMobs;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.util.ColorUtil;
import me.blackvein.quests.Event;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quester;
@ -2254,7 +2254,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
text += DARKGRAY + "|---------" + Lang.get("stageEditorOptional") + "---------|";
text += DARKGRAY + "|---------" + Lang.get("stageEditorOptional") + "---------|\n";
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) {
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetKillLocations") + " (" + Lang.get("noneSet") + ")\n";

View File

@ -6,7 +6,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.util.ColorUtil;
import me.blackvein.quests.ItemData;
import me.blackvein.quests.ItemData.Data;
import me.blackvein.quests.Quester;

View File

@ -2,7 +2,7 @@ package me.blackvein.quests.prompts;
import java.text.MessageFormat;
import java.util.LinkedList;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.util.ColorUtil;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;

View File

@ -1,12 +1,13 @@
package me.blackvein.quests.prompts;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import java.util.Arrays;
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.util.ColorUtil;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
@ -29,7 +30,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
public RequirementsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9");
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
quests = plugin;
factory = qf;
@ -98,7 +99,6 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
if (Quests.mcmmo != null) {
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
@ -115,18 +115,35 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
text += GRAY + "6 - Set mcMMO requirements (mcMMO not installed)\n";
}
if (Quests.heroes != null) {
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - Set Heroes requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - Set Heroes requirements\n";
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) {
text += AQUA + " Primary Class: " + BLUE + (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) + "\n";
}
if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
text += AQUA + " Secondary Class: " + BLUE + (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) + "\n";
}
}
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == 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 && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
text += GRAY + "" + BOLD + "8 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
text += RED + "" + BOLD + "8 - " + RESET + RED + "Set fail requirements message (Required)\n";
} else {
text += BLUE + "" + BOLD + "8 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n";
text += GRAY + "8 - Set Heroes requirements (Heroes not installed)\n";
}
text += GREEN + "" + BOLD + "9" + RESET + YELLOW + " - Done";
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == 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 && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
text += GRAY + "" + BOLD + "9 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
text += RED + "" + BOLD + "9 - " + RESET + RED + "Set fail requirements message (Required)\n";
} else {
text += BLUE + "" + BOLD + "9 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n";
}
text += GREEN + "" + BOLD + "10" + RESET + YELLOW + " - Done";
return text;
@ -148,14 +165,21 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
} else if (input.equalsIgnoreCase("6")) {
return new QuestListPrompt(false);
} else if (input.equalsIgnoreCase("7")) {
if(Quests.mcmmo != null)
if (Quests.mcmmo != null) {
return new mcMMOPrompt();
else
} else {
return new RequirementsPrompt(quests, factory);
}
} else if (input.equalsIgnoreCase("8")) {
return new FailMessagePrompt();
if (Quests.heroes != null) {
return new HeroesPrompt();
} else {
return new RequirementsPrompt(quests, factory);
}
} else if (input.equalsIgnoreCase("9")) {
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 || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null) {
return new FailMessagePrompt();
} else if (input.equalsIgnoreCase("10")) {
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 || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null || context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
context.getForWhom().sendRawMessage(RED + "You must set a fail requirements message!");
@ -365,7 +389,6 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n";
if (context.getSessionData(CK.REQ_ITEMS_REMOVE) == null) {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set remove items (No values set)\n";
} else {
@ -505,79 +528,79 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
}
}
private class mcMMOPrompt extends FixedSetPrompt {
public mcMMOPrompt(){
public mcMMOPrompt() {
super("1", "2", "3");
}
@Override
public String getPromptText(ConversationContext cc) {
String text = DARKGREEN + "- mcMMO Requirements -\n";
if(cc.getSessionData(CK.REQ_MCMMO_SKILLS) == null){
if (cc.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
text += BOLD + "" + GREEN + "1" + RESET + GREEN + " - Set skills (None set)\n";
}else{
} else {
text += BOLD + "" + GREEN + "1" + RESET + GREEN + " - Set skills\n";
LinkedList<String> skills = (LinkedList<String>) cc.getSessionData(CK.REQ_MCMMO_SKILLS);
for(String skill : skills){
for (String skill : skills) {
text += GRAY + " - " + AQUA + skill + "\n";
}
}
if(cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) == null){
if (cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) == null) {
text += BOLD + "" + GREEN + "2" + RESET + GREEN + " - Set skill amounts (None set)\n";
}else{
} else {
text += BOLD + "" + GREEN + "2" + RESET + GREEN + " - Set skill amounts\n";
LinkedList<Integer> amounts = (LinkedList<Integer>) cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
for(int i : amounts){
for (int i : amounts) {
text += GRAY + " - " + AQUA + i + "\n";
}
}
text += BOLD + "" + GREEN + "3" + RESET + GREEN + " - Done";
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
if(input.equalsIgnoreCase("1")){
if (input.equalsIgnoreCase("1")) {
return new mcMMOSkillsPrompt();
}else if(input.equalsIgnoreCase("2")){
} else if (input.equalsIgnoreCase("2")) {
return new mcMMOAmountsPrompt();
}else if(input.equalsIgnoreCase("3")){
} else if (input.equalsIgnoreCase("3")) {
return new RequirementsPrompt(quests, factory);
}
return null;
}
}
private class mcMMOSkillsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String skillList =
DARKGREEN + "-Skill List-\n" +
GREEN + "Acrobatics\n" +
GREEN + "All\n" +
GREEN + "Archery\n" +
GREEN + "Axes\n" +
GREEN + "Excavation\n" +
GREEN + "Fishing\n" +
GREEN + "Herbalism\n" +
GREEN + "Mining\n" +
GREEN + "Repair\n" +
GREEN + "Smelting\n" +
GREEN + "Swords\n" +
GREEN + "Taming\n" +
GREEN + "Unarmed\n" +
GREEN + "Woodcutting\n\n";
String skillList
= DARKGREEN + "-Skill List-\n"
+ GREEN + "Acrobatics\n"
+ GREEN + "All\n"
+ GREEN + "Archery\n"
+ GREEN + "Axes\n"
+ GREEN + "Excavation\n"
+ GREEN + "Fishing\n"
+ GREEN + "Herbalism\n"
+ GREEN + "Mining\n"
+ GREEN + "Repair\n"
+ GREEN + "Smelting\n"
+ GREEN + "Swords\n"
+ GREEN + "Taming\n"
+ GREEN + "Unarmed\n"
+ GREEN + "Woodcutting\n\n";
return skillList + YELLOW + "Enter mcMMO skills, separating each one by a space, or enter \'clear\' to clear the list, "
+ "or \'cancel\' to return.\n";
@ -587,44 +610,44 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
LinkedList<String> skills = new LinkedList<String>();
for(String s : input.split(" ")){
for (String s : input.split(" ")) {
String formatted = MiscUtil.getCapitalized(s);
if(Quests.getMcMMOSkill(formatted) != null){
if (Quests.getMcMMOSkill(formatted) != null) {
skills.add(formatted);
}else if(skills.contains(formatted)){
} else if (skills.contains(formatted)) {
cc.getForWhom().sendRawMessage(YELLOW + "Error: List contains duplicates!");
return new mcMMOSkillsPrompt();
}else{
} else {
cc.getForWhom().sendRawMessage(YELLOW + "Error: " + RED + s + YELLOW + " is not an mcMMO skill name!");
return new mcMMOSkillsPrompt();
}
}
cc.setSessionData(CK.REQ_MCMMO_SKILLS, skills);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("clear")){
} else if (input.equalsIgnoreCase("clear")) {
cc.getForWhom().sendRawMessage(YELLOW + "mcMMO skill requirements cleared.");
cc.setSessionData(CK.REQ_MCMMO_SKILLS, null);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("cancel")){
} else if (input.equalsIgnoreCase("cancel")) {
return new mcMMOPrompt();
}
return new mcMMOSkillsPrompt();
}
}
private class mcMMOAmountsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
@ -636,38 +659,217 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
LinkedList<Integer> amounts = new LinkedList<Integer>();
for(String s : input.split(" ")){
try{
for (String s : input.split(" ")) {
try {
int i = Integer.parseInt(s);
amounts.add(i);
}catch(NumberFormatException nfe){
} catch (NumberFormatException nfe) {
cc.getForWhom().sendRawMessage(YELLOW + "Error: " + RED + s + YELLOW + " is not a number!");
return new mcMMOAmountsPrompt();
}
}
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, amounts);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("clear")){
} else if (input.equalsIgnoreCase("clear")) {
cc.getForWhom().sendRawMessage(YELLOW + "mcMMO skill amount requirements cleared.");
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, null);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("cancel")){
} else if (input.equalsIgnoreCase("cancel")) {
return new mcMMOPrompt();
}
return new mcMMOAmountsPrompt();
}
}
private class HeroesPrompt extends FixedSetPrompt {
public HeroesPrompt() {
super("1", "2", "3");
}
@Override
public String getPromptText(ConversationContext cc) {
String text = DARKGREEN + "- Heroes Requirements -\n";
if (cc.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null) {
text += BOLD + "" + GREEN + "1" + RESET + GREEN + " - Set Primary Class (None set)\n";
} else {
text += BOLD + "" + GREEN + "1" + RESET + GREEN + " - Set Primary Class (" + AQUA + (String) cc.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) + GREEN + ")\n";
}
if (cc.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
text += BOLD + "" + GREEN + "2" + RESET + GREEN + " - Set Secondary Class (None set)\n";
} else {
text += BOLD + "" + GREEN + "2" + RESET + GREEN + " - Set Secondary Class (" + AQUA + (String) cc.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) + GREEN + ")\n";
}
text += BOLD + "" + GREEN + "3" + RESET + GREEN + " - Done";
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("1")) {
return new HeroesPrimaryPrompt();
} else if (input.equalsIgnoreCase("2")) {
return new HeroesSecondaryPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new RequirementsPrompt(quests, factory);
}
return null;
}
}
private class HeroesPrimaryPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = PURPLE + "- " + PINK + "Primary Classes" + PURPLE + " -\n";
LinkedList<String> list = new LinkedList<String>();
for (HeroClass hc : Quests.heroes.getClassManager().getClasses()) {
if (hc.isPrimary()) {
list.add(hc.getName());
}
}
if (list.isEmpty()) {
text += GRAY + "(None)";
} else {
Collections.sort(list);
for (String s : list) {
text += PURPLE + "- " + PINK + s + "\n";
}
}
text += YELLOW + "Enter a Heroes Primary Class name, or enter \"clear\" to clear the requirement, or \"cancel\" to return.";
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("clear") == false && input.equalsIgnoreCase("cancel") == false) {
HeroClass hc = Quests.heroes.getClassManager().getClass(input);
if (hc != null) {
if (hc.isPrimary()) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, hc.getName());
return new HeroesPrompt();
} else {
cc.getForWhom().sendRawMessage(RED + "The " + PINK + hc.getName() + RED + " class is not primary!");
return new HeroesPrimaryPrompt();
}
} else {
cc.getForWhom().sendRawMessage(RED + "Class not found!");
return new HeroesPrimaryPrompt();
}
} else if (input.equalsIgnoreCase("clear")) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, null);
cc.getForWhom().sendRawMessage(YELLOW + "Heroes Primary Class requirement cleared.");
return new HeroesPrompt();
} else {
return new HeroesPrompt();
}
}
}
private class HeroesSecondaryPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = PURPLE + "- " + PINK + "Secondary Classes" + PURPLE + " -\n";
LinkedList<String> list = new LinkedList<String>();
for (HeroClass hc : Quests.heroes.getClassManager().getClasses()) {
if (hc.isSecondary()) {
list.add(hc.getName());
}
}
if (list.isEmpty()) {
text += GRAY + "(None)";
} else {
Collections.sort(list);
for (String s : list) {
text += PURPLE + "- " + PINK + s + "\n";
}
}
text += YELLOW + "Enter a Heroes Secondary Class name, or enter \"clear\" to clear the requirement, or \"cancel\" to return.";
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("clear") == false && input.equalsIgnoreCase("cancel") == false) {
HeroClass hc = Quests.heroes.getClassManager().getClass(input);
if (hc != null) {
if (hc.isSecondary()) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, hc.getName());
return new HeroesPrompt();
} else {
cc.getForWhom().sendRawMessage(RED + "The " + PINK + hc.getName() + RED + " class is not secondary!");
return new HeroesSecondaryPrompt();
}
} else {
cc.getForWhom().sendRawMessage(RED + "Class not found!");
return new HeroesSecondaryPrompt();
}
} else if (input.equalsIgnoreCase("clear")) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, null);
cc.getForWhom().sendRawMessage(YELLOW + "Heroes Secondary Class requirement cleared.");
return new HeroesPrompt();
} else {
return new HeroesPrompt();
}
}
}
private class FailMessagePrompt extends StringPrompt {

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
package me.blackvein.quests.prompts;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.util.ColorUtil;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;

View File

@ -22,10 +22,10 @@ public class CK {
public static final String REQ_ITEMS = "itemReqs";
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
public static final String REQ_PERMISSION = "permissionReqs";
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
public static final String REQ_QUEST = "questReqs";
public static final String REQ_QUEST_BLOCK= "questBlocks";
@ -40,6 +40,8 @@ public class CK {
public static final String REW_PERMISSION = "permissionRews";
public static final String REW_MCMMO_SKILLS = "mcMMOSkillRews";
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
public static final String REW_HEROES_CLASSES = "heroesClassRews";
public static final String REW_HEROES_AMOUNTS = "heroesAmountRews";
//Stages
public static final String S_BREAK_IDS = "breakIds";

View File

@ -0,0 +1,31 @@
package me.blackvein.quests.util;
import org.bukkit.ChatColor;
public interface ColorUtil {
static final ChatColor BOLD = ChatColor.BOLD;
static final ChatColor ITALIC = ChatColor.ITALIC;
static final ChatColor UNDERLINE = ChatColor.UNDERLINE;
static final ChatColor STRIKETHROUGH = ChatColor.STRIKETHROUGH;
static final ChatColor MAGIC = ChatColor.MAGIC;
static final ChatColor RESET = ChatColor.RESET;
static final ChatColor WHITE = ChatColor.WHITE;
static final ChatColor BLACK = ChatColor.BLACK;
static final ChatColor AQUA = ChatColor.AQUA;
static final ChatColor DARKAQUA = ChatColor.DARK_AQUA;
static final ChatColor BLUE = ChatColor.BLUE;
static final ChatColor DARKBLUE = ChatColor.DARK_BLUE;
static final ChatColor GOLD = ChatColor.GOLD;
static final ChatColor GRAY = ChatColor.GRAY;
static final ChatColor DARKGRAY = ChatColor.DARK_GRAY;
static final ChatColor PINK = ChatColor.LIGHT_PURPLE;
static final ChatColor PURPLE = ChatColor.DARK_PURPLE;
static final ChatColor GREEN = ChatColor.GREEN;
static final ChatColor DARKGREEN = ChatColor.DARK_GREEN;
static final ChatColor RED = ChatColor.RED;
static final ChatColor DARKRED = ChatColor.DARK_RED;
static final ChatColor YELLOW = ChatColor.YELLOW;
}

View File

@ -2,7 +2,6 @@ package me.blackvein.quests.util;
import java.util.LinkedList;
import java.util.Map.Entry;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import org.bukkit.ChatColor;