From 9ef7dcb56d7a7747441b0e294f9b8b3cec9370f6 Mon Sep 17 00:00:00 2001 From: Gegy Date: Sun, 17 Nov 2024 19:42:16 +0100 Subject: [PATCH] Clear kill tracker after dying in Dodgeball --- .../instances/ImmediateRespawnBehavior.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lovetropics/minigames/common/core/game/behavior/instances/ImmediateRespawnBehavior.java b/src/main/java/com/lovetropics/minigames/common/core/game/behavior/instances/ImmediateRespawnBehavior.java index 2063f940f..ce07cf002 100644 --- a/src/main/java/com/lovetropics/minigames/common/core/game/behavior/instances/ImmediateRespawnBehavior.java +++ b/src/main/java/com/lovetropics/minigames/common/core/game/behavior/instances/ImmediateRespawnBehavior.java @@ -25,14 +25,15 @@ import java.util.Map; import java.util.Optional; -public record ImmediateRespawnBehavior(Optional role, Optional respawnAsRole, Optional deathMessage, boolean dropInventory, GameActionList respawnAction, boolean spectateKiller) implements IGameBehavior { +public record ImmediateRespawnBehavior(Optional role, Optional respawnAsRole, Optional deathMessage, boolean dropInventory, GameActionList respawnAction, boolean spectateKiller, boolean clearKillTracker) implements IGameBehavior { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group( PlayerRole.CODEC.optionalFieldOf("role").forGetter(c -> c.role), PlayerRole.CODEC.optionalFieldOf("respawn_as").forGetter(c -> c.respawnAsRole), TemplatedText.CODEC.optionalFieldOf("death_message").forGetter(c -> c.deathMessage), Codec.BOOL.optionalFieldOf("drop_inventory", false).forGetter(c -> c.dropInventory), GameActionList.PLAYER_CODEC.optionalFieldOf("respawn_action", GameActionList.EMPTY).forGetter(c -> c.respawnAction), - Codec.BOOL.optionalFieldOf("spectate_killer", true).forGetter(c -> c.spectateKiller) + Codec.BOOL.optionalFieldOf("spectate_killer", true).forGetter(c -> c.spectateKiller), + Codec.BOOL.optionalFieldOf("clear_kill_tracker", false).forGetter(c -> c.clearKillTracker) ).apply(i, ImmediateRespawnBehavior::new)); @Override @@ -76,6 +77,14 @@ private void respawnPlayer(IGamePhase game, ServerPlayer player, @Nullable Playe player.fallDistance = 0.0f; respawnAction.apply(game, GameActionContext.EMPTY, player); + + if (clearKillTracker) { + for (ServerPlayer otherPlayer : game.participants()) { + if (otherPlayer.getKillCredit() == player) { + otherPlayer.setLastHurtByPlayer(null); + } + } + } } private void sendDeathMessage(IGamePhase game, ServerPlayer player) {