mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 07:05:51 +01:00
Supply external conversation hooks, part 6. Per #570
This commit is contained in:
parent
50bbee5ec3
commit
d5e050412d
@ -0,0 +1,30 @@
|
||||
package me.blackvein.quests.events.editor.quests;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.blackvein.quests.QuestFactory;
|
||||
|
||||
public class QuestsEditorPostOpenOptionsLevelPromptEvent extends QuestsEditorEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final QuestFactory factory;
|
||||
|
||||
public QuestsEditorPostOpenOptionsLevelPromptEvent(QuestFactory factory, ConversationContext context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
public QuestFactory getQuestFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package me.blackvein.quests.events.editor.quests;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.blackvein.quests.QuestFactory;
|
||||
|
||||
public class QuestsEditorPostOpenOptionsMultiplayerPromptEvent extends QuestsEditorEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final QuestFactory factory;
|
||||
|
||||
public QuestsEditorPostOpenOptionsMultiplayerPromptEvent(QuestFactory factory, ConversationContext context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
public QuestFactory getQuestFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ import me.blackvein.quests.Options;
|
||||
import me.blackvein.quests.QuestFactory;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsGeneralPromptEvent;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsLevelPromptEvent;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsMultiplayerPromptEvent;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsPromptEvent;
|
||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsTrueFalsePromptEvent;
|
||||
import me.blackvein.quests.util.CK;
|
||||
@ -103,14 +105,14 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
|
||||
public class TrueFalsePrompt extends StringPrompt {
|
||||
|
||||
private final int size = 3;
|
||||
private final int size = 4;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getQueryText() {
|
||||
String text = "Choose <true> or <false>";
|
||||
String text = "Select '<true>' or '<false>'";
|
||||
text = text.replace("<true>", Lang.get("true"));
|
||||
text = text.replace("<false>", Lang.get("false"));
|
||||
return text;
|
||||
@ -124,6 +126,8 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
return ChatColor.YELLOW + Lang.get("false");
|
||||
case 3:
|
||||
return ChatColor.RED + Lang.get("cmdClear");
|
||||
case 4:
|
||||
return ChatColor.RED + Lang.get("cmdCancel");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -161,15 +165,66 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
}
|
||||
}
|
||||
|
||||
private class NumberPrompt extends StringPrompt {
|
||||
public class LevelPrompt extends StringPrompt {
|
||||
|
||||
private final int size = 6;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getQueryText() {
|
||||
return "Select level of progress sharing";
|
||||
}
|
||||
|
||||
public String getSelectionText(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.GOLD + "1";
|
||||
case 2:
|
||||
return ChatColor.GOLD + "2";
|
||||
case 3:
|
||||
return ChatColor.GOLD + "3";
|
||||
case 4:
|
||||
return ChatColor.GOLD + "4";
|
||||
case 5:
|
||||
return ChatColor.RED + Lang.get("cmdClear");
|
||||
case 6:
|
||||
return ChatColor.RED + Lang.get("cmdCancel");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getAdditionalText(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.GRAY + Lang.get("everything");
|
||||
case 2:
|
||||
return ChatColor.GRAY + Lang.get("objectives");
|
||||
case 3:
|
||||
return ChatColor.GRAY + Lang.get("stageEditorStages");
|
||||
case 4:
|
||||
return ChatColor.GRAY + Lang.get("quests");
|
||||
case 5:
|
||||
return "";
|
||||
case 6:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
QuestsEditorPostOpenOptionsLevelPromptEvent event = new QuestsEditorPostOpenOptionsLevelPromptEvent(factory, context);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = Lang.get("optNumberPrompt");
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("everything");
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("objectives");;
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("stageEditorStages");
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("quests");
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("everything");
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("objectives");;
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("stageEditorStages");
|
||||
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("quests");
|
||||
return ChatColor.YELLOW + text;
|
||||
}
|
||||
|
||||
@ -282,57 +337,100 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
}
|
||||
}
|
||||
|
||||
private class MultiplayerPrompt extends StringPrompt {
|
||||
public class MultiplayerPrompt extends NumericPrompt {
|
||||
|
||||
private final int size = 4;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return ChatColor.DARK_GREEN + Lang.get("optMultiplayer");
|
||||
}
|
||||
|
||||
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.BLUE;
|
||||
case 2:
|
||||
return ChatColor.BLUE;
|
||||
case 3:
|
||||
return ChatColor.BLUE;
|
||||
case 4:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSelectionText(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) == null) {
|
||||
boolean defaultOpt = new Options().getUseDungeonsXLPlugin();
|
||||
return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin") + " ("
|
||||
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
|
||||
} else {
|
||||
boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
|
||||
return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin") + " ("
|
||||
+ (dungeonsOpt ? ChatColor.GREEN + String.valueOf(dungeonsOpt) : ChatColor.RED + String.valueOf(dungeonsOpt)) + ChatColor.YELLOW + ")";
|
||||
}
|
||||
case 2:
|
||||
if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) == null) {
|
||||
boolean defaultOpt = new Options().getUsePartiesPlugin();
|
||||
return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin") + " ("
|
||||
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
|
||||
} else {
|
||||
boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
|
||||
return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin") + " ("
|
||||
+ (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")";
|
||||
}
|
||||
case 3:
|
||||
if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) {
|
||||
int defaultOpt = new Options().getShareProgressLevel();
|
||||
return ChatColor.YELLOW + Lang.get("optShareProgressLevel") + " ("
|
||||
+ ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")";
|
||||
} else {
|
||||
int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
|
||||
return ChatColor.YELLOW + Lang.get("optShareProgressLevel") + " ("
|
||||
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")";
|
||||
}
|
||||
case 4:
|
||||
return ChatColor.YELLOW + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = ChatColor.DARK_GREEN + "- " + Lang.get("optMultiplayer") + " -\n";
|
||||
if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) == null) {
|
||||
boolean defaultOpt = new Options().getUseDungeonsXLPlugin();
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUseDungeonsXLPlugin") + " ("
|
||||
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
|
||||
} else {
|
||||
boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUseDungeonsXLPlugin") + " ("
|
||||
+ (dungeonsOpt ? ChatColor.GREEN + String.valueOf(dungeonsOpt) : ChatColor.RED + String.valueOf(dungeonsOpt)) + ChatColor.YELLOW + ")\n";
|
||||
QuestsEditorPostOpenOptionsMultiplayerPromptEvent event = new QuestsEditorPostOpenOptionsMultiplayerPromptEvent(factory, context);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.DARK_GREEN + "- " + getTitle() + " -\n";
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
|
||||
}
|
||||
if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) == null) {
|
||||
boolean defaultOpt = new Options().getUsePartiesPlugin();
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " ("
|
||||
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
|
||||
} else {
|
||||
boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " ("
|
||||
+ (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")\n";
|
||||
}
|
||||
if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) {
|
||||
int defaultOpt = new Options().getShareProgressLevel();
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " ("
|
||||
+ ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")\n";
|
||||
} else {
|
||||
int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " ("
|
||||
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")\n";
|
||||
}
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
public Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN;
|
||||
tempPrompt = new MultiplayerPrompt();
|
||||
return new TrueFalsePrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
case 2:
|
||||
tempKey = CK.OPT_USE_PARTIES_PLUGIN;
|
||||
tempPrompt = new MultiplayerPrompt();
|
||||
return new TrueFalsePrompt();
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
case 3:
|
||||
tempKey = CK.OPT_SHARE_PROGRESS_LEVEL;
|
||||
tempPrompt = new MultiplayerPrompt();
|
||||
return new NumberPrompt();
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
return new LevelPrompt();
|
||||
case 4:
|
||||
tempKey = null;
|
||||
tempPrompt = null;
|
||||
try {
|
||||
@ -341,8 +439,9 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user