mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-28 19:11:53 +01:00
Only prevent AFK heal, if freeze player is enabled.
This commit is contained in:
parent
dca88382ab
commit
9af6bdb1d6
@ -188,6 +188,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
|
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
|
||||||
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
|
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
|
||||||
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
||||||
|
pm.registerEvent(Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Lowest, this);
|
||||||
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
|
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
|
||||||
|
|
||||||
jail = new Jail(this);
|
jail = new Jail(this);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
@ -17,6 +19,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class EssentialsEntityListener extends EntityListener
|
public class EssentialsEntityListener extends EntityListener
|
||||||
{
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||||
private final IEssentials ess;
|
private final IEssentials ess;
|
||||||
|
|
||||||
public EssentialsEntityListener(IEssentials ess)
|
public EssentialsEntityListener(IEssentials ess)
|
||||||
@ -94,6 +97,7 @@ public class EssentialsEntityListener extends EntityListener
|
|||||||
@Override
|
@Override
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||||
{
|
{
|
||||||
|
LOGGER.log(Level.INFO, "Getting hungry...");
|
||||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -103,12 +107,10 @@ public class EssentialsEntityListener extends EntityListener
|
|||||||
@Override
|
@Override
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isAfk())
|
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
|
||||||
{
|
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||||
if (event.getRegainReason() == RegainReason.SATIATED)
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user