NEW experience requirement

This commit is contained in:
PikaMug 2022-04-11 23:52:07 -04:00
parent 39633f2d15
commit 0ba111ec6a
11 changed files with 233 additions and 93 deletions

View File

@ -14,19 +14,34 @@ package me.blackvein.quests.quests;
public interface Planner {
String getStart();
long getStartInMillis();
boolean hasStart();
void setStart(final String start);
String getEnd();
long getEndInMillis();
boolean hasEnd();
void setEnd(final String end);
long getRepeat();
boolean hasRepeat();
void setRepeat(final long repeat);
long getCooldown();
boolean hasCooldown();
void setCooldown(final long cooldown);
boolean getOverride();
void setOverride(final boolean override);
}

View File

@ -26,6 +26,10 @@ public interface Requirements {
void setQuestPoints(final int questPoints);
int getExp();
void setExp(final int exp);
List<ItemStack> getItems();
void setItems(final List<ItemStack> items);

View File

@ -19,36 +19,67 @@ import java.util.Map;
public interface Rewards {
int getMoney();
void setMoney(final int money);
int getQuestPoints();
void setQuestPoints(final int questPoints);
int getExp();
void setExp(final int exp);
List<String> getCommands();
void setCommands(final List<String> commands);
List<String> getCommandsOverrideDisplay();
void setCommandsOverrideDisplay(final List<String> commandsOverrideDisplay);
List<String> getPermissions();
void setPermissions(final List<String> permissions);
List<String> getPermissionWorlds();
void setPermissionWorlds(final List<String> worldNames);
List<ItemStack> getItems();
void setItems(final List<ItemStack> items);
List<String> getMcmmoSkills();
void setMcmmoSkills(final List<String> mcmmoSkills);
List<Integer> getMcmmoAmounts();
void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
List<String> getHeroesClasses();
void setHeroesClasses(final List<String> heroesClasses);
List<Double> getHeroesAmounts();
void setHeroesAmounts(final List<Double> heroesAmounts);
int getPartiesExperience();
void setPartiesExperience(final int partiesExperience);
List<String> getPhatLoots();
void setPhatLoots(final List<String> phatLoots);
Map<String, Map<String, Object>> getCustomRewards();
void setCustomRewards(final Map<String, Map<String, Object>> customRewards);
List<String> getDetailsOverride();
void setDetailsOverride(final List<String> detailsOverride);
/**

View File

@ -1957,6 +1957,13 @@ public class Quests extends JavaPlugin implements QuestsAPI {
throw new QuestFormatException("Reward money is not a number", questKey);
}
}
if (config.contains("quests." + questKey + ".rewards.quest-points")) {
if (config.getInt("quests." + questKey + ".rewards.quest-points", -999) != -999) {
rewards.setQuestPoints(config.getInt("quests." + questKey + ".rewards.quest-points"));
} else {
throw new QuestFormatException("Reward quest-points is not a number", questKey);
}
}
if (config.contains("quests." + questKey + ".rewards.exp")) {
if (config.getInt("quests." + questKey + ".rewards.exp", -999) != -999) {
rewards.setExp(config.getInt("quests." + questKey + ".rewards.exp"));
@ -1996,13 +2003,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
throw new QuestFormatException("Reward permissions is not a list of worlds", questKey);
}
}
if (config.contains("quests." + questKey + ".rewards.quest-points")) {
if (config.getInt("quests." + questKey + ".rewards.quest-points", -999) != -999) {
rewards.setQuestPoints(config.getInt("quests." + questKey + ".rewards.quest-points"));
} else {
throw new QuestFormatException("Reward quest-points is not a number", questKey);
}
}
if (depends.isPluginAvailable("mcMMO")) {
if (config.contains("quests." + questKey + ".rewards.mcmmo-skills")) {
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.mcmmo-skills"),
@ -2175,6 +2175,13 @@ public class Quests extends JavaPlugin implements QuestsAPI {
throw new QuestFormatException("Requirement quest-points is not a number", questKey);
}
}
if (config.contains("quests." + questKey + ".requirements.exp")) {
if (config.getInt("quests." + questKey + ".requirements.exp", -999) != -999) {
requires.setExp(config.getInt("quests." + questKey + ".requirements.exp"));
} else {
throw new QuestFormatException("Requirement exp is not a number", questKey);
}
}
if (config.contains("quests." + questKey + ".requirements.quest-blocks")) {
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.quest-blocks"),
String.class)) {

View File

@ -136,10 +136,10 @@ public class Stage implements IStage {
private String completeMessage = null;
private String startMessage = null;
private LinkedList<String> objectiveOverrides = new LinkedList<>();
private LinkedList<ICustomObjective> customObjectives = new LinkedList<>();
private LinkedList<Integer> customObjectiveCounts = new LinkedList<>();
private LinkedList<String> customObjectiveDisplays = new LinkedList<>();
private LinkedList<Entry<String, Object>> customObjectiveData = new LinkedList<>();
private final LinkedList<ICustomObjective> customObjectives = new LinkedList<>();
private final LinkedList<Integer> customObjectiveCounts = new LinkedList<>();
private final LinkedList<String> customObjectiveDisplays = new LinkedList<>();
private final LinkedList<Entry<String, Object>> customObjectiveData = new LinkedList<>();
public LinkedList<ItemStack> getBlocksToBreak() {
return blocksToBreak;

View File

@ -52,7 +52,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final String classPrefix;
private boolean hasRequirement = false;
private final int size = 11;
private final int size = 12;
public RequirementsPrompt(final ConversationContext context) {
super(context);
@ -85,21 +85,22 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
case 4:
case 5:
case 6:
case 9:
return ChatColor.BLUE;
case 7:
case 10:
return ChatColor.BLUE;
case 8:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 8:
case 9:
if (plugin.getDependencies().getHeroes() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 10:
case 11:
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) == null) {
if (!hasRequirement) {
return ChatColor.GRAY;
@ -109,7 +110,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.BLUE;
}
case 11:
case 12:
return ChatColor.GREEN;
default:
return null;
@ -130,32 +131,34 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
case 3:
return ChatColor.YELLOW + Lang.get("reqSetItem");
case 4:
return ChatColor.YELLOW + Lang.get("reqSetPerms");
return ChatColor.YELLOW + Lang.get("reqSetExperience");
case 5:
return ChatColor.YELLOW + Lang.get("reqSetQuest");
return ChatColor.YELLOW + Lang.get("reqSetPerms");
case 6:
return ChatColor.YELLOW + Lang.get("reqSetQuestBlocks");
return ChatColor.YELLOW + Lang.get("reqSetQuest");
case 7:
return ChatColor.YELLOW + Lang.get("reqSetQuestBlocks");
case 8:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return ChatColor.YELLOW + Lang.get("reqSetMcMMO");
} else {
return ChatColor.GRAY + Lang.get("reqSetMcMMO");
}
case 8:
case 9:
if (plugin.getDependencies().getHeroes() != null) {
return ChatColor.YELLOW + Lang.get("reqSetHeroes");
} else {
return ChatColor.GRAY + Lang.get("reqSetHeroes");
}
case 9:
return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom");
case 10:
return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom");
case 11:
if (!hasRequirement) {
return ChatColor.GRAY + Lang.get("overrideCreateSet");
} else {
return ChatColor.YELLOW + Lang.get("overrideCreateSet");
}
case 11:
case 12:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
@ -202,6 +205,13 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
return text.toString();
}
case 4:
if (context.getSessionData(CK.REQ_EXP) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REQ_EXP) + " "
+ Lang.get("points") + ChatColor.GRAY + ")";
}
case 5:
if (context.getSessionData(CK.REQ_PERMISSION) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
@ -214,7 +224,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
return text.toString();
}
case 5:
case 6:
if (context.getSessionData(CK.REQ_QUEST) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
@ -230,7 +240,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
return text.toString();
}
case 6:
case 7:
if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
@ -246,7 +256,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
return text.toString();
}
case 7:
case 8:
if (plugin.getDependencies().getMcmmoClassic() != null) {
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
@ -267,7 +277,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 8:
case 9:
if (plugin.getDependencies().getHeroes() != null) {
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
@ -287,7 +297,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 9:
case 10:
if (context.getSessionData(CK.REQ_CUSTOM) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
@ -300,7 +310,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
return text.toString();
}
case 10:
case 11:
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) == null) {
if (!hasRequirement) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
@ -318,7 +328,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
return text.toString();
}
case 11:
case 12:
return "";
default:
return null;
@ -375,26 +385,28 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
case 3:
return new RequirementsItemListPrompt(context);
case 4:
return new RequirementsPermissionsPrompt(context);
return new RequirementsExperiencePrompt(context);
case 5:
return new RequirementsQuestListPrompt(context, true);
return new RequirementsPermissionsPrompt(context);
case 6:
return new RequirementsQuestListPrompt(context, false);
return new RequirementsQuestListPrompt(context, true);
case 7:
return new RequirementsQuestListPrompt(context, false);
case 8:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return new RequirementsMcMMOListPrompt(context);
} else {
return new RequirementsPrompt(context);
}
case 8:
case 9:
if (plugin.getDependencies().getHeroes() != null) {
return new RequirementsHeroesListPrompt(context);
} else {
return new RequirementsPrompt(context);
}
case 9:
return new CustomRequirementModulePrompt(context);
case 10:
return new CustomRequirementModulePrompt(context);
case 11:
if (hasRequirement) {
return new OverridePrompt.Builder()
.context(context)
@ -405,7 +417,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new RequirementsPrompt(context);
}
case 11:
case 12:
return plugin.getQuestFactory().returnToMenu(context);
default:
return new RequirementsPrompt(context);
@ -416,6 +428,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(CK.REQ_MONEY) != null
|| context.getSessionData(CK.REQ_QUEST_POINTS) != null
|| context.getSessionData(CK.REQ_ITEMS) != null
|| context.getSessionData(CK.REQ_EXP) != null
|| context.getSessionData(CK.REQ_PERMISSION) != null
|| context.getSessionData(CK.REQ_QUEST) != null
|| context.getSessionData(CK.REQ_QUEST_BLOCK) != null
@ -781,6 +794,60 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
}
public class RequirementsExperiencePrompt extends QuestsEditorStringPrompt {
public RequirementsExperiencePrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("reqExperiencePrompt");
}
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
if (context.getPlugin() != null) {
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
}
return ChatColor.YELLOW + getQueryText(context);
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input == null) {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
try {
final int i = Integer.parseInt(input);
if (i > 0) {
context.setSessionData(CK.REQ_EXP, i);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("inputPosNum"));
return new RequirementsExperiencePrompt(context);
}
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", input));
return new RequirementsExperiencePrompt(context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REQ_EXP, null);
return new RequirementsPrompt(context);
}
return new RequirementsPrompt(context);
}
}
public class RequirementsPermissionsPrompt extends QuestsEditorStringPrompt {
public RequirementsPermissionsPrompt(final ConversationContext context) {

View File

@ -567,60 +567,6 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
}
}
public class RewardsExperiencePrompt extends QuestsEditorStringPrompt {
public RewardsExperiencePrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("rewExperiencePrompt");
}
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
if (context.getPlugin() != null) {
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
}
return ChatColor.YELLOW + getQueryText(context);
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input == null) {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
try {
final int i = Integer.parseInt(input);
if (i > 0) {
context.setSessionData(CK.REW_EXP, i);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("inputPosNum"));
return new RewardsExperiencePrompt(context);
}
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", input));
return new RewardsExperiencePrompt(context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_EXP, null);
return new RewardsPrompt(context);
}
return new RewardsPrompt(context);
}
}
public class RewardsQuestPointsPrompt extends QuestsEditorStringPrompt {
public RewardsQuestPointsPrompt(final ConversationContext context) {
@ -797,6 +743,60 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
}
}
}
public class RewardsExperiencePrompt extends QuestsEditorStringPrompt {
public RewardsExperiencePrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("rewExperiencePrompt");
}
@Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
if (context.getPlugin() != null) {
final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
}
return ChatColor.YELLOW + getQueryText(context);
}
@Override
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
if (input == null) {
return null;
}
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
try {
final int i = Integer.parseInt(input);
if (i > 0) {
context.setSessionData(CK.REW_EXP, i);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("inputPosNum"));
return new RewardsExperiencePrompt(context);
}
} catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", input));
return new RewardsExperiencePrompt(context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_EXP, null);
return new RewardsPrompt(context);
}
return new RewardsPrompt(context);
}
}
public class RewardsCommandsPrompt extends QuestsEditorStringPrompt {

View File

@ -171,6 +171,9 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
if (requirements.getQuestPoints() != 0) {
context.setSessionData(CK.REQ_QUEST_POINTS, requirements.getQuestPoints());
}
if (requirements.getExp() != 0) {
context.setSessionData(CK.REW_EXP, requirements.getExp());
}
if (!requirements.getItems().isEmpty()) {
context.setSessionData(CK.REQ_ITEMS, requirements.getItems());
context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems());
@ -612,6 +615,8 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi
? context.getSessionData(CK.REQ_MONEY) : null);
requirements.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null
? context.getSessionData(CK.REQ_QUEST_POINTS) : null);
requirements.set("exp", context.getSessionData(CK.REQ_EXP) != null
? context.getSessionData(CK.REQ_EXP) : null);
requirements.set("items", context.getSessionData(CK.REQ_ITEMS) != null
? context.getSessionData(CK.REQ_ITEMS) : null);
requirements.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null

View File

@ -22,6 +22,7 @@ import java.util.Map;
public class BukkitRequirements implements Requirements {
private int money = 0;
private int questPoints = 0;
private int exp = 0;
private List<ItemStack> items = new LinkedList<>();
private List<Boolean> removeItems = new LinkedList<>();
private List<IQuest> neededQuests = new LinkedList<>();
@ -46,6 +47,12 @@ public class BukkitRequirements implements Requirements {
public void setQuestPoints(final int questPoints) {
this.questPoints = questPoints;
}
public int getExp() {
return exp;
}
public void setExp(final int exp) {
this.exp = exp;
}
public List<ItemStack> getItems() {
return items;
}
@ -117,6 +124,7 @@ public class BukkitRequirements implements Requirements {
public boolean hasRequirement() {
if (money != 0) { return true; }
if (questPoints != 0) { return true; }
if (exp != 0) { return true; }
if (!items.isEmpty()) { return true; }
if (!removeItems.isEmpty()) { return true; }
if (!neededQuests.isEmpty()) { return true; }

View File

@ -34,6 +34,7 @@ public class CK {
public static final String REQ_QUEST_POINTS = "questPointsReq";
public static final String REQ_ITEMS = "itemReqs";
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
public static final String REQ_EXP = "expReq";
public static final String REQ_PERMISSION = "permissionReqs";
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";

View File

@ -429,6 +429,7 @@ conditionEditorEnterPlaceholderVal: "Enter placeholder values, <space>, <cancel>
reqSetMoney: "Set money requirement"
reqSetQuestPoints: "Set <points> requirement"
reqSetItem: "Set item requirements"
reqSetExperience: "Set experience requirement"
reqSetPerms: "Set permission requirements"
reqSetQuest: "Set quest requirements"
reqSetQuestBlocks: "Set quest blocks"
@ -442,6 +443,7 @@ reqHeroesSetSecondary: "Set Secondary Class"
reqQuestListTitle: "- Quests Available -"
reqQuestPrompt: "Enter a list of quest names, <semicolon>, <clear>, <cancel>"
reqRemoveItemsPrompt: "Enter a list of true/false values, <space>, <cancel>"
reqExperiencePrompt: "Enter amount of experience, <clear>, <cancel>"
reqPermissionsPrompt: "Enter permission requirements, <space>, <clear>, <cancel>"
reqCustomPrompt: "Enter the name of a custom requirement to add, <clear>, <cancel>"
reqMcMMOAmountsPrompt: "Enter mcMMO Classic skill amounts, <space>, <clear>, <cancel>"
@ -513,11 +515,11 @@ rewSetCustom: "Set custom rewards"
rewSetHeroesClasses: "Set classes"
rewSetHeroesAmounts: "Set experience amounts"
rewMoneyPrompt: "Enter amount of <money>, <clear>, <cancel>"
rewQuestPointsPrompt: "Enter amount of <points>, <clear>, <cancel>"
rewExperiencePrompt: "Enter amount of experience, <clear>, <cancel>"
rewCommandPrompt: "Enter command rewards (use '<player>' to represent the player), <semicolon>, <clear>, <cancel>"
rewPermissionsPrompt: "Enter permission rewards, <space>, <clear>, <cancel>"
rewPermissionsWorldPrompt: "Enter permission worlds, <semicolon>, <clear>, <cancel>"
rewQuestPointsPrompt: "Enter amount of <points>, <clear>, <cancel>"
rewMcMMOPrompt: "Enter mcMMO Classic skills (or enter 'All' for all skills), <space>, <cancel>"
rewHeroesClassesPrompt: "Enter Heroes classes, <space>, <cancel>"
rewHeroesExperiencePrompt: "Enter experience amounts (numbers, decimals are allowed), <space>, <cancel>"