diff --git a/api/src/main/java/dev/aurelium/auraskills/api/mana/ManaAbilities.java b/api/src/main/java/dev/aurelium/auraskills/api/mana/ManaAbilities.java index 953e486b4..306069c27 100644 --- a/api/src/main/java/dev/aurelium/auraskills/api/mana/ManaAbilities.java +++ b/api/src/main/java/dev/aurelium/auraskills/api/mana/ManaAbilities.java @@ -129,41 +129,41 @@ public boolean optionBoolean(String key) { @Override public boolean optionBoolean(String key, boolean def) { - return false; + return provider.optionBoolean(this, key, def); } @Override public int optionInt(String key) { - return 0; + return provider.optionInt(this, key); } @Override public int optionInt(String key, int def) { - return 0; + return provider.optionInt(this, key, def); } @Override public double optionDouble(String key) { - return 0; + return provider.optionDouble(this, key); } @Override public double optionDouble(String key, double def) { - return 0; + return provider.optionDouble(this, key, def); } @Override public String optionString(String key) { - return null; + return provider.optionString(this, key); } @Override public String optionString(String key, String def) { - return null; + return provider.optionString(this, key, def); } @Override public List optionStringList(String key) { - return null; + return provider.optionStringList(this, key); } } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/commands/CommandRegistrar.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/commands/CommandRegistrar.java index 7bfdc0da9..44ce7d7bd 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/commands/CommandRegistrar.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/commands/CommandRegistrar.java @@ -26,7 +26,6 @@ public CommandRegistrar(AuraSkills plugin) { public PaperCommandManager registerCommands() { var manager = new PaperCommandManager(plugin); - manager = new PaperCommandManager(plugin); manager.enableUnstableAPI("help"); manager.usePerIssuerLocale(true, false); manager.getCommandReplacements().addReplacement("skills_alias", "skills|sk|skill"); diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/handler/BlockLootHandler.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/handler/BlockLootHandler.java index 9187119a5..97d53083f 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/handler/BlockLootHandler.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/handler/BlockLootHandler.java @@ -87,6 +87,10 @@ public void onBreak(BlockBreakEvent event) { LootTable table = plugin.getLootTableManager().getLootTable(skill); if (table == null) return; for (LootPool pool : table.getPools()) { + // Ignore non-applicable sources + if (provider != null && !provider.isApplicable(pool, source)) { + continue; + } // Calculate chance for pool double chance; if (provider != null) { diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/provider/SkillLootProvider.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/provider/SkillLootProvider.java index aa314ca44..820a48bf2 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/provider/SkillLootProvider.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/provider/SkillLootProvider.java @@ -2,6 +2,7 @@ import com.archyx.lootmanager.loot.LootPool; import dev.aurelium.auraskills.api.event.loot.LootDropEvent; +import dev.aurelium.auraskills.api.source.XpSource; import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.bukkit.loot.handler.BlockLootHandler; import dev.aurelium.auraskills.common.user.User; @@ -20,4 +21,6 @@ public SkillLootProvider(AuraSkills plugin, BlockLootHandler handler) { public abstract LootDropEvent.Cause getCause(LootPool pool); + public abstract boolean isApplicable(LootPool pool, XpSource source); + } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/mana/ManaAbilityProvider.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/mana/ManaAbilityProvider.java index 0f17702d7..0ba180bf2 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/mana/ManaAbilityProvider.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/mana/ManaAbilityProvider.java @@ -2,11 +2,9 @@ import dev.aurelium.auraskills.api.event.mana.ManaAbilityActivateEvent; import dev.aurelium.auraskills.api.mana.ManaAbility; -import dev.aurelium.auraskills.api.source.XpSource; import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.common.mana.ManaAbilityData; import dev.aurelium.auraskills.common.message.type.ManaAbilityMessage; -import dev.aurelium.auraskills.common.source.SourceTag; import dev.aurelium.auraskills.common.user.User; import dev.aurelium.auraskills.common.util.math.NumberUtil; import dev.aurelium.auraskills.common.util.text.TextUtil; @@ -107,10 +105,6 @@ protected double getValue(User user) { return manaAbility.getValue(user.getManaAbilityLevel(manaAbility)); } - protected boolean hasTag(XpSource source, SourceTag tag) { - return plugin.getSkillManager().getSourcesWithTag(tag).contains(source); - } - private int getDuration(User user) { return (int) Math.round(manaAbility.getValue(user.getManaAbilityLevel(manaAbility)) * 20); } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/menus/stats/StatItem.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/menus/stats/StatItem.java index 72820078a..aef869627 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/menus/stats/StatItem.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/menus/stats/StatItem.java @@ -8,6 +8,7 @@ import dev.aurelium.auraskills.api.trait.Trait; import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.bukkit.menus.common.AbstractItem; +import dev.aurelium.auraskills.bukkit.trait.TraitImpl; import dev.aurelium.auraskills.common.message.type.MenuMessage; import dev.aurelium.auraskills.common.user.User; import dev.aurelium.auraskills.common.util.math.NumberUtil; @@ -78,10 +79,13 @@ private String getSkillsLeveledBy(Stat stat, Locale locale) { public String getStatDescriptors(Stat stat, User user, Locale locale) { StringBuilder sb = new StringBuilder(); for (Trait trait : stat.getTraits()) { + TraitImpl impl = plugin.getTraitManager().getTraitImpl(trait); + if (impl == null) continue; + sb.append(stat.getColor(locale)) .append(trait.getDisplayName(locale)) .append(": ") - .append(NumberUtil.format1(user.getEffectiveTraitLevel(trait))) + .append(impl.getMenuDisplay(user.getEffectiveTraitLevel(trait), trait)) .append("\n"); } if (!sb.isEmpty()) { diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/excavation/ExcavationLootProvider.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/excavation/ExcavationLootProvider.java index 498b36f3a..f95fa27aa 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/excavation/ExcavationLootProvider.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/excavation/ExcavationLootProvider.java @@ -3,9 +3,11 @@ import com.archyx.lootmanager.loot.LootPool; import dev.aurelium.auraskills.api.ability.Abilities; import dev.aurelium.auraskills.api.event.loot.LootDropEvent; +import dev.aurelium.auraskills.api.source.XpSource; import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.bukkit.loot.handler.BlockLootHandler; import dev.aurelium.auraskills.bukkit.loot.provider.SkillLootProvider; +import dev.aurelium.auraskills.common.source.SourceTag; import dev.aurelium.auraskills.common.user.User; public class ExcavationLootProvider extends SkillLootProvider { @@ -37,4 +39,11 @@ public LootDropEvent.Cause getCause(LootPool pool) { } return cause; } + + @Override + public boolean isApplicable(LootPool pool, XpSource source) { + if (pool.getName().equals("rare") && !plugin.getSkillManager().hasTag(source, SourceTag.METAL_DETECTOR_APPLICABLE)) { + return false; + } else return !pool.getName().equals("epic") || plugin.getSkillManager().hasTag(source, SourceTag.LUCKY_SPADES_APPLICABLE); + } } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/mining/SpeedMine.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/mining/SpeedMine.java index 2aec7a355..cd1156e89 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/mining/SpeedMine.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/skills/mining/SpeedMine.java @@ -54,7 +54,7 @@ public void activationListener(BlockBreakEvent event) { BlockXpSource source = sourcePair.first(); if (source == null) return; - if (hasTag(source, SourceTag.SPEED_MINE_APPLICABLE) && isHoldingMaterial(player)) { + if (plugin.getSkillManager().hasTag(source, SourceTag.SPEED_MINE_APPLICABLE) && isHoldingMaterial(player)) { checkActivation(player); } } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/source/BlockLeveler.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/source/BlockLeveler.java index b6d9799b3..1e947a045 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/source/BlockLeveler.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/source/BlockLeveler.java @@ -8,6 +8,7 @@ import dev.aurelium.auraskills.bukkit.skills.farming.FarmingAbilities; import dev.aurelium.auraskills.bukkit.skills.foraging.ForagingAbilities; import dev.aurelium.auraskills.bukkit.skills.mining.MiningAbilities; +import dev.aurelium.auraskills.common.source.SourceTag; import dev.aurelium.auraskills.common.source.SourceType; import dev.aurelium.auraskills.common.user.User; import dev.aurelium.auraskills.common.util.data.Pair; @@ -66,25 +67,26 @@ public void onInteract(PlayerInteractEvent event) { if (failsChecks(event, player, block.getLocation(), skill)) return; plugin.getLevelManager().addXp(user, skill, source.getXp()); - applyAbilities(skill, player, user, block); + applyAbilities(skill, player, user, block, source); } - private void applyAbilities(Skill skill, Player player, User user, Block block) { - var manager = plugin.getAbilityManager(); - if (skill.getAbilities().contains(Abilities.BOUNTIFUL_HARVEST)) { - manager.getAbilityImpl(FarmingAbilities.class).bountifulHarvest(player, user, block); + private void applyAbilities(Skill skill, Player player, User user, Block block, BlockXpSource source) { + var abilities = plugin.getAbilityManager(); + var tags = plugin.getSkillManager(); + if (skill.getAbilities().contains(Abilities.BOUNTIFUL_HARVEST) && tags.hasTag(source, SourceTag.BOUNTIFUL_HARVEST_APPLICABLE)) { + abilities.getAbilityImpl(FarmingAbilities.class).bountifulHarvest(player, user, block); } - if (skill.getAbilities().contains(Abilities.TRIPLE_HARVEST)) { - manager.getAbilityImpl(FarmingAbilities.class).tripleHarvest(player, user, block); + if (skill.getAbilities().contains(Abilities.TRIPLE_HARVEST) && tags.hasTag(source, SourceTag.TRIPLE_HARVEST_APPLICABLE)) { + abilities.getAbilityImpl(FarmingAbilities.class).tripleHarvest(player, user, block); } - if (skill.getAbilities().contains(Abilities.LUMBERJACK)) { - manager.getAbilityImpl(ForagingAbilities.class).lumberjack(player, user, block); + if (skill.getAbilities().contains(Abilities.LUMBERJACK) && tags.hasTag(source, SourceTag.LUMBERJACK_APPLICABLE)) { + abilities.getAbilityImpl(ForagingAbilities.class).lumberjack(player, user, block); } - if (skill.getAbilities().contains(Abilities.LUCKY_MINER)) { - manager.getAbilityImpl(MiningAbilities.class).luckyMiner(player, user, block); + if (skill.getAbilities().contains(Abilities.LUCKY_MINER) && tags.hasTag(source, SourceTag.LUCKY_MINER_APPLICABLE)) { + abilities.getAbilityImpl(MiningAbilities.class).luckyMiner(player, user, block); } - if (skill.getAbilities().contains(Abilities.BIGGER_SCOOP)) { - manager.getAbilityImpl(ExcavationAbilities.class).biggerScoop(player, user, block); + if (skill.getAbilities().contains(Abilities.BIGGER_SCOOP) && tags.hasTag(source, SourceTag.BIGGER_SCOOP_APPLICABLE)) { + abilities.getAbilityImpl(ExcavationAbilities.class).biggerScoop(player, user, block); } } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AnvilDiscountTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AnvilDiscountTrait.java index 79af97503..988dbbfa7 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AnvilDiscountTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AnvilDiscountTrait.java @@ -14,7 +14,7 @@ public class AnvilDiscountTrait extends TraitImpl { AnvilDiscountTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.ANVIL_DISCOUNT); } @Override diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AttackDamageTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AttackDamageTrait.java index 6cf8075fa..b0b541e5b 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AttackDamageTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/AttackDamageTrait.java @@ -12,7 +12,7 @@ public class AttackDamageTrait extends TraitImpl { AttackDamageTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.ATTACK_DAMAGE); } @Override diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/BukkitTraitManager.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/BukkitTraitManager.java index 7b7d250a7..01d99b054 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/BukkitTraitManager.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/BukkitTraitManager.java @@ -25,7 +25,7 @@ public BukkitTraitManager(AuraSkills plugin) { public void registerTraitImplementations() { registerTraitImpl(new HpTrait(plugin)); - registerTraitImpl(new RegenTrait(plugin)); + registerTraitImpl(new HealthRegenTrait(plugin)); registerTraitImpl(new ManaRegenTrait(plugin)); registerTraitImpl(new LuckTrait(plugin)); registerTraitImpl(new DoubleDropTrait(plugin)); diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DamageReductionTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DamageReductionTrait.java index c9feaddfb..9cb3fbb37 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DamageReductionTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DamageReductionTrait.java @@ -4,13 +4,14 @@ import dev.aurelium.auraskills.api.trait.Traits; import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.common.user.User; +import dev.aurelium.auraskills.common.util.math.NumberUtil; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; public class DamageReductionTrait extends TraitImpl { DamageReductionTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.DAMAGE_REDUCTION); } @Override @@ -18,8 +19,18 @@ public double getBaseLevel(Player player, Trait trait) { return 0; } + @Override + public String getMenuDisplay(double value, Trait trait) { + return NumberUtil.format1(getReductionValue(value) * 100) + "%"; + } + public void onDamage(EntityDamageByEntityEvent event, User user) { - double reduction = user.getBonusTraitLevel(Traits.DAMAGE_REDUCTION); - event.setDamage(event.getDamage() * (1 - (-1.0 * Math.pow(1.01, -1.0 * reduction) + 1))); + double reduction = user.getEffectiveTraitLevel(Traits.DAMAGE_REDUCTION); + event.setDamage(event.getDamage() * (1 - getReductionValue(reduction))); } + + private double getReductionValue(double value) { + return -1.0 * Math.pow(1.01, -1.0 * value) + 1; + } + } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DoubleDropTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DoubleDropTrait.java index 34afd9b95..ea547acf0 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DoubleDropTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/DoubleDropTrait.java @@ -23,7 +23,7 @@ public class DoubleDropTrait extends TraitImpl { private final Random r = new Random(); DoubleDropTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.DOUBLE_DROP); } @Override diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ExperienceBonusTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ExperienceBonusTrait.java index 878ebe41a..e6dcd4e8c 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ExperienceBonusTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ExperienceBonusTrait.java @@ -12,7 +12,7 @@ public class ExperienceBonusTrait extends TraitImpl { ExperienceBonusTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.EXPERIENCE_BONUS); } @Override diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/RegenTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HealthRegenTrait.java similarity index 97% rename from bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/RegenTrait.java rename to bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HealthRegenTrait.java index ea9e2aa00..4390811ba 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/RegenTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HealthRegenTrait.java @@ -17,10 +17,10 @@ import java.util.concurrent.TimeUnit; -public class RegenTrait extends TraitImpl { +public class HealthRegenTrait extends TraitImpl { - public RegenTrait(AuraSkills plugin) { - super(plugin); + public HealthRegenTrait(AuraSkills plugin) { + super(plugin, Traits.HUNGER_REGEN, Traits.SATURATION_REGEN); startHungerRegen(); startSaturationRegen(); } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HpTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HpTrait.java index c0eba5c79..35bc32fc9 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HpTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/HpTrait.java @@ -33,7 +33,7 @@ public class HpTrait extends TraitImpl implements AuraSkillsListener { private static final double threshold = 0.1; HpTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.HP); loadHearts(plugin.getConfig()); } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/LuckTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/LuckTrait.java index 835ce7d1f..ae43c8458 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/LuckTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/LuckTrait.java @@ -17,7 +17,7 @@ public class LuckTrait extends TraitImpl { LuckTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.LUCK); } @Override diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ManaRegenTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ManaRegenTrait.java index 257d881b2..9d4d7f9f3 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ManaRegenTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/ManaRegenTrait.java @@ -16,7 +16,7 @@ public class ManaRegenTrait extends TraitImpl { ManaRegenTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.MANA_REGEN); startRegen(); } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/MaxManaTrait.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/MaxManaTrait.java index 438186801..0539de4c9 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/MaxManaTrait.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/MaxManaTrait.java @@ -8,12 +8,12 @@ public class MaxManaTrait extends TraitImpl { MaxManaTrait(AuraSkills plugin) { - super(plugin); + super(plugin, Traits.MAX_MANA); } @Override public double getBaseLevel(Player player, Trait trait) { - return Traits.MAX_MANA.optionDouble("base"); + return 20; } } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/TraitImpl.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/TraitImpl.java index ea49cb31d..24bcd2446 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/TraitImpl.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/trait/TraitImpl.java @@ -4,6 +4,7 @@ import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.bukkit.user.BukkitUser; import dev.aurelium.auraskills.common.user.User; +import dev.aurelium.auraskills.common.util.math.NumberUtil; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -25,6 +26,10 @@ public Set getTraits() { public abstract double getBaseLevel(Player player, Trait trait); + public String getMenuDisplay(double value, Trait trait) { + return NumberUtil.format1(value); + } + public final void reload(User user, Trait trait) { reload(((BukkitUser) user).getPlayer(), trait); } diff --git a/bukkit/src/main/resources/messages/messages_en.yml b/bukkit/src/main/resources/messages/messages_en.yml index 804ca9984..eec0f5aee 100644 --- a/bukkit/src/main/resources/messages/messages_en.yml +++ b/bukkit/src/main/resources/messages/messages_en.yml @@ -1076,8 +1076,8 @@ traits: name: Anvil Discount max_mana: name: Max Mana - defense: - name: Defense + damage_reduction: + name: Damage Reduction units: mana: Mana hp: HP diff --git a/common/src/main/java/dev/aurelium/auraskills/common/message/type/TraitMessage.java b/common/src/main/java/dev/aurelium/auraskills/common/message/type/TraitMessage.java index 51e96e096..e04dfac06 100644 --- a/common/src/main/java/dev/aurelium/auraskills/common/message/type/TraitMessage.java +++ b/common/src/main/java/dev/aurelium/auraskills/common/message/type/TraitMessage.java @@ -18,7 +18,7 @@ public enum TraitMessage implements MessageKey { EXPERIENCE_BONUS_NAME, ANVIL_DISCOUNT_NAME, MAX_MANA_NAME, - DEFENSE_NAME; + DAMAGE_REDUCTION_NAME; private final String path; diff --git a/common/src/main/java/dev/aurelium/auraskills/common/skill/SkillManager.java b/common/src/main/java/dev/aurelium/auraskills/common/skill/SkillManager.java index b32817082..6f6faf379 100644 --- a/common/src/main/java/dev/aurelium/auraskills/common/skill/SkillManager.java +++ b/common/src/main/java/dev/aurelium/auraskills/common/skill/SkillManager.java @@ -127,4 +127,8 @@ public List getSourcesWithTag(SourceTag tag) { return sourceTagMap.getOrDefault(tag, new ArrayList<>()); } + public boolean hasTag(XpSource source, SourceTag tag) { + return sourceTagMap.getOrDefault(tag, new ArrayList<>()).contains(source); + } + } diff --git a/common/src/main/java/dev/aurelium/auraskills/common/source/SourceLoader.java b/common/src/main/java/dev/aurelium/auraskills/common/source/SourceLoader.java index 2709ad7fc..812f8926c 100644 --- a/common/src/main/java/dev/aurelium/auraskills/common/source/SourceLoader.java +++ b/common/src/main/java/dev/aurelium/auraskills/common/source/SourceLoader.java @@ -109,13 +109,25 @@ public Map> loadTags(Skills skill) { ConfigurationNode tagNode = user.node("tags").node(tag.name().toLowerCase(Locale.ROOT)); // Parse sources from string list - List sources = tagNode.getList(String.class, new ArrayList<>()).stream() - .map(NamespacedId::fromStringOrDefault) - .map(id -> plugin.getSkillManager().getSourceById(id)) - .filter(Objects::nonNull) - .toList(); + List sourceList = new ArrayList<>(); + for (String sourceString : tagNode.getList(String.class, new ArrayList<>())) { + if (sourceString.equals("*")) { // Add all sources in skill + sourceList.addAll(skill.getSources()); + } else if (sourceString.startsWith("!")) { // Remove source if starts with ! + NamespacedId id = NamespacedId.fromStringOrDefault(sourceString.substring(1)); + XpSource source = plugin.getSkillManager().getSourceById(id); + if (source != null) { + sourceList.remove(source); + } + } else { // Add raw source name + XpSource source = plugin.getSkillManager().getSourceById(NamespacedId.fromStringOrDefault(sourceString)); + if (source != null) { + sourceList.add(source); + } + } + } - tagMap.put(tag, sources); + tagMap.put(tag, sourceList); } return tagMap; diff --git a/common/src/main/resources/sources/excavation.yml b/common/src/main/resources/sources/excavation.yml index 592fa2357..7e0178331 100644 --- a/common/src/main/resources/sources/excavation.yml +++ b/common/src/main/resources/sources/excavation.yml @@ -46,4 +46,13 @@ sources: xp: 0.5 muddy_mangrove_roots: block: muddy_mangrove_roots - xp: 2.5 \ No newline at end of file + xp: 2.5 +tags: + bigger_scoop_applicable: + - '*' + metal_detector_applicable: + - '*' + lucky_spades_applicable: + - '*' + terraform_applicable: + - '*' \ No newline at end of file diff --git a/common/src/main/resources/sources/farming.yml b/common/src/main/resources/sources/farming.yml index 99656cbb2..fa080cfe6 100644 --- a/common/src/main/resources/sources/farming.yml +++ b/common/src/main/resources/sources/farming.yml @@ -108,4 +108,9 @@ sources: state: berries: true menu_item: - material: glow_berries \ No newline at end of file + material: glow_berries +tags: + bountiful_harvest_applicable: + - '*' + triple_harvest_applicable: + - '*' \ No newline at end of file diff --git a/common/src/main/resources/sources/foraging.yml b/common/src/main/resources/sources/foraging.yml index 3d1945dfc..c018b0720 100644 --- a/common/src/main/resources/sources/foraging.yml +++ b/common/src/main/resources/sources/foraging.yml @@ -93,3 +93,6 @@ sources: block: pink_petals xp: 0.2 support_block: below +tags: + lumberjack_applicable: + - '*' \ No newline at end of file diff --git a/common/src/main/resources/sources/mining.yml b/common/src/main/resources/sources/mining.yml index 5c1aca22b..d57ab7431 100644 --- a/common/src/main/resources/sources/mining.yml +++ b/common/src/main/resources/sources/mining.yml @@ -150,4 +150,26 @@ sources: reinforced_deepslate: block: reinforced_deepslate xp: 125.0 - +tags: + lucky_miner_applicable: + - coal_ore + - nether_quartz_ore + - iron_ore + - redstone_ore + - lapis_ore + - gold_ore + - diamond_ore + - emerald_ore + - nether_gold_ore + - ancient_debris + - copper_ore + - deepslate_coal_ore + - deepslate_iron_ore + - deepslate_copper_ore + - deepslate_gold_ore + - deepslate_redstone_ore + - deepslate_lapis_ore + - deepslate_emerald_ore + - deepslate_diamond_ore + speed_mine_applicable: + - '*' \ No newline at end of file