diff --git a/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java b/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java index ab5e90d70..d56a576c7 100644 --- a/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java +++ b/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java @@ -260,6 +260,7 @@ else if (isCompleted) quest.getDescription(playerUUID).forEach(string -> { lore.add(Component.text(" §f" + string)); }); + lore.addAll(quest.getAdditionalLore()); if (currentTier.getSteps() != null && !currentTier.getSteps().isEmpty()) { lore.add(Component.empty()); lore.add(Component.text("§6◆ §eAvancement:")); diff --git a/src/main/java/fr/openmc/core/features/quests/objects/Quest.java b/src/main/java/fr/openmc/core/features/quests/objects/Quest.java index 9d6861400..e38f616cf 100644 --- a/src/main/java/fr/openmc/core/features/quests/objects/Quest.java +++ b/src/main/java/fr/openmc/core/features/quests/objects/Quest.java @@ -10,6 +10,7 @@ import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; import lombok.Getter; +import lombok.Setter; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; @@ -31,6 +32,8 @@ public class Quest { private final String name; private final List baseDescription; + @Setter + private List additionalLore; private final ItemStack icon; private final boolean isLargeActionBar; private final List tiers = new ArrayList<>(); @@ -50,6 +53,7 @@ public class Quest { public Quest(String name, List baseDescription, ItemStack icon) { this.name = name; this.baseDescription = baseDescription; + this.additionalLore = List.of(); this.icon = icon; this.isLargeActionBar = false; } @@ -64,6 +68,7 @@ public Quest(String name, List baseDescription, ItemStack icon) { public Quest(String name, List baseDescription, Material icon) { this.name = name; this.baseDescription = baseDescription; + this.additionalLore = List.of(); this.icon = new ItemStack(icon); this.isLargeActionBar = false; } @@ -79,6 +84,7 @@ public Quest(String name, List baseDescription, Material icon) { public Quest(String name, List baseDescription, ItemStack icon, boolean isLargeActionBar) { this.name = name; this.baseDescription = baseDescription; + this.additionalLore = List.of(); this.icon = icon; this.isLargeActionBar = isLargeActionBar; } @@ -94,6 +100,7 @@ public Quest(String name, List baseDescription, ItemStack icon, boolean public Quest(String name, List baseDescription, Material icon, boolean isLargeActionBar) { this.name = name; this.baseDescription = baseDescription; + this.additionalLore = List.of(); this.icon = new ItemStack(icon); this.isLargeActionBar = isLargeActionBar; } diff --git a/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java index ac6106c0a..1334b7854 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java @@ -4,6 +4,10 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; +import fr.openmc.core.utils.ItemUtils; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; @@ -13,33 +17,49 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; import java.util.EnumMap; import java.util.List; import java.util.Map; public class BreakLogQuest extends Quest implements Listener { - private final Map logWeights = new EnumMap<>(Material.class); - - /** - * Crée une hâche enchantée pour les récompenses. - * @param material Le matériau de la hache (ex: Material.IRON_AXE) - * @return ItemStack enchanté - */ - private ItemStack getEnchantedAxe(Material material) { - ItemStack axe = ItemStack.of(material); - axe.editMeta(meta -> { - meta.addEnchant(Enchantment.EFFICIENCY, 3, true); // Efficacité III - meta.addEnchant(Enchantment.UNBREAKING, 2, true); // Solidité II - }); - return axe; + private final static Map logWeights = new EnumMap<>(Material.class); + static { + // Définir les poids (progression plus rapide pour les bûches rares) + logWeights.put(Material.OAK_LOG, 1); + logWeights.put(Material.BIRCH_LOG, 1); + logWeights.put(Material.SPRUCE_LOG, 1); + logWeights.put(Material.ACACIA_LOG, 2); + logWeights.put(Material.DARK_OAK_LOG, 3); + logWeights.put(Material.JUNGLE_LOG, 3); + logWeights.put(Material.MANGROVE_LOG, 4); + logWeights.put(Material.CHERRY_LOG, 4); + logWeights.put(Material.CRIMSON_STEM, 5); + logWeights.put(Material.WARPED_STEM, 5); } + private static List getLore() { + List lore = new ArrayList<>(); + + for (var entry : logWeights.entrySet()) { + lore.add(Component.text("- ").color(NamedTextColor.DARK_GRAY) + .append(ItemUtils.getItemTranslation(entry.getKey())) + .append(Component.text(" : ")) + .append(Component.text(entry.getValue()).color(NamedTextColor.AQUA)) + .append(Component.text(" points")) + .decoration(TextDecoration.ITALIC, false) + .color(NamedTextColor.GRAY) + ); + } + + return lore; + } public BreakLogQuest() { super("Bûcheron de l'extrême", List.of("Casser {target} bûches"), new ItemStack(Material.IRON_AXE)); - + this.setAdditionalLore(getLore()); this.addTiers( new QuestTier(500, new QuestMoneyReward(300), new QuestItemReward(Material.IRON_AXE, 1)), new QuestTier(1500, new QuestMoneyReward(500), new QuestItemReward(getEnchantedAxe(Material.IRON_AXE), 1)), @@ -47,19 +67,6 @@ public BreakLogQuest() { new QuestTier(15000, new QuestMoneyReward(3000), new QuestItemReward(getEnchantedAxe(Material.DIAMOND_AXE), 1)) ); - - - // Définir les poids (progression plus rapide pour les bûches rares) - logWeights.put(Material.OAK_LOG, 1); - logWeights.put(Material.BIRCH_LOG, 1); - logWeights.put(Material.SPRUCE_LOG, 1); - logWeights.put(Material.ACACIA_LOG, 2); - logWeights.put(Material.DARK_OAK_LOG, 3); - logWeights.put(Material.JUNGLE_LOG, 3); - logWeights.put(Material.MANGROVE_LOG, 4); - logWeights.put(Material.CHERRY_LOG, 4); - logWeights.put(Material.CRIMSON_STEM, 5); - logWeights.put(Material.WARPED_STEM, 5); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -72,4 +79,18 @@ public void onPlayerBreak(BlockBreakEvent event) { this.incrementProgress(event.getPlayer().getUniqueId(), progress); } } + + /** + * Crée une hâche enchantée pour les récompenses. + * @param material Le matériau de la hache (ex: Material.IRON_AXE) + * @return ItemStack enchanté + */ + private ItemStack getEnchantedAxe(Material material) { + ItemStack axe = ItemStack.of(material); + axe.editMeta(meta -> { + meta.addEnchant(Enchantment.EFFICIENCY, 3, true); // Efficacité III + meta.addEnchant(Enchantment.UNBREAKING, 2, true); // Solidité II + }); + return axe; + } }