Supply default ask- and finish-message upon quest creation, fixes #1237

This commit is contained in:
PikaMug 2020-06-21 04:27:52 -04:00
parent 869dfc16c0
commit ea0ab7dba3
5 changed files with 38 additions and 48 deletions

View File

@ -149,12 +149,12 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.ED_QUEST_EDIT, q.getName()); context.setSessionData(CK.ED_QUEST_EDIT, q.getName());
context.setSessionData(CK.Q_ID, q.getId()); context.setSessionData(CK.Q_ID, q.getId());
context.setSessionData(CK.Q_NAME, q.getName()); context.setSessionData(CK.Q_NAME, q.getName());
context.setSessionData(CK.Q_ASK_MESSAGE, q.getDescription());
context.setSessionData(CK.Q_FINISH_MESSAGE, q.getFinished());
if (q.getNpcStart() != null) { if (q.getNpcStart() != null) {
context.setSessionData(CK.Q_START_NPC, q.getNpcStart().getId()); context.setSessionData(CK.Q_START_NPC, q.getNpcStart().getId());
} }
context.setSessionData(CK.Q_START_BLOCK, q.getBlockStart()); context.setSessionData(CK.Q_START_BLOCK, q.getBlockStart());
context.setSessionData(CK.Q_ASK_MESSAGE, q.getDescription());
context.setSessionData(CK.Q_FINISH_MESSAGE, q.getFinished());
if (q.getInitialAction() != null) { if (q.getInitialAction() != null) {
context.setSessionData(CK.Q_INITIAL_EVENT, q.getInitialAction().getName()); context.setSessionData(CK.Q_INITIAL_EVENT, q.getInitialAction().getName());
} }

View File

@ -335,7 +335,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return eventFactory; return eventFactory;
} }
@Deprecated /**
* @deprecated Use {@link #getActionFactory()}
*/
public ActionFactory getEventFactory() { public ActionFactory getEventFactory() {
return eventFactory; return eventFactory;
} }
@ -1358,7 +1360,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questKey + ".name")) { if (config.contains("quests." + questKey + ".name")) {
quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest)); quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest));
} else { } else {
throw new QuestFormatException("Quest block is missing", questKey); throw new QuestFormatException("name is missing", questKey);
}
if (config.contains("quests." + questKey + ".ask-message")) {
quest.description = ConfigUtil.parseString(config.getString("quests." + questKey
+ ".ask-message"), quest);
} else {
throw new QuestFormatException("ask-message is missing", questKey);
}
if (config.contains("quests." + questKey + ".finish-message")) {
quest.finished = ConfigUtil.parseString(config.getString("quests." + questKey
+ ".finish-message"), quest);
} else {
throw new QuestFormatException("finish-message is missing", questKey);
} }
if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) { if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) {
if (CitizensAPI.getNPCRegistry().getById(config.getInt("quests." + questKey + ".npc-giver-id")) if (CitizensAPI.getNPCRegistry().getById(config.getInt("quests." + questKey + ".npc-giver-id"))
@ -1422,18 +1436,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
throw new QuestFormatException("redo-delay is not a number", questKey); throw new QuestFormatException("redo-delay is not a number", questKey);
} }
} }
if (config.contains("quests." + questKey + ".finish-message")) {
quest.finished = ConfigUtil.parseString(config.getString("quests." + questKey
+ ".finish-message"), quest);
} else {
throw new QuestFormatException("finish-message is missing", questKey);
}
if (config.contains("quests." + questKey + ".ask-message")) {
quest.description = ConfigUtil.parseString(config.getString("quests." + questKey
+ ".ask-message"), quest);
} else {
throw new QuestFormatException("ask-message is missing", questKey);
}
if (config.contains("quests." + questKey + ".action")) { if (config.contains("quests." + questKey + ".action")) {
Action act = loadAction(config.getString("quests." + questKey + ".action")); Action act = loadAction(config.getString("quests." + questKey + ".action"));
if (act != null) { if (act != null) {

View File

@ -117,17 +117,9 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
case 1: case 1:
return ChatColor.YELLOW + Lang.get("questEditorName"); return ChatColor.YELLOW + Lang.get("questEditorName");
case 2: case 2:
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) { return ChatColor.YELLOW + Lang.get("questEditorAskMessage");
return ChatColor.RED + Lang.get("questEditorAskMessage");
} else {
return ChatColor.YELLOW + Lang.get("questEditorAskMessage");
}
case 3: case 3:
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) { return ChatColor.YELLOW + Lang.get("questEditorFinishMessage");
return ChatColor.RED + Lang.get("questEditorFinishMessage");
} else {
return ChatColor.YELLOW + Lang.get("questEditorFinishMessage");
}
case 4: case 4:
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) { if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) {
return ChatColor.YELLOW + Lang.get("questEditorNPCStart"); return ChatColor.YELLOW + Lang.get("questEditorNPCStart");
@ -184,26 +176,18 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
case 1: case 1:
return ""; return "";
case 2: case 2:
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) { return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")"; + ChatColor.GRAY + ")";
} else {
return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET
+ ChatColor.YELLOW + ")";
}
case 3: case 3:
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) { return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.Q_FINISH_MESSAGE)
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")"; + ChatColor.RESET + ChatColor.GRAY + ")";
} else {
return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_FINISH_MESSAGE) + ChatColor.RESET
+ ChatColor.YELLOW + ")";
}
case 4: case 4:
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens()
!= null) { != null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else if (plugin.getDependencies().getCitizens() != null) { } else if (plugin.getDependencies().getCitizens() != null) {
return ChatColor.YELLOW + "(" + CitizensAPI.getNPCRegistry().getById((Integer) context return ChatColor.GRAY + "(" + ChatColor.AQUA + CitizensAPI.getNPCRegistry().getById((Integer) context
.getSessionData(CK.Q_START_NPC)).getName() + ChatColor.RESET + ChatColor.YELLOW + ")"; .getSessionData(CK.Q_START_NPC)).getName() + ChatColor.RESET + ChatColor.GRAY + ")";
} else { } else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
} }
@ -212,16 +196,16 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
Location l = (Location) context.getSessionData(CK.Q_START_BLOCK); Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
return ChatColor.YELLOW + "(" + l.getWorld().getName() + ", " + l.getBlockX() + ", " return ChatColor.GRAY + "(" + ChatColor.AQUA + l.getWorld().getName() + ", " + l.getBlockX() + ", "
+ l.getBlockY() + ", " + l.getBlockZ() + ")"; + l.getBlockY() + ", " + l.getBlockZ() + ChatColor.RESET + ChatColor.GRAY + ")";
} }
case 6: case 6:
if (plugin.getDependencies().getWorldGuardApi() != null) { if (plugin.getDependencies().getWorldGuardApi() != null) {
if (context.getSessionData(CK.Q_REGION) == null) { if (context.getSessionData(CK.Q_REGION) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
return ChatColor.YELLOW + "(" + ChatColor.GREEN return ChatColor.GRAY + "(" + ChatColor.AQUA + (String) context.getSessionData(CK.Q_REGION)
+ (String) context.getSessionData(CK.Q_REGION) + ChatColor.YELLOW + ")"; + ChatColor.RESET + ChatColor.GRAY + ")";
} }
} else { } else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
@ -230,15 +214,16 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) { if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
return ChatColor.YELLOW + "(" + (String) context.getSessionData(CK.Q_INITIAL_EVENT) + ")"; return ChatColor.GRAY + "(" + ChatColor.AQUA + (String) context.getSessionData(CK.Q_INITIAL_EVENT)
+ ChatColor.RESET + ChatColor.GRAY + ")";
} }
case 8: case 8:
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
if (context.getSessionData(CK.Q_GUIDISPLAY) == null) { if (context.getSessionData(CK.Q_GUIDISPLAY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
return ChatColor.YELLOW + "(" + ItemUtil.getDisplayString((ItemStack) context return ChatColor.GRAY + "(" + ChatColor.AQUA + ItemUtil.getDisplayString((ItemStack) context
.getSessionData(CK.Q_GUIDISPLAY)) + ChatColor.RESET + ChatColor.YELLOW + ")"; .getSessionData(CK.Q_GUIDISPLAY)) + ChatColor.RESET + ChatColor.GRAY + ")";
} }
} else { } else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";

