mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Added lazy health fix
This commit is contained in:
parent
acadaf7371
commit
2e6412f8b7
@ -23,6 +23,7 @@ import com.willfp.ecoenchants.enchantments.support.obtaining.EnchantingListeners
|
||||
import com.willfp.ecoenchants.enchantments.support.obtaining.LootPopulator;
|
||||
import com.willfp.ecoenchants.enchantments.support.obtaining.VillagerListeners;
|
||||
import com.willfp.ecoenchants.enchantments.util.ItemConversions;
|
||||
import com.willfp.ecoenchants.enchantments.util.LazyHealthFixListener;
|
||||
import com.willfp.ecoenchants.enchantments.util.TimedRunnable;
|
||||
import com.willfp.ecoenchants.enchantments.util.WatcherTriggers;
|
||||
import com.willfp.ecoenchants.integrations.mythicmobs.MythicMobsManager;
|
||||
@ -158,7 +159,8 @@ public class EcoEnchantsPlugin extends LibReforgePlugin {
|
||||
new VillagerListeners(this),
|
||||
new ItemConversions(this),
|
||||
new CustomEnchantEnableListeners(this),
|
||||
new CustomEcoEnchantRequirementListeners(this)
|
||||
new CustomEcoEnchantRequirementListeners(this),
|
||||
new LazyHealthFixListener(this)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.willfp.ecoenchants.enchantments.util;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LazyHealthFixListener extends PluginDependent<EcoPlugin> implements Listener {
|
||||
public LazyHealthFixListener(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(@NotNull final PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.getHealth() >= 19.0) {
|
||||
this.getPlugin().getScheduler().runLater(3, () -> player.setHealth(
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user