mirror of
https://github.com/nulli0n/ExcellentEnchants-spigot.git
synced 2024-11-26 12:15:28 +01:00
Enchants fixes
This commit is contained in:
parent
6b0f9cdc43
commit
2e4d9b45b7
@ -433,5 +433,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
||||
@Override
|
||||
public void consumeCharges(@NotNull ItemStack item) {
|
||||
EnchantManager.consumeEnchantmentCharges(item, this);
|
||||
EnchantManager.updateEnchantmentsDisplay(item);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ public class Config {
|
||||
Set.of("enchant_name", "other_enchant"),
|
||||
"A list of enchantments, that will be disabled and removed from the game (server).",
|
||||
"Enchantment names are the same as enchantment file name in /enchants/ folder. ! Must be in lower_case !",
|
||||
"Example: To disable 'Explosive Arrows' you need to add 'explosive_arrows' here.");
|
||||
"Example: To disable 'Explosive Arrows' you need to add 'explosive_arrows' here.")
|
||||
.mapReader(set -> set.stream().map(String::toLowerCase).collect(Collectors.toSet()));
|
||||
|
||||
public static final JOption<Map<String, Set<String>>> ENCHANTMENTS_DISABLED_IN_WORLDS = new JOption<Map<String, Set<String>>>("Enchantments.Disabled_In_Worlds",
|
||||
(cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> k, worldName -> cfg.getStringSet(path + "." + worldName))),
|
||||
|
@ -226,6 +226,7 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
|
||||
lore.add(0, enchant.getNameFormatted(level, getEnchantmentCharges(meta, enchant)));
|
||||
});
|
||||
}
|
||||
else sizeReal = 0;
|
||||
|
||||
meta.setLore(lore);
|
||||
PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal);
|
||||
|
@ -132,6 +132,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant,
|
||||
for (LivingEntity entity : this.getEntities()) {
|
||||
EnchantManager.getEquippedEnchants(entity, EnchantRegrowth.class).forEach((item, enchants) -> {
|
||||
enchants.forEach((enchant, level) -> {
|
||||
if (enchant.isOutOfCharges(item)) return;
|
||||
if (enchant.onTrigger(entity, item, level)) {
|
||||
enchant.consumeCharges(item);
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan
|
||||
for (LivingEntity entity : this.getEntities()) {
|
||||
EnchantManager.getEquippedEnchants(entity, EnchantSaturation.class).forEach((item, enchants) -> {
|
||||
enchants.forEach((enchant, level) -> {
|
||||
if (enchant.isOutOfCharges(item)) return;
|
||||
if (enchant.onTrigger(entity, item, level)) {
|
||||
enchant.consumeCharges(item);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.utils.EffectUtil;
|
||||
@ -44,16 +45,13 @@ public class EnchantSurprise extends PotionEnchant implements Chanced, CombatEnc
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffectType getEffectType() {
|
||||
return Rnd.get(PotionEffectType.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
|
||||
if (!this.isAvailableToUse(damager)) return false;
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
if (!this.addEffect(victim, level)) return false;
|
||||
|
||||
PotionEffect effect = new PotionEffect(Rnd.get(PotionEffectType.values()), this.getEffectDuration(level), Math.max(0, this.getEffectAmplifier(level) - 1), false, false);
|
||||
if (!victim.addPotionEffect(effect)) return false;
|
||||
|
||||
if (this.hasVisualEffects()) {
|
||||
EffectUtil.playEffect(victim.getEyeLocation(), Particle.SPELL_WITCH, "", 0.25, 0.25, 0.25, 0.1f, 30);
|
||||
|
Loading…
Reference in New Issue
Block a user