Renamed OnLivingSetAttackTargetEvent.java to OnLivingSetAttackTargetEventHandler.java.

This commit is contained in:
2021-09-29 18:46:36 +01:00
parent ac7594b2eb
commit 24ed48df22
2 changed files with 2 additions and 2 deletions

View File

@ -0,0 +1,23 @@
package com.micle.loginprotection.events;
import com.micle.loginprotection.LoginProtection;
import com.micle.loginprotection.data.ProtectedPlayer;
import com.micle.loginprotection.setup.Config;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class OnLivingSetAttackTargetEventHandler {
@SubscribeEvent
public void LivingSetAttackTargetEvent(LivingSetAttackTargetEvent event) {
if (!(event.getTarget() instanceof Player target)) { return; }
ProtectedPlayer player = LoginProtection.protected_players.getPlayer(target.getUUID());
if (player == null) { return; }
if (player.isLoading() && !Config.MAIN_IGNORE_PLAYER_ENABLED.get()) { return; }
if (!player.isLoading() && !Config.POST_GRACE_IGNORE_PLAYER_ENABLED.get()) { return; }
((Mob) event.getEntityLiving()).setTarget(null);
}
}