mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-27 11:37:51 +01:00
Address inability to clear overrides in editor, fixes #1168
This commit is contained in:
parent
d36893ef0e
commit
81ce65e815
@ -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);
|
||||
}
|
||||
context.setSessionData(classPrefix + "-override", input);
|
||||
return oldPrompt;
|
||||
}
|
||||
|
||||
|
@ -154,13 +154,17 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
|
||||
public String getAdditionalText(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.REQ_MONEY) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
if (plugin.getDependencies().getVaultEconomy() != null) {
|
||||
if (context.getSessionData(CK.REQ_MONEY) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " "
|
||||
+ (moneyReq > 1 ? plugin.getDependencies().getCurrency(true)
|
||||
: plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")";
|
||||
}
|
||||
} else {
|
||||
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " "
|
||||
+ (moneyReq > 1 ? plugin.getDependencies().getCurrency(true)
|
||||
: plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")";
|
||||
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||
}
|
||||
case 2:
|
||||
if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {
|
||||
@ -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) {
|
||||
LinkedList<String> overrides = new LinkedList<String>();
|
||||
if (context.getSessionData(CK.REQ_FAIL_MESSAGE) != null) {
|
||||
overrides.addAll((List<String>) context.getSessionData(CK.REQ_FAIL_MESSAGE));
|
||||
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(input);
|
||||
context.setSessionData(CK.REQ_FAIL_MESSAGE, overrides);
|
||||
context.setSessionData(classPrefix + "-override", null);
|
||||
}
|
||||
overrides.add((String) context.getSessionData(classPrefix + "-override"));
|
||||
context.setSessionData(CK.REQ_FAIL_MESSAGE, overrides);
|
||||
context.setSessionData(classPrefix + "-override", null);
|
||||
}
|
||||
}
|
||||
checkRequirement(context);
|
||||
|
||||
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||
|
@ -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") + ")";
|
||||
|
Loading…
Reference in New Issue
Block a user