mirror of
https://github.com/PikaMug/Quests.git
synced 2024-10-22 20:40:06 +02:00
NEW per-quest Options section, part 2. Fixes #624
This commit is contained in:
parent
def44fb8b3
commit
181e60584f
@ -1,22 +1,31 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
public class Options {
|
||||
private boolean useDungeonsXLPlugin = false;
|
||||
private boolean usePartiesPlugin = true;
|
||||
|
||||
public boolean getUseDungeonsXLPlugin() {
|
||||
return useDungeonsXLPlugin;
|
||||
}
|
||||
|
||||
public void setUseDungeonsXLPlugin(boolean useDungeonsXLPlugin) {
|
||||
this.useDungeonsXLPlugin = useDungeonsXLPlugin;
|
||||
}
|
||||
|
||||
public boolean getUsePartiesPlugin() {
|
||||
return usePartiesPlugin;
|
||||
}
|
||||
|
||||
public void setUsePartiesPlugin(boolean usePartiesPlugin) {
|
||||
this.usePartiesPlugin = usePartiesPlugin;
|
||||
}
|
||||
private boolean allowCommands = true;
|
||||
private boolean useDungeonsXLPlugin = false;
|
||||
private boolean usePartiesPlugin = true;
|
||||
|
||||
public boolean getAllowCommands() {
|
||||
return allowCommands;
|
||||
}
|
||||
|
||||
public void setAllowCommands(boolean allowCommands) {
|
||||
this.allowCommands = allowCommands;
|
||||
}
|
||||
|
||||
public boolean getUseDungeonsXLPlugin() {
|
||||
return useDungeonsXLPlugin;
|
||||
}
|
||||
|
||||
public void setUseDungeonsXLPlugin(boolean useDungeonsXLPlugin) {
|
||||
this.useDungeonsXLPlugin = useDungeonsXLPlugin;
|
||||
}
|
||||
|
||||
public boolean getUsePartiesPlugin() {
|
||||
return usePartiesPlugin;
|
||||
}
|
||||
|
||||
public void setUsePartiesPlugin(boolean usePartiesPlugin) {
|
||||
this.usePartiesPlugin = usePartiesPlugin;
|
||||
}
|
||||
}
|
@ -825,6 +825,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
String endDatePln = null;
|
||||
Long repeatCyclePln = null;
|
||||
Long cooldownPln = null;
|
||||
boolean allowCommandsOpt = true;
|
||||
boolean useDungeonsXLPluginOpt = false;
|
||||
boolean usePartiesPluginOpt = true;
|
||||
if (cc.getSessionData(CK.Q_START_NPC) != null) {
|
||||
@ -941,6 +942,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
if (cc.getSessionData(CK.PLN_COOLDOWN) != null) {
|
||||
cooldownPln = (Long) cc.getSessionData(CK.PLN_COOLDOWN);
|
||||
}
|
||||
if (cc.getSessionData(CK.OPT_ALLOW_COMMANDS) != null) {
|
||||
allowCommandsOpt = (Boolean) cc.getSessionData(CK.OPT_ALLOW_COMMANDS);
|
||||
}
|
||||
if (cc.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null) {
|
||||
useDungeonsXLPluginOpt = (Boolean) cc.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
|
||||
}
|
||||
@ -1395,6 +1399,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cs.set("planner", null);
|
||||
}
|
||||
ConfigurationSection sch = cs.createSection("options");
|
||||
sch.set("allow-commands", allowCommandsOpt);
|
||||
sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt);
|
||||
sch.set("use-parties-plugin", usePartiesPluginOpt);
|
||||
}
|
||||
@ -1509,6 +1514,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cc.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
|
||||
}
|
||||
Options opt = q.getOptions();
|
||||
cc.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.getAllowCommands());
|
||||
cc.setSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN, opt.getUseDungeonsXLPlugin());
|
||||
cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin());
|
||||
// Stages (Objectives)
|
||||
|
@ -1738,6 +1738,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
|
||||
private void loadQuestOptions(FileConfiguration config, ConfigurationSection questsSection, Quest quest, String questKey) throws SkipQuest {
|
||||
Options opts = quest.getOptions();
|
||||
if (config.contains("quests." + questKey + ".options.allow-commands")) {
|
||||
opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands"));
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".options.use-dungeonsxl-plugin")) {
|
||||
opts.setUseDungeonsXLPlugin(config.getBoolean("quests." + questKey + ".options.use-dungeonsxl-plugin"));
|
||||
}
|
||||
|
@ -386,6 +386,15 @@ public class PlayerListener implements Listener {
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
if (quester.getCurrentQuests().isEmpty() == false) {
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (!quest.getOptions().getAllowCommands()) {
|
||||
if (!evt.getMessage().startsWith("/quest")) {
|
||||
evt.getPlayer().sendMessage(ChatColor.RED + Lang.get(evt.getPlayer(), "optCommandsDenied").replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED));
|
||||
evt.setCancelled(true);
|
||||
plugin.getLogger().info("Player " + evt.getPlayer().getName() + " tried to use command " + evt.getMessage()
|
||||
+ " but was denied because they are currently on quest " + quest.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
Stage currentStage = quester.getCurrentStage(quest);
|
||||
if (currentStage == null) {
|
||||
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() + " on command for quest " + quest.getName());
|
||||
|
@ -89,14 +89,26 @@ public class OptionsPrompt extends FixedSetPrompt {
|
||||
String lang = Lang.get("questEditorOpts") + ": " + Lang.get("optGeneral");
|
||||
lang = lang.replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
|
||||
text = ChatColor.DARK_AQUA + lang + "\n";
|
||||
text += ChatColor.RED + "WIP" + "\n";
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
|
||||
if (context.getSessionData(CK.OPT_ALLOW_COMMANDS) == null) {
|
||||
boolean defaultOpt = new Options().getAllowCommands();
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " ("
|
||||
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
|
||||
} else {
|
||||
boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS);
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " ("
|
||||
+ (commandsOpt ? ChatColor.GREEN + String.valueOf(commandsOpt) : ChatColor.RED + String.valueOf(commandsOpt)) + ChatColor.YELLOW + ")\n";
|
||||
}
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
tempKey = CK.OPT_ALLOW_COMMANDS;
|
||||
tempPrompt = new GeneralPrompt();
|
||||
return new TrueFalsePrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
tempKey = null;
|
||||
tempPrompt = null;
|
||||
return factory.returnToMenu();
|
||||
|
@ -129,6 +129,7 @@ public class CK {
|
||||
public static final String PLN_REPEAT_CYCLE = "repeatCyclePln";
|
||||
public static final String PLN_COOLDOWN = "cooldownPln";
|
||||
// Options
|
||||
public static final String OPT_ALLOW_COMMANDS = "allowCommandsOpt";
|
||||
public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
|
||||
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
|
||||
// Events
|
||||
|
@ -509,6 +509,8 @@ plnTooLate: "<quest> was last active <time> ago."
|
||||
optGeneral: "General"
|
||||
optMultiplayer: "Multiplayer"
|
||||
optBooleanPrompt: "Enter '<true>' or '<false>', <clear>, <cancel>"
|
||||
optAllowCommands: "Allow commands during quest"
|
||||
optCommandsDenied: "You cannot use commands during <quest>."
|
||||
optUseDungeonsXLPlugin: "Use DungeonsXL plugin"
|
||||
optUsePartiesPlugin: "Use Parties plugin"
|
||||
rewSetMoney: "Set money reward"
|
||||
|
Loading…
Reference in New Issue
Block a user