Supply external conversation hooks, part 36

This commit is contained in:
PikaMug 2020-10-24 02:13:15 -04:00
parent b0848ab2d4
commit 59262678e5
4 changed files with 149 additions and 60 deletions

View File

@ -18,7 +18,6 @@ import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import me.blackvein.quests.Quest; import me.blackvein.quests.Quest;
@ -118,11 +117,11 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
if (player.hasPermission("quests.editor.actions.edit") if (player.hasPermission("quests.editor.actions.edit")
|| player.hasPermission("quests.editor.events.edit")) { || player.hasPermission("quests.editor.events.edit")) {
if (plugin.getActions().isEmpty()) { if (plugin.getActions().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("eventEditorNoneToEdit")); + Lang.get("eventEditorNoneToEdit"));
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
} else { } else {
return new ActionSelectEditPrompt(); return new ActionSelectEditPrompt(context);
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
@ -132,18 +131,18 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
if (player.hasPermission("quests.editor.actions.delete") if (player.hasPermission("quests.editor.actions.delete")
|| player.hasPermission("quests.editor.events.delete")) { || player.hasPermission("quests.editor.events.delete")) {
if (plugin.getActions().isEmpty()) { if (plugin.getActions().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("eventEditorNoneToDelete")); + Lang.get("eventEditorNoneToDelete"));
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
} else { } else {
return new ActionSelectDeletePrompt(); return new ActionSelectDeletePrompt(context);
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
} }
case 4: case 4:
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited")); context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("exited"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
default: default:
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
@ -157,7 +156,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
@Override @Override
public String getTitle(final ConversationContext context) { public String getTitle(final ConversationContext context) {
return Lang.get("eventEditorCreate"); return Lang.get("eventCreateTitle");
} }
@Override @Override
@ -211,16 +210,30 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} }
} }
private class ActionSelectEditPrompt extends StringPrompt { public class ActionSelectEditPrompt extends ActionsEditorStringPrompt {
public ActionSelectEditPrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return Lang.get("eventEditTitle");
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("eventEditorEnterEventName");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEdit") + " -\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Action a : plugin.getActions()) { for (final Action a : plugin.getActions()) {
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", "; text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", ";
} }
text = text.substring(0, text.length() - 2) + "\n"; text = text.substring(0, text.length() - 2) + "\n";
text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); text += ChatColor.YELLOW + getQueryText(context);
return text; return text;
} }
@ -234,24 +247,38 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
plugin.getActionFactory().loadData(a, context); plugin.getActionFactory().loadData(a, context);
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNotFound"));
return new ActionSelectEditPrompt(); return new ActionSelectEditPrompt(context);
} else { } else {
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
} }
} }
} }
private class ActionSelectDeletePrompt extends StringPrompt { public class ActionSelectDeletePrompt extends ActionsEditorStringPrompt {
public ActionSelectDeletePrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return Lang.get("eventDeleteTitle");
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("eventEditorEnterEventName");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorDelete") + " -\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Action a : plugin.getActions()) { for (final Action a : plugin.getActions()) {
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ","; text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ",";
} }
text = text.substring(0, text.length() - 1) + "\n"; text = text.substring(0, text.length() - 1) + "\n";
text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); text += ChatColor.YELLOW + getQueryText(context);
return text; return text;
} }
@ -272,27 +299,41 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} }
if (used.isEmpty()) { if (used.isEmpty()) {
context.setSessionData(CK.ED_EVENT_DELETE, a.getName()); context.setSessionData(CK.ED_EVENT_DELETE, a.getName());
return new ActionConfirmDeletePrompt(); return new ActionConfirmDeletePrompt(context);
} else { } else {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorEventInUse") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorEventInUse")
+ " \"" + ChatColor.DARK_PURPLE + a.getName() + ChatColor.RED + "\":"); + " \"" + ChatColor.DARK_PURPLE + a.getName() + ChatColor.RED + "\":");
for (final String s : used) { for (final String s : used) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s); context.getForWhom().sendRawMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s);
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("eventEditorMustModifyQuests")); + Lang.get("eventEditorMustModifyQuests"));
return new ActionSelectDeletePrompt(); return new ActionSelectDeletePrompt(context);
} }
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNotFound"));
return new ActionSelectDeletePrompt(); return new ActionSelectDeletePrompt(context);
} else { } else {
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
} }
} }
} }
private class ActionConfirmDeletePrompt extends StringPrompt { public class ActionConfirmDeletePrompt extends ActionsEditorStringPrompt {
public ActionConfirmDeletePrompt(final ConversationContext context) {
super (context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("confirmDelete");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
@ -300,7 +341,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
+ Lang.get("yesWord") + "\n"; + Lang.get("yesWord") + "\n";
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - "
+ Lang.get("noWord"); + Lang.get("noWord");
return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW return ChatColor.RED + getQueryText(context) + " (" + ChatColor.YELLOW
+ (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text; + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text;
} }
@ -312,7 +353,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) { } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new ActionMenuPrompt(context); return new ActionMenuPrompt(context);
} else { } else {
return new ActionConfirmDeletePrompt(); return new ActionConfirmDeletePrompt(context);
} }
} }
} }

