Process custom requirement display placeholders

This commit is contained in:
PikaMug 2024-02-15 12:31:34 -05:00
parent a85c2d4b81
commit d35301d1e5

View File

@ -1129,12 +1129,23 @@ public class BukkitQuester implements Quester {
for (final Entry<String, Map<String, Object>> m : requirements.getCustomRequirements().entrySet()) { for (final Entry<String, Map<String, Object>> m : requirements.getCustomRequirements().entrySet()) {
for (final CustomRequirement cr : plugin.getCustomRequirements()) { for (final CustomRequirement cr : plugin.getCustomRequirements()) {
if (cr.getName().equalsIgnoreCase(m.getKey())) { if (cr.getName().equalsIgnoreCase(m.getKey())) {
String message = cr.getDisplay() != null ? cr.getDisplay() : m.getKey();
for (Entry<String, Object> prompt : cr.getData().entrySet()) {
final String replacement = "%" + prompt.getKey() + "%";
try {
if (message.contains(replacement)) {
message = message.replace(replacement, String.valueOf(m.getValue().get(prompt.getKey())));
}
} catch (final NullPointerException ne) {
plugin.getLogger().severe("Unable to gather display for " + cr.getName() + " on "
+ quest.getName());
ne.printStackTrace();
}
}
if (cr.testRequirement(getPlayer().getUniqueId(), m.getValue())) { if (cr.testRequirement(getPlayer().getUniqueId(), m.getValue())) {
finishedRequirements.add(ChatColor.GREEN + "" finishedRequirements.add(ChatColor.GREEN + "" + message);
+ (cr.getDisplay() != null ? cr.getDisplay() : m.getKey()));
} else { } else {
unfinishedRequirements.add(ChatColor.GRAY + "" unfinishedRequirements.add(ChatColor.GRAY + "" + message);
+ (cr.getDisplay() != null ? cr.getDisplay() : m.getKey()));
} }
} }
} }