mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-28 21:56:28 +01:00
New command reward display override, fixes #738
This commit is contained in:
parent
7187e06f25
commit
d6d781e61d
@ -619,8 +619,14 @@ public class Quest {
|
||||
none = null;
|
||||
}
|
||||
if (rews.getCommands().isEmpty() == false) {
|
||||
int index = 0;
|
||||
for (String s : rews.getCommands()) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommands().get(rews.getCommands().indexOf(s)));
|
||||
if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() >= index) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommandsOverrideDisplay().get(index));
|
||||
} else {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + s);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
|
@ -799,6 +799,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
List<Integer> RPGItemAmounts = null;
|
||||
Integer expRew = null;
|
||||
List<String> commandRews = null;
|
||||
List<String> commandDisplayOverrideRews = null;
|
||||
List<String> permRews = null;
|
||||
List<String> mcMMOSkillRews = null;
|
||||
List<Integer> mcMMOSkillAmounts = null;
|
||||
@ -894,6 +895,10 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
commandRews = new LinkedList<String>();
|
||||
commandRews.addAll((List<String>)cc.getSessionData(CK.REW_COMMAND));
|
||||
}
|
||||
if (cc.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null) {
|
||||
commandDisplayOverrideRews = new LinkedList<String>();
|
||||
commandDisplayOverrideRews.addAll((List<String>)cc.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY));
|
||||
}
|
||||
if (cc.getSessionData(CK.REW_PERMISSION) != null) {
|
||||
permRews = new LinkedList<String>();
|
||||
permRews.addAll((List<String>) cc.getSessionData(CK.REW_PERMISSION));
|
||||
@ -1363,7 +1368,11 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
stage.set("start-message", startMessage == null ? startMessage : startMessage.replace("\\n", "\n"));
|
||||
stage.set("complete-message", completeMessage == null ? completeMessage : completeMessage.replace("\\n", "\n"));
|
||||
}
|
||||
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 || phatLootRews != null && phatLootRews.isEmpty() == false || customRews != null && customRews.isEmpty() == false) {
|
||||
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false
|
||||
|| permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false
|
||||
|| commandDisplayOverrideRews != null && commandDisplayOverrideRews.isEmpty() == false || mcMMOSkillRews != null
|
||||
|| RPGItemRews != null || heroesClassRews != null && heroesClassRews.isEmpty() == false
|
||||
|| phatLootRews != null && phatLootRews.isEmpty() == false || customRews != null && customRews.isEmpty() == false) {
|
||||
ConfigurationSection rews = cs.createSection("rewards");
|
||||
rews.set("items", (itemRews != null && itemRews.isEmpty() == false) ? itemRews : null);
|
||||
rews.set("money", moneyRew);
|
||||
@ -1371,6 +1380,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
rews.set("exp", expRew);
|
||||
rews.set("permissions", permRews);
|
||||
rews.set("commands", commandRews);
|
||||
rews.set("commands-override-display", commandDisplayOverrideRews);
|
||||
rews.set("mcmmo-skills", mcMMOSkillRews);
|
||||
rews.set("mcmmo-levels", mcMMOSkillAmounts);
|
||||
rews.set("rpgitem-names", RPGItemRews);
|
||||
@ -1492,6 +1502,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
if (rews.getCommands().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_COMMAND, rews.getCommands());
|
||||
}
|
||||
if (rews.getCommandsOverrideDisplay().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, rews.getCommandsOverrideDisplay());
|
||||
}
|
||||
if (rews.getPermissions().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_PERMISSION, rews.getPermissions());
|
||||
}
|
||||
|
@ -1565,12 +1565,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".rewards.commands")) {
|
||||
if (Quests.checkList(config.getList("quests." + questKey + ".rewards.commands"), String.class)) {
|
||||
|
||||
rews.setCommands(config.getStringList("quests." + questKey + ".rewards.commands"));
|
||||
} else {
|
||||
skipQuestProcess("commands: Reward in Quest " + quest.getName() + " is not a list of commands!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".rewards.commands-override-display")) {
|
||||
if (Quests.checkList(config.getList("quests." + questKey + ".rewards.commands-override-display"), String.class)) {
|
||||
rews.setCommandsOverrideDisplay(config.getStringList("quests." + questKey + ".rewards.commands-override-display"));
|
||||
} else {
|
||||
skipQuestProcess("commands-override-display: Reward in Quest " + quest.getName() + " is not a list of strings!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".rewards.permissions")) {
|
||||
if (Quests.checkList(config.getList("quests." + questKey + ".rewards.permissions"), String.class)) {
|
||||
rews.setPermissions(config.getStringList("quests." + questKey + ".rewards.permissions"));
|
||||
|
@ -24,6 +24,7 @@ public class Rewards {
|
||||
private int questPoints = 0;
|
||||
private int exp = 0;
|
||||
private List<String> commands = new LinkedList<String>();
|
||||
private List<String> commandsOverrideDisplay = new LinkedList<String>();
|
||||
private List<String> permissions = new LinkedList<String>();
|
||||
private List<ItemStack> items = new LinkedList<ItemStack>();
|
||||
private List<String> mcmmoSkills = new LinkedList<String>();
|
||||
@ -57,6 +58,12 @@ public class Rewards {
|
||||
public void setCommands(List<String> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
public List<String> getCommandsOverrideDisplay() {
|
||||
return commandsOverrideDisplay;
|
||||
}
|
||||
public void setCommandsOverrideDisplay(List<String> commandsOverrideDisplay) {
|
||||
this.commandsOverrideDisplay = commandsOverrideDisplay;
|
||||
}
|
||||
public List<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
@ -133,7 +133,10 @@ public class RequirementsPrompt extends FixedSetPrompt {
|
||||
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\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 && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) {
|
||||
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 && context.getSessionData(CK.REQ_CUSTOM) == null) {
|
||||
text += ChatColor.GRAY + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.GRAY + Lang.get("reqSetFail") + " (" + Lang.get("reqNone") + ")\n";
|
||||
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
|
||||
text += ChatColor.RED + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.RED + Lang.get("reqSetFail") + " (" + Lang.get("questRequiredNoneSet") + ")\n";
|
||||
|
@ -78,8 +78,11 @@ public class RewardsPrompt extends FixedSetPrompt {
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + "\n";
|
||||
List<String> commands = (List<String>) context.getSessionData(CK.REW_COMMAND);
|
||||
List<String> overrides = (List<String>) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY);
|
||||
int index = 0;
|
||||
for (String cmd : commands) {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + "\n";
|
||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + (overrides != null ? ChatColor.GRAY + " (\"" + ChatColor.AQUA + overrides.get(index) + ChatColor.GRAY + "\")" : "") + "\n";
|
||||
index++;
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(CK.REW_PERMISSION) == null) {
|
||||
@ -156,7 +159,7 @@ public class RewardsPrompt extends FixedSetPrompt {
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
return new ExperiencePrompt();
|
||||
} else if (input.equalsIgnoreCase("5")) {
|
||||
return new CommandsPrompt();
|
||||
return new CommandsListPrompt();
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
return new PermissionsPrompt();
|
||||
} else if (input.equalsIgnoreCase("7")) {
|
||||
@ -340,6 +343,72 @@ public class RewardsPrompt extends FixedSetPrompt {
|
||||
}
|
||||
}
|
||||
|
||||
private class CommandsListPrompt extends FixedSetPrompt {
|
||||
|
||||
public CommandsListPrompt() {
|
||||
super("1", "2", "3", "4");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = ChatColor.GOLD + "- " + Lang.get("rewCommands") + " -\n";
|
||||
if (context.getSessionData(CK.REW_COMMAND) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetCommandsOverrides") + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + "\n";
|
||||
for (String s : getCommand(context)) {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
||||
}
|
||||
if (context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommandsOverrides") + " (" + Lang.get("stageEditorOptional") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommandsOverrides") + "\n";
|
||||
for (String s : getCommandOverrideDisplay(context)) {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
||||
}
|
||||
}
|
||||
text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new CommandsPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
if (context.getSessionData(CK.REW_COMMAND) == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("rewNoCommands"));
|
||||
return new CommandsListPrompt();
|
||||
} else {
|
||||
return new CommandsOverrideDisplayPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewCommandsCleared"));
|
||||
context.setSessionData(CK.REW_COMMAND, null);
|
||||
context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, null);
|
||||
return new CommandsListPrompt();
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
return new RewardsPrompt(plugin, factory);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<String> getCommand(ConversationContext context) {
|
||||
return (List<String>) context.getSessionData(CK.REW_COMMAND);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<String> getCommandOverrideDisplay(ConversationContext context) {
|
||||
return (List<String>) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
private class CommandsPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
@ -365,7 +434,35 @@ public class RewardsPrompt extends FixedSetPrompt {
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(CK.REW_COMMAND, null);
|
||||
}
|
||||
return new RewardsPrompt(plugin, factory);
|
||||
return new CommandsListPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
private class CommandsOverrideDisplayPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = ChatColor.YELLOW + Lang.get("rewCommandsOverridePrompt") + "\n";
|
||||
text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("rewCommandsOverrideHint");
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
String[] args = input.split(Lang.get("charSemi"));
|
||||
List<String> overrides = new LinkedList<String>();
|
||||
for (String s : args) {
|
||||
if (s.startsWith("/")) {
|
||||
s = s.substring(1);
|
||||
}
|
||||
overrides.add(s);
|
||||
}
|
||||
context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, overrides);
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, null);
|
||||
}
|
||||
return new CommandsListPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ public class CK {
|
||||
public static final String REW_ITEMS = "itemRews";
|
||||
public static final String REW_EXP = "expRew";
|
||||
public static final String REW_COMMAND = "commandRews";
|
||||
public static final String REW_COMMAND_OVERRIDE_DISPLAY = "commandOverrideDisplay";
|
||||
public static final String REW_PERMISSION = "permissionRews";
|
||||
public static final String REW_MCMMO_SKILLS = "mcMMOSkillRews";
|
||||
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
|
||||
|
@ -495,6 +495,12 @@ rewSetQuestPoints: "Set Quest Points reward"
|
||||
rewSetItems: "Set item rewards"
|
||||
rewSetExperience: "Set experience reward"
|
||||
rewSetCommands: "Set command rewards"
|
||||
rewCommands: "Command rewards"
|
||||
rewSetCommandsOverrides: "Set command display overrides"
|
||||
rewCommandsCleared: "Command rewards cleared."
|
||||
rewCommandsOverridePrompt: "Enter command display override, <clear>, <cancel>"
|
||||
rewCommandsOverrideHint: "(This override will display your own text as the reward)"
|
||||
rewNoCommands: "You must set commands first!"
|
||||
rewSetPermission: "Set permission rewards"
|
||||
rewSetMcMMO: "Set mcMMO skill rewards"
|
||||
rewSetHeroes: "Set Heroes experience rewards"
|
||||
|
Loading…
Reference in New Issue
Block a user