Config setting to toggle saving in trial mode

This commit is contained in:
PikaMug 2021-06-22 07:31:57 -04:00
parent 4f1c55c299
commit 5d9a9e8c97
5 changed files with 63 additions and 47 deletions

View File

@ -12,12 +12,11 @@
package me.blackvein.quests;
import java.io.File;
import java.io.IOException;
import me.blackvein.quests.util.Lang;
import org.bukkit.configuration.file.FileConfiguration;
import me.blackvein.quests.util.Lang;
import java.io.File;
import java.io.IOException;
public class Settings {
@ -39,6 +38,7 @@ public class Settings {
private boolean showQuestReqs = true;
private boolean showQuestTitles = true;
private int strictPlayerMovement = 0;
private boolean trialSave = true;
private int topLimit = 150;
private boolean translateNames = false;
private boolean translateSubCommands = false;
@ -149,6 +149,12 @@ public class Settings {
public void setStrictPlayerMovement(final int strictPlayerMovement) {
this.strictPlayerMovement = strictPlayerMovement;
}
public boolean canTrialSave() {
return trialSave;
}
public void setTrialSave(final boolean trialSave) {
this.trialSave = trialSave;
}
public int getTopLimit() {
return topLimit;
}
@ -193,6 +199,7 @@ public class Settings {
showQuestReqs = config.getBoolean("show-requirements", true);
showQuestTitles = config.getBoolean("show-titles", true);
strictPlayerMovement = config.getInt("strict-player-movement", 0);
trialSave = config.getBoolean("trial-save", true);
topLimit = config.getInt("top-limit", 150);
translateNames = config.getBoolean("translate-names", true);
translateSubCommands = config.getBoolean("translate-subcommands", false);

View File

@ -12,20 +12,6 @@
package me.blackvein.quests.convo.actions.main;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestMob;
import me.blackvein.quests.Quests;
@ -45,6 +31,19 @@ import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@ -1032,6 +1031,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("noPermission"));
return new ActionMainPrompt(context);
}
plugin.getActionFactory().saveAction(context);
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {

View File

@ -12,14 +12,6 @@
package me.blackvein.quests.convo.conditions.main;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage;
@ -33,6 +25,13 @@ import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenNume
import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenStringPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
@ -527,6 +526,10 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("noPermission"));
return new ConditionMainPrompt(context);
}
plugin.getConditionFactory().saveCondition(context);
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {

View File

@ -12,28 +12,7 @@
package me.blackvein.quests.convo.quests.main;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.sk89q.worldguard.protection.managers.RegionManager;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.generic.ItemStackPrompt;
@ -51,6 +30,25 @@ import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.CitizensAPI;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class QuestMainPrompt extends QuestsEditorNumericPrompt {
@ -815,6 +813,10 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
if (plugin.hasLimitedAccess(context.getForWhom()) && !plugin.getSettings().canTrialSave()) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("noPermission"));
return new QuestMainPrompt(context);
}
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedAskMessage"));
return new QuestMainPrompt(context);

View File

@ -32,6 +32,7 @@ storage-data:
connection-timeout: 5000
storage-method:
player-data: yaml
trial-save: true
top-limit: 150
translate-names: true
translate-subcommands: false