From f9a1c2961c5f0d4dbfdf0e3775e6d81a808d8c47 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sat, 3 Aug 2024 00:51:00 -0400 Subject: [PATCH] Display block goal in journal, see #2271 --- .../quests/item/BukkitQuestJournal.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/me/pikamug/quests/item/BukkitQuestJournal.java b/core/src/main/java/me/pikamug/quests/item/BukkitQuestJournal.java index 24db68228..f7d61d578 100644 --- a/core/src/main/java/me/pikamug/quests/item/BukkitQuestJournal.java +++ b/core/src/main/java/me/pikamug/quests/item/BukkitQuestJournal.java @@ -12,12 +12,13 @@ package me.pikamug.quests.item; import me.pikamug.quests.BukkitQuestsPlugin; import me.pikamug.quests.player.Quester; -import me.pikamug.quests.quests.components.BukkitObjective; import me.pikamug.quests.quests.Quest; +import me.pikamug.quests.quests.components.BukkitObjective; import me.pikamug.quests.quests.components.Objective; import me.pikamug.quests.util.BukkitItemUtil; import me.pikamug.quests.util.BukkitLang; 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.TextComponent; import net.md_5.bungee.api.chat.TranslatableComponent; @@ -84,22 +85,34 @@ public class BukkitQuestJournal { continue; } String[] split = null; - if (message.contains("") && objective.getGoalAsItem() != null) { + if (message.contains("")) { split = message.split(""); builder.add(split[0]); - final ItemStack goal = objective.getGoalAsItem(); - if (goal.getItemMeta() != null && goal.getItemMeta().hasDisplayName()) { - builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC - + goal.getItemMeta().getDisplayName()); - } else { + if (objective.getGoalAsBlockItem() != null) { + final BlockItemStack goal = objective.getGoalAsBlockItem(); if (plugin.getConfigSettings().canTranslateNames()) { final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager() - .queryItemStack(goal)); + .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(); + if (goal.getItemMeta() != null && goal.getItemMeta().hasDisplayName()) { + builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC + + goal.getItemMeta().getDisplayName()); + } else { + if (plugin.getConfigSettings().canTranslateNames()) { + final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager() + .queryItemStack(goal)); + tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA); + builder.add(tc); + } else { + builder.add(ChatColor.AQUA + BukkitItemUtil.getPrettyItemName(goal.getType().name())); + } + } } if (split.length > 1) { builder.add(split[1]).newLine();