From e7cf94770936b3171ee884a67a878de0319b35e2 Mon Sep 17 00:00:00 2001 From: DiFFoZ <48765566+DiFFoZ@users.noreply.github.com> Date: Sun, 13 Nov 2022 17:08:23 +0700 Subject: [PATCH] Fix `logs:enableDeathLog` disables dummy respawn --- Dummy/Events/DummyDeadEvent.cs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Dummy/Events/DummyDeadEvent.cs b/Dummy/Events/DummyDeadEvent.cs index 317fcbf..6171e14 100644 --- a/Dummy/Events/DummyDeadEvent.cs +++ b/Dummy/Events/DummyDeadEvent.cs @@ -1,18 +1,17 @@ extern alias JetBrainsAnnotations; +using System.Threading.Tasks; using Cysharp.Threading.Tasks; using Dummy.API; +using JetBrainsAnnotations::JetBrains.Annotations; +using Microsoft.Extensions.Configuration; using OpenMod.API.Eventing; using OpenMod.Core.Eventing; -using OpenMod.UnityEngine.Extensions; using OpenMod.Unturned.Players; using OpenMod.Unturned.Players.Life.Events; using OpenMod.Unturned.Users; -using SDG.Unturned; -using System.Threading.Tasks; -using JetBrainsAnnotations::JetBrains.Annotations; using SDG.NetTransport; +using SDG.Unturned; using UnityEngine; -using Microsoft.Extensions.Configuration; namespace Dummy.Events { @@ -36,27 +35,26 @@ public DummyDeadEvent(IDummyProvider dummyProvider, IUnturnedUserDirectory untur [EventListener(Priority = EventListenerPriority.Monitor)] public async Task HandleEventAsync(object? sender, UnturnedPlayerDeathEvent @event) { - if (!m_Configuration.GetValue("logs:enableDeathLog")) - { - return; - } - var dummy = await m_DummyProvider.FindDummyUserAsync(@event.Player.SteamId.m_SteamID); if (dummy == null) { return; } - foreach (var owner in dummy.Owners) + if (m_Configuration.GetValue("logs:enableDeathLog")) { - var player = m_UnturnedUserDirectory.FindUser(owner); - if (player == null) + foreach (var owner in dummy.Owners) { - continue; - } + var player = m_UnturnedUserDirectory.FindUser(owner); + if (player == null) + { + continue; + } - await player.PrintMessageAsync( - $"Dummy {@event.Player.SteamId} has died. Death reason: {@event.DeathCause.ToString().ToLower()}, killer = {@event.Instigator}. Respawning..."); + await player.PrintMessageAsync( + $"Dummy {@event.Player.SteamId} has died. Death reason: {@event.DeathCause.ToString().ToLower()}, killer = {@event.Instigator}. Respawning..."); + } + return; } Revive(dummy.Player).Forget();