Renamed OnLivingSetAttackTargetEvent.java to OnLivingSetAttackTargetEventHandler.java.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user