View File

@ -177,6 +177,8 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
return new QuestSelectCreatePrompt(context); return new QuestSelectCreatePrompt(context);
} }
context.setSessionData(CK.Q_NAME, input); context.setSessionData(CK.Q_NAME, input);
context.setSessionData(CK.Q_ASK_MESSAGE, Lang.get("questEditorDefaultAskMessage"));
context.setSessionData(CK.Q_FINISH_MESSAGE, Lang.get("questEditorDefaultFinishMessage"));
questNames.add(input); questNames.add(input);
plugin.getQuestFactory().setNamesOfQuestsBeingEdited(questNames); plugin.getQuestFactory().setNamesOfQuestsBeingEdited(questNames);
return new QuestMainPrompt(context); return new QuestMainPrompt(context);

View File

@ -63,13 +63,14 @@ questEditorPln: "Edit Planner"
questEditorStages: "Edit Stages" questEditorStages: "Edit Stages"
questEditorRews: "Edit Rewards" questEditorRews: "Edit Rewards"
questEditorOpts: "Edit Options" questEditorOpts: "Edit Options"
questEditorDefaultAskMessage: "Challenge objectives with haste!"
questEditorDefaultFinishMessage: "You have finished all objectives."
questEditorEnterQuestName: "Enter quest name, <cancel>" questEditorEnterQuestName: "Enter quest name, <cancel>"
questEditorEnterAskMessage: "Enter ask message, <cancel>" questEditorEnterAskMessage: "Enter ask message, <cancel>"
questEditorEnterFinishMessage: "Enter finish message, <cancel>" questEditorEnterFinishMessage: "Enter finish message, <cancel>"
questEditorEnterNPCStart: "Enter NPC ID, <clear>, <cancel>" questEditorEnterNPCStart: "Enter NPC ID, <clear>, <cancel>"
questEditorEnterBlockStart: "Right-click on a block to use as a start point, <done>, <clear>, <cancel>" questEditorEnterBlockStart: "Right-click on a block to use as a start point, <done>, <clear>, <cancel>"
questEditorEnterInitialEvent: "Enter an action name, <clear>, <cancel>" questEditorEnterInitialEvent: "Enter an action name, <clear>, <cancel>"
questRequiredNoneSet: "Required, none set"
questDungeonsCreate: "Players added to this group may perform quests together!" questDungeonsCreate: "Players added to this group may perform quests together!"
questDungeonsDisband: "The quest group was disbanded." questDungeonsDisband: "The quest group was disbanded."
questDungeonsInvite: "<player> can now perform quests with you!" questDungeonsInvite: "<player> can now perform quests with you!"