mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-23 02:55:40 +01:00
New check placeholder condition
This commit is contained in:
parent
85ec7e14a4
commit
71e0a01717
@ -633,6 +633,17 @@ public class Quester {
|
|||||||
msg += ChatColor.AQUA + "\n \u2515 " + r;
|
msg += ChatColor.AQUA + "\n \u2515 " + r;
|
||||||
}
|
}
|
||||||
p.sendMessage(ChatColor.YELLOW + msg);
|
p.sendMessage(ChatColor.YELLOW + msg);
|
||||||
|
} else if (!c.getPlaceholdersCheckIdentifier().isEmpty()) {
|
||||||
|
String msg = "- " + Lang.get("conditionEditorCheckPlaceholder");
|
||||||
|
int index = 0;
|
||||||
|
for (final String r : c.getPlaceholdersCheckIdentifier()) {
|
||||||
|
if (c.getPlaceholdersCheckValue().size() > index) {
|
||||||
|
msg += ChatColor.AQUA + "\n \u2515 " + r + ChatColor.GRAY + " = "
|
||||||
|
+ ChatColor.AQUA + c.getPlaceholdersCheckValue().get(index);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
p.sendMessage(ChatColor.YELLOW + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3462,6 +3462,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
throw new ConditionFormatException("stay-within-region is not a list of regions", conditionKey);
|
throw new ConditionFormatException("stay-within-region is not a list of regions", conditionKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (data.contains(conditionKey + "check-placeholder-id")) {
|
||||||
|
if (ConfigUtil.checkList(data.getList(conditionKey + "check-placeholder-id"), String.class)) {
|
||||||
|
if (data.contains(conditionKey + "check-placeholder-value")) {
|
||||||
|
if (ConfigUtil.checkList(data.getList(conditionKey + "check-placeholder-value"), String.class)) {
|
||||||
|
final LinkedList<String> identifiers = new LinkedList<String>();
|
||||||
|
final LinkedList<String> values = new LinkedList<String>();
|
||||||
|
identifiers.addAll(data.getStringList(conditionKey + "check-placeholder-id"));
|
||||||
|
values.addAll(data.getStringList(conditionKey + "check-placeholder-value"));
|
||||||
|
condition.setPlaceholdersCheckIdentifier(identifiers);
|
||||||
|
condition.setPlaceholdersCheckValue(values);
|
||||||
|
} else {
|
||||||
|
throw new ConditionFormatException("check-placeholder-value is not a list of values", conditionKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ConditionFormatException("check-placeholder-id is not a list of identifiers", conditionKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import me.blackvein.quests.Quester;
|
|||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
|
||||||
public class Condition {
|
public class Condition {
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ public class Condition {
|
|||||||
private LinkedList<String> worldsWhileStayingWithin = new LinkedList<String>();
|
private LinkedList<String> worldsWhileStayingWithin = new LinkedList<String>();
|
||||||
private LinkedList<String> biomesWhileStayingWithin = new LinkedList<String>();
|
private LinkedList<String> biomesWhileStayingWithin = new LinkedList<String>();
|
||||||
private LinkedList<String> regionsWhileStayingWithin = new LinkedList<String>();
|
private LinkedList<String> regionsWhileStayingWithin = new LinkedList<String>();
|
||||||
|
private LinkedList<String> placeholdersCheckIdentifier = new LinkedList<String>();
|
||||||
|
private LinkedList<String> placeholdersCheckValue = new LinkedList<String>();
|
||||||
|
|
||||||
public Condition(final Quests plugin) {
|
public Condition(final Quests plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -103,6 +106,22 @@ public class Condition {
|
|||||||
this.regionsWhileStayingWithin = biomesWhileStayingWithin;
|
this.regionsWhileStayingWithin = biomesWhileStayingWithin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedList<String> getPlaceholdersCheckIdentifier() {
|
||||||
|
return placeholdersCheckIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlaceholdersCheckIdentifier(final LinkedList<String> placeholdersCheckIdentifier) {
|
||||||
|
this.placeholdersCheckIdentifier = placeholdersCheckIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<String> getPlaceholdersCheckValue() {
|
||||||
|
return placeholdersCheckValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlaceholdersCheckValue(final LinkedList<String> placeholdersCheckValue) {
|
||||||
|
this.placeholdersCheckValue = placeholdersCheckValue;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean check(final Quester quester, final Quest quest) {
|
public boolean check(final Quester quester, final Quest quest) {
|
||||||
final Player player = quester.getPlayer();
|
final Player player = quester.getPlayer();
|
||||||
@ -161,6 +180,21 @@ public class Condition {
|
|||||||
plugin.getLogger().info("DEBUG: Condition region mismatch for " + player.getName() + ": " + r);
|
plugin.getLogger().info("DEBUG: Condition region mismatch for " + player.getName() + ": " + r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (!placeholdersCheckIdentifier.isEmpty()) {
|
||||||
|
int index = 0;
|
||||||
|
for (final String i : placeholdersCheckIdentifier) {
|
||||||
|
if (plugin.getDependencies().isPluginAvailable("PlaceholderAPI")) {
|
||||||
|
if (placeholdersCheckValue.size() > index &&
|
||||||
|
placeholdersCheckValue.get(index).equals(PlaceholderAPI.setPlaceholders(player, i))) {
|
||||||
|
return true;
|
||||||
|
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||||
|
plugin.getLogger().info("DEBUG: Condition placeholder mismatch for " + player.getName() + ": " + i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.getLogger().warning("PAPI must be installed for placeholder checks: " + i);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,18 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
regions.addAll(condition.getRegionsWhileStayingWithin());
|
regions.addAll(condition.getRegionsWhileStayingWithin());
|
||||||
context.setSessionData(CK.C_WHILE_WITHIN_REGION, regions);
|
context.setSessionData(CK.C_WHILE_WITHIN_REGION, regions);
|
||||||
}
|
}
|
||||||
|
if (condition.getPlaceholdersCheckIdentifier() != null
|
||||||
|
&& condition.getPlaceholdersCheckIdentifier().isEmpty() == false) {
|
||||||
|
final LinkedList<String> identifiers = new LinkedList<String>();
|
||||||
|
identifiers.addAll(condition.getPlaceholdersCheckIdentifier());
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, identifiers);
|
||||||
|
}
|
||||||
|
if (condition.getPlaceholdersCheckValue() != null
|
||||||
|
&& condition.getPlaceholdersCheckValue().isEmpty() == false) {
|
||||||
|
final LinkedList<String> values = new LinkedList<String>();
|
||||||
|
values.addAll(condition.getPlaceholdersCheckValue());
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearData(final ConversationContext context) {
|
public void clearData(final ConversationContext context) {
|
||||||
@ -127,6 +139,8 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, null);
|
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, null);
|
||||||
context.setSessionData(CK.C_WHILE_WITHIN_BIOME, null);
|
context.setSessionData(CK.C_WHILE_WITHIN_BIOME, null);
|
||||||
context.setSessionData(CK.C_WHILE_WITHIN_REGION, null);
|
context.setSessionData(CK.C_WHILE_WITHIN_REGION, null);
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, null);
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteCondition(final ConversationContext context) {
|
public void deleteCondition(final ConversationContext context) {
|
||||||
@ -231,6 +245,14 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||||||
section.set("stay-within-region",
|
section.set("stay-within-region",
|
||||||
context.getSessionData(CK.C_WHILE_WITHIN_REGION));
|
context.getSessionData(CK.C_WHILE_WITHIN_REGION));
|
||||||
}
|
}
|
||||||
|
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID) != null) {
|
||||||
|
section.set("check-placeholder-id",
|
||||||
|
context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID));
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL) != null) {
|
||||||
|
section.set("check-placeholder-value",
|
||||||
|
context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
data.save(conditionsFile);
|
data.save(conditionsFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.convo.conditions.main;
|
package me.blackvein.quests.convo.conditions.main;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
this.plugin = (Quests)context.getPlugin();
|
this.plugin = (Quests)context.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int size = 7;
|
private final int size = 8;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
@ -62,10 +63,11 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
return ChatColor.BLUE;
|
|
||||||
case 6:
|
case 6:
|
||||||
return ChatColor.GREEN;
|
return ChatColor.BLUE;
|
||||||
case 7:
|
case 7:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
case 8:
|
||||||
return ChatColor.RED;
|
return ChatColor.RED;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -84,10 +86,12 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
case 4:
|
case 4:
|
||||||
return ChatColor.GOLD + Lang.get("conditionEditorWorld");
|
return ChatColor.GOLD + Lang.get("conditionEditorWorld");
|
||||||
case 5:
|
case 5:
|
||||||
return ChatColor.YELLOW + Lang.get("conditionEditorFailQuest") + ":";
|
return ChatColor.YELLOW + Lang.get("conditionEditorCheckPlaceholder");
|
||||||
case 6:
|
case 6:
|
||||||
return ChatColor.GREEN + Lang.get("save");
|
return ChatColor.YELLOW + Lang.get("conditionEditorFailQuest") + ":";
|
||||||
case 7:
|
case 7:
|
||||||
|
return ChatColor.GREEN + Lang.get("save");
|
||||||
|
case 8:
|
||||||
return ChatColor.RED + Lang.get("exit");
|
return ChatColor.RED + Lang.get("exit");
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -101,14 +105,15 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
return "";
|
|
||||||
case 5:
|
case 5:
|
||||||
|
return "";
|
||||||
|
case 6:
|
||||||
if (context.getSessionData(CK.C_FAIL_QUEST) == null) {
|
if (context.getSessionData(CK.C_FAIL_QUEST) == null) {
|
||||||
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
|
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
|
||||||
}
|
}
|
||||||
return "" + ChatColor.AQUA + context.getSessionData(CK.C_FAIL_QUEST);
|
return "" + ChatColor.AQUA + context.getSessionData(CK.C_FAIL_QUEST);
|
||||||
case 6:
|
|
||||||
case 7:
|
case 7:
|
||||||
|
case 8:
|
||||||
return "";
|
return "";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -141,6 +146,8 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
case 4:
|
case 4:
|
||||||
return new WorldPrompt(context);
|
return new WorldPrompt(context);
|
||||||
case 5:
|
case 5:
|
||||||
|
return new ConditionPlaceholderListPrompt(context);
|
||||||
|
case 6:
|
||||||
final String s = (String) context.getSessionData(CK.C_FAIL_QUEST);
|
final String s = (String) context.getSessionData(CK.C_FAIL_QUEST);
|
||||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
|
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
|
||||||
@ -148,13 +155,13 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
|
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
|
||||||
}
|
}
|
||||||
return new ConditionMainPrompt(context);
|
return new ConditionMainPrompt(context);
|
||||||
case 6:
|
case 7:
|
||||||
if (context.getSessionData(CK.C_OLD_CONDITION) != null) {
|
if (context.getSessionData(CK.C_OLD_CONDITION) != null) {
|
||||||
return new ConditionSavePrompt(context, (String) context.getSessionData(CK.C_OLD_CONDITION));
|
return new ConditionSavePrompt(context, (String) context.getSessionData(CK.C_OLD_CONDITION));
|
||||||
} else {
|
} else {
|
||||||
return new ConditionSavePrompt(context, null);
|
return new ConditionSavePrompt(context, null);
|
||||||
}
|
}
|
||||||
case 7:
|
case 8:
|
||||||
return new ConditionExitPrompt(context);
|
return new ConditionExitPrompt(context);
|
||||||
default:
|
default:
|
||||||
return new ConditionMainPrompt(context);
|
return new ConditionMainPrompt(context);
|
||||||
@ -213,6 +220,229 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ConditionPlaceholderListPrompt extends ConditionsEditorNumericPrompt {
|
||||||
|
|
||||||
|
public ConditionPlaceholderListPrompt(final ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 4;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle(final ConversationContext context) {
|
||||||
|
return Lang.get("conditionEditorPlaceholderTitle");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 3:
|
||||||
|
return ChatColor.RED;
|
||||||
|
case 4:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSelectionText(final ConversationContext context, final int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("conditionEditorSetPlaceholderId");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("conditionEditorSetPlaceholderVal");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.RED + Lang.get("clear");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.GREEN + Lang.get("done");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
if (plugin.getDependencies().getPlaceholderApi() != null) {
|
||||||
|
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
for (final String i : (List<String>) context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if (plugin.getDependencies().getPlaceholderApi() != null) {
|
||||||
|
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
for (final String i : (List<String>) context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(final ConversationContext context) {
|
||||||
|
final ConditionsEditorPostOpenNumericPromptEvent event
|
||||||
|
= new ConditionsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = ChatColor.AQUA + getTitle(context) + "\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||||
|
switch(input.intValue()) {
|
||||||
|
case 1:
|
||||||
|
return new ConditionPlaceholderIdentifierPrompt(context);
|
||||||
|
case 2:
|
||||||
|
return new ConditionPlaceholderValuePrompt(context);
|
||||||
|
case 3:
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorPlaceholderCleared"));
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, null);
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, null);
|
||||||
|
return new ConditionPlaceholderListPrompt(context);
|
||||||
|
case 4:
|
||||||
|
int one;
|
||||||
|
int two;
|
||||||
|
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID) != null) {
|
||||||
|
one = ((List<String>) context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID)).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL) != null) {
|
||||||
|
two = ((List<String>) context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL)).size();
|
||||||
|
} else {
|
||||||
|
two = 0;
|
||||||
|
}
|
||||||
|
if (one == two) {
|
||||||
|
return new ConditionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
|
||||||
|
return new ConditionPlaceholderListPrompt(context);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return new ConditionPlaceholderListPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConditionPlaceholderIdentifierPrompt extends ConditionsEditorStringPrompt {
|
||||||
|
|
||||||
|
public ConditionPlaceholderIdentifierPrompt(final ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle(final ConversationContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQueryText(final ConversationContext context) {
|
||||||
|
return Lang.get("conditionEditorEnterPlaceholderId");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(final ConversationContext context) {
|
||||||
|
final ConditionsEditorPostOpenStringPromptEvent event
|
||||||
|
= new ConditionsEditorPostOpenStringPromptEvent(context, this);
|
||||||
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
return ChatColor.YELLOW + getQueryText(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
final String[] args = input.split(" ");
|
||||||
|
final List<String> identifiers = new LinkedList<String>();
|
||||||
|
for (String arg : args) {
|
||||||
|
if (!arg.trim().startsWith("%")) {
|
||||||
|
arg = "%" + arg.trim();
|
||||||
|
}
|
||||||
|
if (!arg.endsWith("%")) {
|
||||||
|
arg = arg + "%";
|
||||||
|
}
|
||||||
|
identifiers.add(arg);
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, identifiers);
|
||||||
|
}
|
||||||
|
return new ConditionPlaceholderListPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConditionPlaceholderValuePrompt extends ConditionsEditorStringPrompt {
|
||||||
|
|
||||||
|
public ConditionPlaceholderValuePrompt(final ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle(final ConversationContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQueryText(final ConversationContext context) {
|
||||||
|
return Lang.get("conditionEditorEnterPlaceholderVal");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(final ConversationContext context) {
|
||||||
|
final ConditionsEditorPostOpenStringPromptEvent event
|
||||||
|
= new ConditionsEditorPostOpenStringPromptEvent(context, this);
|
||||||
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
return ChatColor.YELLOW + getQueryText(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
final String[] args = input.split(" ");
|
||||||
|
final List<String> values = new LinkedList<String>();
|
||||||
|
values.addAll(Arrays.asList(args));
|
||||||
|
context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, values);
|
||||||
|
}
|
||||||
|
return new ConditionPlaceholderListPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ConditionSavePrompt extends ConditionsEditorStringPrompt {
|
public class ConditionSavePrompt extends ConditionsEditorStringPrompt {
|
||||||
|
|
||||||
String modName = null;
|
String modName = null;
|
||||||
|
@ -657,7 +657,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
switch(number) {
|
switch(number) {
|
||||||
case 1:
|
case 1:
|
||||||
if (context.getSessionData(CK.REW_ITEMS) == null) {
|
if (context.getSessionData(CK.REW_ITEMS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
for (final ItemStack is : (List<ItemStack>) context.getSessionData(CK.REW_ITEMS)) {
|
for (final ItemStack is : (List<ItemStack>) context.getSessionData(CK.REW_ITEMS)) {
|
||||||
@ -1049,7 +1049,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
switch(number) {
|
switch(number) {
|
||||||
case 1:
|
case 1:
|
||||||
if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) {
|
if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
for (final String s : (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS)) {
|
for (final String s : (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS)) {
|
||||||
@ -1059,7 +1059,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if (context.getSessionData(CK.REW_MCMMO_AMOUNTS) == null) {
|
if (context.getSessionData(CK.REW_MCMMO_AMOUNTS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
for (final Integer i : (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS)) {
|
for (final Integer i : (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS)) {
|
||||||
@ -1068,6 +1068,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
|
case 4:
|
||||||
return "";
|
return "";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -1121,7 +1122,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
if (one == two) {
|
if (one == two) {
|
||||||
return new RewardsPrompt(context);
|
return new RewardsPrompt(context);
|
||||||
} else {
|
} else {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("rewMcMMOListsNotSameSize"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
|
||||||
return new RewardsMcMMOListPrompt(context);
|
return new RewardsMcMMOListPrompt(context);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1289,7 +1290,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
switch(number) {
|
switch(number) {
|
||||||
case 1:
|
case 1:
|
||||||
if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) {
|
if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
for (final String s : (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES)) {
|
for (final String s : (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES)) {
|
||||||
@ -1299,7 +1300,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if (context.getSessionData(CK.REW_HEROES_AMOUNTS) == null) {
|
if (context.getSessionData(CK.REW_HEROES_AMOUNTS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
for (final Double d : (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS)) {
|
for (final Double d : (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS)) {
|
||||||
|
@ -187,4 +187,6 @@ public class CK {
|
|||||||
public static final String C_WHILE_WITHIN_WORLD = "conWithinWorld";
|
public static final String C_WHILE_WITHIN_WORLD = "conWithinWorld";
|
||||||
public static final String C_WHILE_WITHIN_BIOME = "conWithinBiome";
|
public static final String C_WHILE_WITHIN_BIOME = "conWithinBiome";
|
||||||
public static final String C_WHILE_WITHIN_REGION = "conWithinRegion";
|
public static final String C_WHILE_WITHIN_REGION = "conWithinRegion";
|
||||||
|
public static final String C_WHILE_PLACEHOLDER_ID = "conPlaceholderId";
|
||||||
|
public static final String C_WHILE_PLACEHOLDER_VAL = "conPlaceholderVal";
|
||||||
}
|
}
|
||||||
|
@ -404,6 +404,7 @@ conditionEditorForcedToQuit: "If you save the condition, anyone who is actively
|
|||||||
conditionEditorSetName: "Set name"
|
conditionEditorSetName: "Set name"
|
||||||
conditionEditorEntity: "Entity"
|
conditionEditorEntity: "Entity"
|
||||||
conditionEditorWorld: "World"
|
conditionEditorWorld: "World"
|
||||||
|
conditionEditorCheckPlaceholder: "Check placeholder"
|
||||||
conditionEditorFailQuest: "Fail the quest"
|
conditionEditorFailQuest: "Fail the quest"
|
||||||
conditionEditorConditionCleared: "Condition cleared."
|
conditionEditorConditionCleared: "Condition cleared."
|
||||||
conditionEditorRideEntity: "Ride entity"
|
conditionEditorRideEntity: "Ride entity"
|
||||||
@ -426,6 +427,12 @@ conditionEditorRegionsTitle: "- Regions -"
|
|||||||
conditionEditorRegionsPrompt: "Enter region names, <space>, <cancel>"
|
conditionEditorRegionsPrompt: "Enter region names, <space>, <cancel>"
|
||||||
conditionEditorStayWithinRegion: "Stay within region"
|
conditionEditorStayWithinRegion: "Stay within region"
|
||||||
conditionEditorInvalidRegion: "is not a valid region name!"
|
conditionEditorInvalidRegion: "is not a valid region name!"
|
||||||
|
conditionEditorPlaceholderTitle: "- PlaceholderAPI -"
|
||||||
|
conditionEditorSetPlaceholderId: "Set placeholder identifiers"
|
||||||
|
conditionEditorSetPlaceholderVal: "Set placeholder values"
|
||||||
|
conditionEditorPlaceholderCleared: "Placeholder condition cleared."
|
||||||
|
conditionEditorEnterPlaceholderId: "Enter placeholder identifiers, <space>, <cancel>"
|
||||||
|
conditionEditorEnterPlaceholderVal: "Enter placeholder values, <space>, <cancel>"
|
||||||
reqSetMoney: "Set money requirement"
|
reqSetMoney: "Set money requirement"
|
||||||
reqSetQuestPoints: "Set <points> requirement"
|
reqSetQuestPoints: "Set <points> requirement"
|
||||||
reqSetItem: "Set item requirements"
|
reqSetItem: "Set item requirements"
|
||||||
|
Loading…
Reference in New Issue
Block a user