OnLivingSetAttackTargetEventHandler: Checks for new grace states before cancelling event.
This commit is contained in:
@ -11,16 +11,20 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
public class OnLivingSetAttackTargetEventHandler {
|
||||
@SubscribeEvent
|
||||
public void LivingSetAttackTargetEvent(LivingSetAttackTargetEvent event) {
|
||||
if (!(event.getTarget() instanceof Player target)) { return; }
|
||||
if (!(event.getTarget() instanceof Player target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProtectedPlayer player = ProtectedPlayerManager.getPlayer(target.getUUID());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if ((player.getState().equals(ProtectedPlayer.State.JOINING) && Config.Server.LOGIN_IGNORE_PLAYER_ENABLED.get()) ||
|
||||
(player.getState().equals(ProtectedPlayer.State.AFK) && Config.Server.AFK_IGNORE_PLAYER_ENABLED.get()) ||
|
||||
(player.getState().equals(ProtectedPlayer.State.ACTIVE) && player.getGracePeriodTimeRemaining() > 0 &&
|
||||
Config.Server.POST_GRACE_IGNORE_PLAYER_ENABLED.get())) {
|
||||
|
||||
// Check if mob should ignore player
|
||||
if ((player.getState().equals(ProtectedPlayer.State.JOINING) && Config.Server.LOGIN_MOBS_IGNORE_PLAYER.get()) ||
|
||||
(player.getState().equals(ProtectedPlayer.State.AFK) && Config.Server.AFK_MOBS_IGNORE_PLAYER.get()) ||
|
||||
(player.getState().equals(ProtectedPlayer.State.LOGIN_GRACE) && Config.Server.LOGIN_GRACE_MOBS_IGNORE_PLAYER.get()) ||
|
||||
(player.getState().equals(ProtectedPlayer.State.AFK_GRACE) && Config.Server.AFK_GRACE_MOBS_IGNORE_PLAYER.get())) {
|
||||
((Mob) event.getEntityLiving()).setTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user