Address inability to clear overrides in editor, fixes #1168

This commit is contained in:
PikaMug 2020-04-04 01:32:51 -04:00
parent d36893ef0e
commit 81ce65e815
3 changed files with 24 additions and 24 deletions

View File

@ -18,7 +18,6 @@ import org.bukkit.conversations.Prompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
import me.blackvein.quests.util.Lang;
public class OverridePrompt extends QuestsEditorStringPrompt {
private final Prompt oldPrompt;
@ -59,13 +58,7 @@ public class OverridePrompt extends QuestsEditorStringPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false
&& input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
context.setSessionData(classPrefix + "-override", input);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cleared"));
context.setSessionData(classPrefix + "-override", null);
}
return oldPrompt;
}

View File

@ -154,6 +154,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
if (plugin.getDependencies().getVaultEconomy() != null) {
if (context.getSessionData(CK.REQ_MONEY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
@ -162,6 +163,9 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
+ (moneyReq > 1 ? plugin.getDependencies().getCurrency(true)
: plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")";
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 2:
if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
@ -289,16 +293,20 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
// Checkadd newly made override
if (context.getSessionData(classPrefix + "-override") != null) {
final String input = (String) context.getSessionData(classPrefix + "-override");
if (input != null && !input.equalsIgnoreCase(Lang.get("cancel"))) {
if (input.equalsIgnoreCase(Lang.get("clear"))) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, null);
} else {
LinkedList<String> overrides = new LinkedList<String>();
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) != null) {
overrides.addAll((List<String>) context.getSessionData(CK.REQ_FAIL_MESSAGE));
}
overrides.add((String) context.getSessionData(classPrefix + "-override"));
overrides.add(input);
context.setSessionData(CK.REQ_FAIL_MESSAGE, overrides);
context.setSessionData(classPrefix + "-override", null);
}
}
checkRequirement(context);
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);

View File

@ -166,7 +166,6 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
if (plugin.getDependencies().getVaultEconomy() != null) {
if (context.getSessionData(CK.REW_MONEY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";