Fixed EnchantRegrowth and EnchantSaturation

This commit is contained in:
nulli0n 2023-01-26 08:08:43 +06:00
parent 3c0473330e
commit d9d2a84805
2 changed files with 16 additions and 7 deletions

View File

@ -40,25 +40,30 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant,
public EnchantRegrowth(@NotNull ExcellentEnchants plugin) {
super(plugin, ID, EnchantPriority.MEDIUM);
this.task = new Task(plugin);
this.task.start();
}
@Override
public void loadConfig() {
super.loadConfig();
this.healInterval = JOption.create("Settings.Heal.Interval", 100,
"How often (in seconds) enchantment will have effect?").read(cfg);
"How often (in ticks) enchantment will have effect? 1 second = 20 ticks.").read(cfg);
this.healMinHealth = EnchantScaler.read(this, "Settings.Heal.Min_Health", "0.5",
"Minimal entity health for the enchantment to have effect.");
this.healMaxHealth = EnchantScaler.read(this, "Settings.Heal.Max_Health", "20.0",
"Maximal entity health when the enchantment will not heal anymore.");
this.healAmount = EnchantScaler.read(this, "Settings.Heal.Amount", "0.25",
"Amount of hearts to be restored.");
this.task = new Task(plugin);
this.task.start();
}
@Override
public void clear() {
this.stopTask();
}
private void stopTask() {
if (this.task != null) {
this.task.stop();
this.task = null;

View File

@ -35,24 +35,28 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan
public EnchantSaturation(@NotNull ExcellentEnchants plugin) {
super(plugin, ID, EnchantPriority.MEDIUM);
this.task = new Task(plugin);
this.task.start();
}
@Override
public void loadConfig() {
super.loadConfig();
this.saturationInterval = JOption.create("Settings.Saturation.Interval", 100,
"How often (in seconds) enchantment will have effect?").read(cfg);
"How often (in ticks) enchantment will have effect? 1 second = 20 ticks.").read(cfg);
this.saturationAmount = EnchantScaler.read(this, "Settings.Saturation.Amount", Placeholders.ENCHANTMENT_LEVEL,
"Amount of food points to restore.");
this.saturationMaxFoodLevel = EnchantScaler.read(this, "Settings.Saturation.Max_Food_Level", "20",
"Maximal player's food level for the enchantment to stop feeding them.");
this.task = new Task(plugin);
this.task.start();
}
@Override
public void clear() {
this.stopTask();
}
private void stopTask() {
if (this.task != null) {
this.task.stop();
this.task = null;