mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-23 01:27:35 +01:00
Replace config setting for quitting with per-quest option, fixes #615
This commit is contained in:
parent
ccc6b976b8
commit
62a4629f34
@ -14,6 +14,7 @@ package me.blackvein.quests;
|
|||||||
|
|
||||||
public class Options {
|
public class Options {
|
||||||
private boolean allowCommands = true;
|
private boolean allowCommands = true;
|
||||||
|
private boolean allowQuitting = true;
|
||||||
private boolean useDungeonsXLPlugin = false;
|
private boolean useDungeonsXLPlugin = false;
|
||||||
private boolean usePartiesPlugin = true;
|
private boolean usePartiesPlugin = true;
|
||||||
|
|
||||||
@ -25,6 +26,14 @@ public class Options {
|
|||||||
this.allowCommands = allowCommands;
|
this.allowCommands = allowCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getAllowQuitting() {
|
||||||
|
return allowQuitting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowQuitting(boolean allowQuitting) {
|
||||||
|
this.allowQuitting = allowQuitting;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getUseDungeonsXLPlugin() {
|
public boolean getUseDungeonsXLPlugin() {
|
||||||
return useDungeonsXLPlugin;
|
return useDungeonsXLPlugin;
|
||||||
}
|
}
|
||||||
|
@ -833,6 +833,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
Long repeatCyclePln = null;
|
Long repeatCyclePln = null;
|
||||||
Long cooldownPln = null;
|
Long cooldownPln = null;
|
||||||
boolean allowCommandsOpt = true;
|
boolean allowCommandsOpt = true;
|
||||||
|
boolean allowQuittingOpt = true;
|
||||||
boolean useDungeonsXLPluginOpt = false;
|
boolean useDungeonsXLPluginOpt = false;
|
||||||
boolean usePartiesPluginOpt = true;
|
boolean usePartiesPluginOpt = true;
|
||||||
if (cc.getSessionData(CK.Q_START_NPC) != null) {
|
if (cc.getSessionData(CK.Q_START_NPC) != null) {
|
||||||
@ -952,6 +953,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
if (cc.getSessionData(CK.OPT_ALLOW_COMMANDS) != null) {
|
if (cc.getSessionData(CK.OPT_ALLOW_COMMANDS) != null) {
|
||||||
allowCommandsOpt = (Boolean) cc.getSessionData(CK.OPT_ALLOW_COMMANDS);
|
allowCommandsOpt = (Boolean) cc.getSessionData(CK.OPT_ALLOW_COMMANDS);
|
||||||
}
|
}
|
||||||
|
if (cc.getSessionData(CK.OPT_ALLOW_QUITTING) != null) {
|
||||||
|
allowQuittingOpt = (Boolean) cc.getSessionData(CK.OPT_ALLOW_QUITTING);
|
||||||
|
}
|
||||||
if (cc.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null) {
|
if (cc.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null) {
|
||||||
useDungeonsXLPluginOpt = (Boolean) cc.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
|
useDungeonsXLPluginOpt = (Boolean) cc.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
|
||||||
}
|
}
|
||||||
@ -1421,6 +1425,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
ConfigurationSection sch = cs.createSection("options");
|
ConfigurationSection sch = cs.createSection("options");
|
||||||
sch.set("allow-commands", allowCommandsOpt);
|
sch.set("allow-commands", allowCommandsOpt);
|
||||||
|
sch.set("allow-quitting", allowQuittingOpt);
|
||||||
sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt);
|
sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt);
|
||||||
sch.set("use-parties-plugin", usePartiesPluginOpt);
|
sch.set("use-parties-plugin", usePartiesPluginOpt);
|
||||||
}
|
}
|
||||||
@ -1536,6 +1541,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
Options opt = q.getOptions();
|
Options opt = q.getOptions();
|
||||||
cc.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.getAllowCommands());
|
cc.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.getAllowCommands());
|
||||||
|
cc.setSessionData(CK.OPT_ALLOW_QUITTING, opt.getAllowQuitting());
|
||||||
cc.setSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN, opt.getUseDungeonsXLPlugin());
|
cc.setSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN, opt.getUseDungeonsXLPlugin());
|
||||||
cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin());
|
cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin());
|
||||||
// Stages (Objectives)
|
// Stages (Objectives)
|
||||||
|
@ -247,8 +247,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<CustomReward> getCustomRewards() {
|
public List<CustomReward> getCustomRewards() {
|
||||||
return customRewards;
|
return customRewards;
|
||||||
}
|
}
|
||||||
@ -1781,6 +1779,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (config.contains("quests." + questKey + ".options.allow-commands")) {
|
if (config.contains("quests." + questKey + ".options.allow-commands")) {
|
||||||
opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands"));
|
opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands"));
|
||||||
}
|
}
|
||||||
|
if (config.contains("quests." + questKey + ".options.allow-quitting")) {
|
||||||
|
opts.setAllowQuitting(config.getBoolean("quests." + questKey + ".options.allow-quitting"));
|
||||||
|
} else if (getConfig().contains("allow-quitting")) {
|
||||||
|
// Legacy
|
||||||
|
opts.setAllowQuitting(getConfig().getBoolean("allow-quitting"));
|
||||||
|
}
|
||||||
if (config.contains("quests." + questKey + ".options.use-dungeonsxl-plugin")) {
|
if (config.contains("quests." + questKey + ".options.use-dungeonsxl-plugin")) {
|
||||||
opts.setUseDungeonsXLPlugin(config.getBoolean("quests." + questKey + ".options.use-dungeonsxl-plugin"));
|
opts.setUseDungeonsXLPlugin(config.getBoolean("quests." + questKey + ".options.use-dungeonsxl-plugin"));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ public class Settings {
|
|||||||
private int acceptTimeout = 20;
|
private int acceptTimeout = 20;
|
||||||
private boolean allowCommands = true;
|
private boolean allowCommands = true;
|
||||||
private boolean allowCommandsForNpcQuests = false;
|
private boolean allowCommandsForNpcQuests = false;
|
||||||
private boolean allowQuitting = true;
|
|
||||||
private boolean askConfirmation = true;
|
private boolean askConfirmation = true;
|
||||||
private boolean genFilesOnJoin = true;
|
private boolean genFilesOnJoin = true;
|
||||||
private boolean ignoreLockedQuests = false;
|
private boolean ignoreLockedQuests = false;
|
||||||
@ -61,12 +60,6 @@ public class Settings {
|
|||||||
public void setAllowCommandsForNpcQuests(boolean allowCommandsForNpcQuests) {
|
public void setAllowCommandsForNpcQuests(boolean allowCommandsForNpcQuests) {
|
||||||
this.allowCommandsForNpcQuests = allowCommandsForNpcQuests;
|
this.allowCommandsForNpcQuests = allowCommandsForNpcQuests;
|
||||||
}
|
}
|
||||||
public boolean canAllowQuitting() {
|
|
||||||
return allowQuitting;
|
|
||||||
}
|
|
||||||
public void setAllowQuitting(boolean allowQuitting) {
|
|
||||||
this.allowQuitting = allowQuitting;
|
|
||||||
}
|
|
||||||
public boolean canAskConfirmation() {
|
public boolean canAskConfirmation() {
|
||||||
return askConfirmation;
|
return askConfirmation;
|
||||||
}
|
}
|
||||||
@ -169,7 +162,6 @@ public class Settings {
|
|||||||
acceptTimeout = config.getInt("accept-timeout", 20);
|
acceptTimeout = config.getInt("accept-timeout", 20);
|
||||||
allowCommands = config.getBoolean("allow-command-questing", true);
|
allowCommands = config.getBoolean("allow-command-questing", true);
|
||||||
allowCommandsForNpcQuests = config.getBoolean("allow-command-quests-with-npcs", false);
|
allowCommandsForNpcQuests = config.getBoolean("allow-command-quests-with-npcs", false);
|
||||||
allowQuitting = config.getBoolean("allow-quitting", true);
|
|
||||||
askConfirmation = config.getBoolean("ask-confirmation", true);
|
askConfirmation = config.getBoolean("ask-confirmation", true);
|
||||||
genFilesOnJoin = config.getBoolean("generate-files-on-join", true);
|
genFilesOnJoin = config.getBoolean("generate-files-on-join", true);
|
||||||
ignoreLockedQuests = config.getBoolean("ignore-locked-quests", false);
|
ignoreLockedQuests = config.getBoolean("ignore-locked-quests", false);
|
||||||
|
@ -612,7 +612,6 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void questsQuit(final Player player, String[] args) {
|
private void questsQuit(final Player player, String[] args) {
|
||||||
if (plugin.getSettings().canAllowQuitting() == true) {
|
|
||||||
if (((Player) player).hasPermission("quests.quit")) {
|
if (((Player) player).hasPermission("quests.quit")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
player.sendMessage(ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP"));
|
player.sendMessage(ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP"));
|
||||||
@ -622,6 +621,7 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
if (quester.getCurrentQuests().isEmpty() == false) {
|
if (quester.getCurrentQuests().isEmpty() == false) {
|
||||||
Quest q = plugin.getQuest(MiscUtil.concatArgArray(args, 1, args.length - 1, ' '));
|
Quest q = plugin.getQuest(MiscUtil.concatArgArray(args, 1, args.length - 1, ' '));
|
||||||
if (q != null) {
|
if (q != null) {
|
||||||
|
if (q.getOptions().getAllowQuitting()) {
|
||||||
QuestQuitEvent event = new QuestQuitEvent(q, quester);
|
QuestQuitEvent event = new QuestQuitEvent(q, quester);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -634,6 +634,9 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
quester.saveData();
|
quester.saveData();
|
||||||
quester.loadData();
|
quester.loadData();
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questQuitDisabled"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + Lang.get(player, "questNotFound"));
|
player.sendMessage(ChatColor.RED + Lang.get(player, "questNotFound"));
|
||||||
}
|
}
|
||||||
@ -643,9 +646,6 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + Lang.get(player, "NoPermission"));
|
player.sendMessage(ChatColor.RED + Lang.get(player, "NoPermission"));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questQuitDisabled"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void questsTake(final Player player, String[] args) {
|
private void questsTake(final Player player, String[] args) {
|
||||||
|
@ -33,7 +33,7 @@ public class OptionsPrompt extends FixedSetPrompt {
|
|||||||
private StringPrompt tempPrompt;
|
private StringPrompt tempPrompt;
|
||||||
|
|
||||||
public OptionsPrompt(Quests plugin, QuestFactory qf) {
|
public OptionsPrompt(Quests plugin, QuestFactory qf) {
|
||||||
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
|
super("1", "2", "3");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
factory = qf;
|
factory = qf;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,16 @@ public class OptionsPrompt extends FixedSetPrompt {
|
|||||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " ("
|
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";
|
+ (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");
|
if (context.getSessionData(CK.OPT_ALLOW_QUITTING) == null) {
|
||||||
|
boolean defaultOpt = new Options().getAllowQuitting();
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowQuitting") + " ("
|
||||||
|
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
|
||||||
|
} else {
|
||||||
|
boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING);
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowQuitting") + " ("
|
||||||
|
+ (quittingOpt ? ChatColor.GREEN + String.valueOf(quittingOpt) : ChatColor.RED + String.valueOf(quittingOpt)) + ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +130,10 @@ public class OptionsPrompt extends FixedSetPrompt {
|
|||||||
tempPrompt = new GeneralPrompt();
|
tempPrompt = new GeneralPrompt();
|
||||||
return new TrueFalsePrompt();
|
return new TrueFalsePrompt();
|
||||||
} else if (input.equalsIgnoreCase("2")) {
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
tempKey = CK.OPT_ALLOW_QUITTING;
|
||||||
|
tempPrompt = new GeneralPrompt();
|
||||||
|
return new TrueFalsePrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
tempKey = null;
|
tempKey = null;
|
||||||
tempPrompt = null;
|
tempPrompt = null;
|
||||||
return factory.returnToMenu();
|
return factory.returnToMenu();
|
||||||
|
@ -131,6 +131,7 @@ public class CK {
|
|||||||
public static final String PLN_COOLDOWN = "cooldownPln";
|
public static final String PLN_COOLDOWN = "cooldownPln";
|
||||||
// Options
|
// Options
|
||||||
public static final String OPT_ALLOW_COMMANDS = "allowCommandsOpt";
|
public static final String OPT_ALLOW_COMMANDS = "allowCommandsOpt";
|
||||||
|
public static final String OPT_ALLOW_QUITTING = "allowQuittingOpt";
|
||||||
public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
|
public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
|
||||||
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
|
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
|
||||||
// Events
|
// Events
|
||||||
|
@ -500,6 +500,7 @@ optGeneral: "General"
|
|||||||
optMultiplayer: "Multiplayer"
|
optMultiplayer: "Multiplayer"
|
||||||
optBooleanPrompt: "Enter '<true>' or '<false>', <clear>, <cancel>"
|
optBooleanPrompt: "Enter '<true>' or '<false>', <clear>, <cancel>"
|
||||||
optAllowCommands: "Allow commands during quest"
|
optAllowCommands: "Allow commands during quest"
|
||||||
|
optAllowQuitting: "Allow quitting during quest"
|
||||||
optCommandsDenied: "You cannot use commands during <quest>."
|
optCommandsDenied: "You cannot use commands during <quest>."
|
||||||
optUseDungeonsXLPlugin: "Use DungeonsXL plugin"
|
optUseDungeonsXLPlugin: "Use DungeonsXL plugin"
|
||||||
optUsePartiesPlugin: "Use Parties plugin"
|
optUsePartiesPlugin: "Use Parties plugin"
|
||||||
@ -701,7 +702,7 @@ pageSelectionNum: "Page selection must be a number."
|
|||||||
pageSelectionPosNum: "Page selection must be a positive number."
|
pageSelectionPosNum: "Page selection must be a positive number."
|
||||||
questTakeDisabled: "Taking Quests via commands has been disabled."
|
questTakeDisabled: "Taking Quests via commands has been disabled."
|
||||||
questQuit: "You have quit <quest>"
|
questQuit: "You have quit <quest>"
|
||||||
questQuitDisabled: "Quitting Quests has been disabled."
|
questQuitDisabled: "Quitting this quest has been disabled."
|
||||||
questsUnknownCommand: "Unknown Quests command. Type /quests for help."
|
questsUnknownCommand: "Unknown Quests command. Type /quests for help."
|
||||||
pageNotExist: "Page does not exist."
|
pageNotExist: "Page does not exist."
|
||||||
pageFooter: "- Page <current> of <all> -"
|
pageFooter: "- Page <current> of <all> -"
|
||||||
|
Loading…
Reference in New Issue
Block a user