ExcellentEnchants-spigot/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/NightVisionEnchant.java

65 lines
2.4 KiB
Java
Raw Normal View History

2024-02-05 00:26:03 +01:00
package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
2024-03-24 13:11:31 +01:00
import su.nightexpress.excellentenchants.ExcellentEnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionData;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
2024-02-05 00:26:03 +01:00
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
2024-03-24 13:11:31 +01:00
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig;
2024-02-05 00:26:03 +01:00
2024-03-24 13:11:31 +01:00
import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*;
public class NightVisionEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant {
2024-02-05 00:26:03 +01:00
public static final String ID = "night_vision";
2024-03-24 13:11:31 +01:00
private PotionSettingsImpl potionSettings;
private PeriodSettingsImpl periodSettings;
2024-02-05 00:26:03 +01:00
2024-03-24 13:11:31 +01:00
public NightVisionEnchant(@NotNull ExcellentEnchantsPlugin plugin, @NotNull File file) {
super(plugin, file);
this.setDescription("Grants permanent " + ENCHANTMENT_POTION_TYPE + " " + ENCHANTMENT_POTION_LEVEL + " effect.");
this.setMaxLevel(1);
this.setRarity(Rarity.VERY_RARE);
2024-02-05 00:26:03 +01:00
}
@Override
2024-03-24 13:11:31 +01:00
protected void loadAdditional(@NotNull FileConfig config) {
this.potionSettings = PotionSettingsImpl.create(this, config, PotionEffectType.NIGHT_VISION, true);
this.periodSettings = PeriodSettingsImpl.create(config);
2024-02-05 00:26:03 +01:00
}
@NotNull
@Override
2024-03-24 13:11:31 +01:00
public PotionSettings getPotionSettings() {
return potionSettings;
2024-02-05 00:26:03 +01:00
}
@NotNull
@Override
2024-03-24 13:11:31 +01:00
public PeriodicSettings getPeriodSettings() {
return periodSettings;
2024-02-05 00:26:03 +01:00
}
@Override
@NotNull
public EnchantmentTarget getCategory() {
return EnchantmentTarget.ARMOR_HEAD;
}
@Override
public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
return this.addEffect(entity, level);
}
}