View File

@ -18,7 +18,6 @@ import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import me.blackvein.quests.Quest; import me.blackvein.quests.Quest;
@ -116,11 +115,11 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
case 2: case 2:
if (player.hasPermission("quests.conditions.edit")) { if (player.hasPermission("quests.conditions.edit")) {
if (plugin.getConditions().isEmpty()) { if (plugin.getConditions().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("conditionEditorNoneToEdit")); + Lang.get("conditionEditorNoneToEdit"));
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
} else { } else {
return new ConditionSelectEditPrompt(); return new ConditionSelectEditPrompt(context);
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
@ -129,18 +128,18 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
case 3: case 3:
if (player.hasPermission("quests.conditions.delete")) { if (player.hasPermission("quests.conditions.delete")) {
if (plugin.getConditions().isEmpty()) { if (plugin.getConditions().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("conditionEditorNoneToDelete")); + Lang.get("conditionEditorNoneToDelete"));
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
} else { } else {
return new ConditionSelectDeletePrompt(); return new ConditionSelectDeletePrompt(context);
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
} }
case 4: case 4:
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited")); context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("exited"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
default: default:
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
@ -148,13 +147,14 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
} }
public class ConditionSelectCreatePrompt extends ConditionsEditorStringPrompt { public class ConditionSelectCreatePrompt extends ConditionsEditorStringPrompt {
public ConditionSelectCreatePrompt(final ConversationContext context) { public ConditionSelectCreatePrompt(final ConversationContext context) {
super(context); super(context);
} }
@Override @Override
public String getTitle(final ConversationContext context) { public String getTitle(final ConversationContext context) {
return Lang.get("conditionEditorCreate"); return Lang.get("conditionCreateTitle");
} }
@Override @Override
@ -208,16 +208,30 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
} }
} }
private class ConditionSelectEditPrompt extends StringPrompt { public class ConditionSelectEditPrompt extends ConditionsEditorStringPrompt {
public ConditionSelectEditPrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return Lang.get("conditionEditTitle");
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("conditionEditorEnterName");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("conditionEditorEdit") + " -\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Condition a : plugin.getConditions()) { for (final Condition a : plugin.getConditions()) {
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", "; text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", ";
} }
text = text.substring(0, text.length() - 2) + "\n"; text = text.substring(0, text.length() - 2) + "\n";
text += ChatColor.YELLOW + Lang.get("conditionEditorEnterName"); text += ChatColor.YELLOW + getQueryText(context);
return text; return text;
} }
@ -231,24 +245,38 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
plugin.getConditionFactory().loadData(c, context); plugin.getConditionFactory().loadData(c, context);
return new ConditionMainPrompt(context); return new ConditionMainPrompt(context);
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("conditionEditorNotFound")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorNotFound"));
return new ConditionSelectEditPrompt(); return new ConditionSelectEditPrompt(context);
} else { } else {
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
} }
} }
} }
private class ConditionSelectDeletePrompt extends StringPrompt { public class ConditionSelectDeletePrompt extends ConditionsEditorStringPrompt {
public ConditionSelectDeletePrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return Lang.get("conditionDeleteTitle");
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("conditionEditorEnterQuestName");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("conditionEditorDelete") + " -\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Condition c : plugin.getConditions()) { for (final Condition c : plugin.getConditions()) {
text += ChatColor.AQUA + c.getName() + ChatColor.GRAY + ","; text += ChatColor.AQUA + c.getName() + ChatColor.GRAY + ",";
} }
text = text.substring(0, text.length() - 1) + "\n"; text = text.substring(0, text.length() - 1) + "\n";
text += ChatColor.YELLOW + Lang.get("conditionEditorEnterName"); text += ChatColor.YELLOW + getQueryText(context);
return text; return text;
} }
@ -269,27 +297,41 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
} }
if (used.isEmpty()) { if (used.isEmpty()) {
context.setSessionData(CK.ED_CONDITION_DELETE, c.getName()); context.setSessionData(CK.ED_CONDITION_DELETE, c.getName());
return new ConditionConfirmDeletePrompt(); return new ConditionConfirmDeletePrompt(context);
} else { } else {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("conditionEditorInUse") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorInUse")
+ " \"" + ChatColor.DARK_PURPLE + c.getName() + ChatColor.RED + "\":"); + " \"" + ChatColor.DARK_PURPLE + c.getName() + ChatColor.RED + "\":");
for (final String s : used) { for (final String s : used) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s); context.getForWhom().sendRawMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s);
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("eventEditorMustModifyQuests")); + Lang.get("eventEditorMustModifyQuests"));
return new ConditionSelectDeletePrompt(); return new ConditionSelectDeletePrompt(context);
} }
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("conditionEditorNotFound")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorNotFound"));
return new ConditionSelectDeletePrompt(); return new ConditionSelectDeletePrompt(context);
} else { } else {
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
} }
} }
} }
private class ConditionConfirmDeletePrompt extends StringPrompt { public class ConditionConfirmDeletePrompt extends ConditionsEditorStringPrompt {
public ConditionConfirmDeletePrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("confirmDelete");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
@ -309,7 +351,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) { } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new ConditionMenuPrompt(context); return new ConditionMenuPrompt(context);
} else { } else {
return new ConditionConfirmDeletePrompt(); return new ConditionConfirmDeletePrompt(context);
} }
} }
} }

