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.Q_ID, q.getId());
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) {
context.setSessionData(CK.Q_START_NPC, q.getNpcStart().getId());
}
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) {
context.setSessionData(CK.Q_INITIAL_EVENT, q.getInitialAction().getName());
}

View File

@ -335,7 +335,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return eventFactory;
}
@Deprecated
/**
* @deprecated Use {@link #getActionFactory()}
*/
public ActionFactory getEventFactory() {
return eventFactory;
}
@ -1358,7 +1360,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questKey + ".name")) {
quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest));
} 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 (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);
}
}
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")) {
Action act = loadAction(config.getString("quests." + questKey + ".action"));
if (act != null) {

View File

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

View File

@ -177,6 +177,8 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
return new QuestSelectCreatePrompt(context);
}
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);
plugin.getQuestFactory().setNamesOfQuestsBeingEdited(questNames);
return new QuestMainPrompt(context);

View File

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