Display block goal in journal, see #2271

This commit is contained in:
PikaMug 2024-08-03 00:51:00 -04:00
parent 237aa29864
commit f9a1c2961c

View File

@ -12,12 +12,13 @@ package me.pikamug.quests.item;
import me.pikamug.quests.BukkitQuestsPlugin; import me.pikamug.quests.BukkitQuestsPlugin;
import me.pikamug.quests.player.Quester; import me.pikamug.quests.player.Quester;
import me.pikamug.quests.quests.components.BukkitObjective;
import me.pikamug.quests.quests.Quest; import me.pikamug.quests.quests.Quest;
import me.pikamug.quests.quests.components.BukkitObjective;
import me.pikamug.quests.quests.components.Objective; import me.pikamug.quests.quests.components.Objective;
import me.pikamug.quests.util.BukkitItemUtil; import me.pikamug.quests.util.BukkitItemUtil;
import me.pikamug.quests.util.BukkitLang; import me.pikamug.quests.util.BukkitLang;
import me.pikamug.quests.util.BukkitMiscUtil; import me.pikamug.quests.util.BukkitMiscUtil;
import me.pikamug.quests.util.stack.BlockItemStack;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.TranslatableComponent; import net.md_5.bungee.api.chat.TranslatableComponent;
@ -84,9 +85,20 @@ public class BukkitQuestJournal {
continue; continue;
} }
String[] split = null; String[] split = null;
if (message.contains("<item>") && objective.getGoalAsItem() != null) { if (message.contains("<item>")) {
split = message.split("<item>"); split = message.split("<item>");
builder.add(split[0]); builder.add(split[0]);
if (objective.getGoalAsBlockItem() != null) {
final BlockItemStack goal = objective.getGoalAsBlockItem();
if (plugin.getConfigSettings().canTranslateNames()) {
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
.queryMaterial(goal.getType(), goal.getDurability(), null));
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
builder.add(tc);
} else {
builder.add(ChatColor.AQUA + BukkitItemUtil.getPrettyItemName(goal.getType().name()));
}
} else if (objective.getGoalAsItem() != null) {
final ItemStack goal = objective.getGoalAsItem(); final ItemStack goal = objective.getGoalAsItem();
if (goal.getItemMeta() != null && goal.getItemMeta().hasDisplayName()) { if (goal.getItemMeta() != null && goal.getItemMeta().hasDisplayName()) {
builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC
@ -101,6 +113,7 @@ public class BukkitQuestJournal {
builder.add(ChatColor.AQUA + BukkitItemUtil.getPrettyItemName(goal.getType().name())); builder.add(ChatColor.AQUA + BukkitItemUtil.getPrettyItemName(goal.getType().name()));
} }
} }
}
if (split.length > 1) { if (split.length > 1) {
builder.add(split[1]).newLine(); builder.add(split[1]).newLine();
} }