Added config option for mobs ignoring player during the grace period.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -12,8 +13,10 @@ public class OnLivingSetAttackTargetEvent {
|
||||
public void LivingSetAttackTargetEvent(LivingSetAttackTargetEvent event) {
|
||||
if (!(event.getTarget() instanceof Player target)) { return; }
|
||||
|
||||
if (LoginProtection.protected_players.getPlayer(target.getUUID()) == null) { return; }
|
||||
if (!Config.MAIN_IGNORE_PLAYER_ENABLED.get()) { 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);
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ public class Config {
|
||||
public static ForgeConfigSpec SERVER_CONFIG;
|
||||
|
||||
public static ForgeConfigSpec.BooleanValue POST_GRACE_ENABLED;
|
||||
public static ForgeConfigSpec.BooleanValue POST_GRACE_IGNORE_PLAYER_ENABLED;
|
||||
public static ForgeConfigSpec.IntValue POST_GRACE_DURATION;
|
||||
public static ForgeConfigSpec.BooleanValue POST_DROWN_ENABLED;
|
||||
public static ForgeConfigSpec.BooleanValue POST_WATER_ENABLED;
|
||||
@ -42,6 +43,9 @@ public class Config {
|
||||
POST_GRACE_DURATION = builder
|
||||
.comment("Grace period duration in seconds.")
|
||||
.defineInRange("graceDuration", 10, 1, Integer.MAX_VALUE/40);
|
||||
POST_GRACE_IGNORE_PLAYER_ENABLED = builder
|
||||
.comment("Whether mobs will ignore a player during their grace period.")
|
||||
.define("graceIgnorePlayerEnabled", true);
|
||||
builder.pop();
|
||||
builder.push("water_protection");
|
||||
POST_DROWN_ENABLED = builder
|
||||
|
||||
Reference in New Issue
Block a user