Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +32,8 @@ public class Quest {

private final String name;
private final List<String> baseDescription;
@Setter
private List<Component> additionalLore;
private final ItemStack icon;
private final boolean isLargeActionBar;
private final List<QuestTier> tiers = new ArrayList<>();
Expand All @@ -50,6 +53,7 @@ public class Quest {
public Quest(String name, List<String> baseDescription, ItemStack icon) {
this.name = name;
this.baseDescription = baseDescription;
this.additionalLore = List.of();
this.icon = icon;
this.isLargeActionBar = false;
}
Expand All @@ -64,6 +68,7 @@ public Quest(String name, List<String> baseDescription, ItemStack icon) {
public Quest(String name, List<String> baseDescription, Material icon) {
this.name = name;
this.baseDescription = baseDescription;
this.additionalLore = List.of();
this.icon = new ItemStack(icon);
this.isLargeActionBar = false;
}
Expand All @@ -79,6 +84,7 @@ public Quest(String name, List<String> baseDescription, Material icon) {
public Quest(String name, List<String> baseDescription, ItemStack icon, boolean isLargeActionBar) {
this.name = name;
this.baseDescription = baseDescription;
this.additionalLore = List.of();
this.icon = icon;
this.isLargeActionBar = isLargeActionBar;
}
Expand All @@ -94,6 +100,7 @@ public Quest(String name, List<String> baseDescription, ItemStack icon, boolean
public Quest(String name, List<String> baseDescription, Material icon, boolean isLargeActionBar) {
this.name = name;
this.baseDescription = baseDescription;
this.additionalLore = List.of();
this.icon = new ItemStack(icon);
this.isLargeActionBar = isLargeActionBar;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,53 +17,56 @@
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<Material, Integer> 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<Material, Integer> 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<Component> getLore() {
List<Component> 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)),
new QuestTier(5000, new QuestMoneyReward(1500), new QuestItemReward(getEnchantedAxe(Material.GOLDEN_AXE), 1)),
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)
Expand All @@ -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;
}
}
Loading