mirror of https://github.com/PikaMug/Quests.git
Split ask-confirmation setting, per #1866
This commit is contained in:
parent
3554de1c0d
commit
e2282494e0
|
@ -9,12 +9,14 @@ public interface ISettings {
|
|||
void setAllowCommandsForNpcQuests(final boolean allowCommandsForNpcQuests);
|
||||
boolean canAllowPranks();
|
||||
void setAllowPranks(final boolean allowPranks);
|
||||
boolean canAskConfirmation();
|
||||
void setAskConfirmation(final boolean askConfirmation);
|
||||
boolean canClickablePrompts();
|
||||
void setClickablePrompts(boolean clickablePrompts);
|
||||
int getConditionInterval();
|
||||
void setConditionInterval(final int conditionInterval);
|
||||
boolean canConfirmAbandon();
|
||||
void setConfirmAbandon(final boolean confirmAbandon);
|
||||
boolean canConfirmAccept();
|
||||
void setConfirmAccept(final boolean confirmAccept);
|
||||
int getConsoleLogging();
|
||||
void setConsoleLogging(final int consoleLogging);
|
||||
boolean canDisableCommandFeedback();
|
||||
|
|
|
@ -867,7 +867,7 @@ public class Quester implements IQuester {
|
|||
final ISettings settings = plugin.getSettings();
|
||||
if (getPlayer() != null) {
|
||||
setQuestIdToQuit(quest.getId());
|
||||
if (settings.canAskConfirmation()) {
|
||||
if (settings.canConfirmAbandon()) {
|
||||
final ConversationFactory cf = new ConversationFactory(plugin).withModality(false)
|
||||
.withPrefix(context -> ChatColor.GRAY.toString())
|
||||
.withFirstPrompt(new QuestAbandonPrompt()).withTimeout(settings.getAcceptTimeout())
|
||||
|
|
|
@ -49,12 +49,12 @@ import me.blackvein.quests.module.ICustomObjective;
|
|||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.BukkitQuestFactory;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.quests.IStage;
|
||||
import me.blackvein.quests.quests.Options;
|
||||
import me.blackvein.quests.quests.Planner;
|
||||
import me.blackvein.quests.quests.QuestFactory;
|
||||
import me.blackvein.quests.quests.Requirements;
|
||||
import me.blackvein.quests.quests.Rewards;
|
||||
import me.blackvein.quests.quests.IStage;
|
||||
import me.blackvein.quests.statistics.Metrics;
|
||||
import me.blackvein.quests.storage.Storage;
|
||||
import me.blackvein.quests.storage.StorageFactory;
|
||||
|
@ -97,7 +97,6 @@ import org.bukkit.entity.EntityType;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -4192,47 +4191,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
return SkillType.getSkill(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use InventoryUtil.removeItem(Inventory, ItemStack)
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean removeItem(final Inventory inventory, final ItemStack is) {
|
||||
final int amount = is.getAmount();
|
||||
final HashMap<Integer, ? extends ItemStack> allItems = inventory.all(is.getType());
|
||||
final HashMap<Integer, Integer> removeFrom = new HashMap<>();
|
||||
int foundAmount = 0;
|
||||
for (final Map.Entry<Integer, ? extends ItemStack> item : allItems.entrySet()) {
|
||||
if (ItemUtil.compareItems(is, item.getValue(), true) == 0) {
|
||||
if (item.getValue().getAmount() >= amount - foundAmount) {
|
||||
removeFrom.put(item.getKey(), amount - foundAmount);
|
||||
foundAmount = amount;
|
||||
} else {
|
||||
foundAmount += item.getValue().getAmount();
|
||||
removeFrom.put(item.getKey(), item.getValue().getAmount());
|
||||
}
|
||||
if (foundAmount >= amount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foundAmount == amount) {
|
||||
for (final Map.Entry<Integer, Integer> toRemove : removeFrom.entrySet()) {
|
||||
final ItemStack item = inventory.getItem(toRemove.getKey());
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getAmount() - toRemove.getValue() <= 0) {
|
||||
inventory.clear(toRemove.getKey());
|
||||
} else {
|
||||
item.setAmount(item.getAmount() - toRemove.getValue());
|
||||
inventory.setItem(toRemove.getKey(), item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if player can use Quests
|
||||
*
|
||||
|
|
|
@ -30,6 +30,8 @@ public class Settings implements ISettings {
|
|||
private boolean askConfirmation = true;
|
||||
private boolean clickablePrompts = true;
|
||||
private int conditionInterval = 7;
|
||||
private boolean confirmAbandon = true;
|
||||
private boolean confirmAccept = true;
|
||||
private int consoleLogging = 1;
|
||||
private boolean disableCommandFeedback = true;
|
||||
private boolean genFilesOnJoin = true;
|
||||
|
@ -76,11 +78,18 @@ public class Settings implements ISettings {
|
|||
public void setAllowPranks(final boolean allowPranks) {
|
||||
this.allowPranks = allowPranks;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #canConfirmAccept()}
|
||||
*/
|
||||
public boolean canAskConfirmation() {
|
||||
return askConfirmation;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link #setConfirmAccept(boolean)}
|
||||
*/
|
||||
public void setAskConfirmation(final boolean askConfirmation) {
|
||||
this.askConfirmation = askConfirmation;
|
||||
this.confirmAccept = askConfirmation;
|
||||
}
|
||||
public boolean canClickablePrompts() {
|
||||
return clickablePrompts;
|
||||
|
@ -94,6 +103,19 @@ public class Settings implements ISettings {
|
|||
public void setConditionInterval(final int conditionInterval) {
|
||||
this.conditionInterval = conditionInterval;
|
||||
}
|
||||
public boolean canConfirmAbandon() {
|
||||
return confirmAbandon;
|
||||
}
|
||||
public void setConfirmAbandon(final boolean confirmAbandon) {
|
||||
this.confirmAbandon = confirmAbandon;
|
||||
}
|
||||
public boolean canConfirmAccept() {
|
||||
return confirmAccept;
|
||||
}
|
||||
public void setConfirmAccept(final boolean confirmAccept) {
|
||||
this.askConfirmation = confirmAccept;
|
||||
this.confirmAccept = confirmAccept;
|
||||
}
|
||||
public int getConsoleLogging() {
|
||||
return consoleLogging;
|
||||
}
|
||||
|
@ -203,9 +225,11 @@ public class Settings implements ISettings {
|
|||
allowCommands = config.getBoolean("allow-command-questing", true);
|
||||
allowCommandsForNpcQuests = config.getBoolean("allow-command-quests-with-npcs", false);
|
||||
allowPranks = config.getBoolean("allow-pranks", true);
|
||||
askConfirmation = config.getBoolean("ask-confirmation", true);
|
||||
askConfirmation = config.getBoolean("confirm-accept", true);
|
||||
clickablePrompts = config.getBoolean("clickable-prompts", true);
|
||||
conditionInterval = config.getInt("condition-interval", 8);
|
||||
confirmAbandon = config.getBoolean("confirm-abandon", true);
|
||||
confirmAccept = config.getBoolean("confirm-accept", true);
|
||||
if (conditionInterval < 3 || conditionInterval > 180) {
|
||||
plugin.getLogger().warning("Condition interval out of range, reverting to default of 8 seconds");
|
||||
conditionInterval = 8;
|
||||
|
|
|
@ -3,9 +3,10 @@ accept-timeout: 20
|
|||
allow-command-questing: true
|
||||
allow-command-quests-with-npcs: false
|
||||
allow-pranks: true
|
||||
ask-confirmation: true
|
||||
clickable-prompts: true
|
||||
condition-interval: 8
|
||||
confirm-abandon: true
|
||||
confirm-accept: true
|
||||
console-logging: 2
|
||||
disable-command-feedback: false
|
||||
generate-files-on-join: true
|
||||
|
|
Loading…
Reference in New Issue