View File

@ -203,7 +203,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public String getTitle(final ConversationContext context) { public String getTitle(final ConversationContext context) {
return Lang.get("questEditTitle"); return Lang.get("questEditorEdit");
} }
@Override @Override
@ -213,11 +213,11 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
String s = ChatColor.GOLD + getTitle(context) + "\n"; String text = ChatColor.GOLD + getTitle(context) + "\n";
for (final Quest q : plugin.getQuests()) { for (final Quest q : plugin.getQuests()) {
s += ChatColor.GRAY + "- " + ChatColor.AQUA + q.getName() + "\n"; text += ChatColor.GRAY + "- " + ChatColor.AQUA + q.getName() + "\n";
} }
return s + ChatColor.YELLOW + getQueryText(context); return text + ChatColor.YELLOW + getQueryText(context);
} }
@Override @Override
@ -278,19 +278,19 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(CK.ED_QUEST_DELETE, found.getName()); context.setSessionData(CK.ED_QUEST_DELETE, found.getName());
return new QuestConfirmDeletePrompt(context); return new QuestConfirmDeletePrompt(context);
} else { } else {
((Player) context.getForWhom()).sendMessage(ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("questEditorQuestAsRequirement1") + " \"" + ChatColor.DARK_PURPLE + Lang.get("questEditorQuestAsRequirement1") + " \"" + ChatColor.DARK_PURPLE
+ context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + "\" " + context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + "\" "
+ Lang.get("questEditorQuestAsRequirement2")); + Lang.get("questEditorQuestAsRequirement2"));
for (final String s : used) { for (final String s : used) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s); context.getForWhom().sendRawMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s);
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("questEditorQuestAsRequirement3")); + Lang.get("questEditorQuestAsRequirement3"));
return new QuestSelectDeletePrompt(context); return new QuestSelectDeletePrompt(context);
} }
} }
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questEditorQuestNotFound")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorQuestNotFound"));
return new QuestSelectDeletePrompt(context); return new QuestSelectDeletePrompt(context);
} else { } else {
return new QuestMenuPrompt(context); return new QuestMenuPrompt(context);

View File

@ -586,6 +586,12 @@ conditionEditorTitle: "- Condition Editor -"
questCreateTitle: "- Create Quest -" questCreateTitle: "- Create Quest -"
questEditTitle: "- Edit Quest -" questEditTitle: "- Edit Quest -"
questDeleteTitle: "- Delete Quest -" questDeleteTitle: "- Delete Quest -"
eventCreateTitle: "- Create Action -"
eventEditTitle: "- Edit Action -"
eventDeleteTitle: "- Delete Action -"
conditionCreateTitle: "- Create Condition -"
conditionEditTitle: "- Edit Condition -"
conditionDeleteTitle: "- Delete Condition -"
requirementsTitle: "- <quest> | Requirements -" requirementsTitle: "- <quest> | Requirements -"
rewardsTitle: "- <quest> | Rewards -" rewardsTitle: "- <quest> | Rewards -"
plannerTitle: "- <quest> | Planner -" plannerTitle: "- <quest> | Planner -"