diff --git a/Feli.OpenMod.Teleporting/Services/TeleportsManager.cs b/Feli.OpenMod.Teleporting/Services/TeleportsManager.cs index ea4094c..b1c29b0 100644 --- a/Feli.OpenMod.Teleporting/Services/TeleportsManager.cs +++ b/Feli.OpenMod.Teleporting/Services/TeleportsManager.cs @@ -256,16 +256,29 @@ private async Task ValidateRequest(Tuple reque if (!_configuration.GetSection("tpaOptions:combat:allow").Get()) { - var combat = GetLastCombat(sender); + var senderCombat = GetLastCombat(sender); + var targetCombat = GetLastCombat(target); - var combatTime = combat.AddSeconds(_configuration.GetSection("tpaOptions:combat:time").Get()); + var time = _configuration.GetSection("teleportOptions:combat:time").Get(); - if (combatTime > DateTime.Now) + var senderCombatTime = senderCombat.AddSeconds(time); + var targetCombatTime = targetCombat.AddSeconds(time); + + if (senderCombatTime > DateTime.Now) { - var waitTime = (combatTime - DateTime.Now).TotalSeconds; + var waitTime = (senderCombatTime - DateTime.Now).TotalSeconds; + + await Say(sender, _stringLocalizer["tpaValidation:combat:self", Math.Round(waitTime)]); + await Say(target, _stringLocalizer["tpaValidation:combat:other", sender.DisplayName]); + + return false; + } + else if (targetCombatTime > DateTime.Now) + { + var waitTime = (targetCombatTime - DateTime.Now).TotalSeconds; - await Say(sender, _stringLocalizer["tpaValidation:combat:sender", Math.Round(waitTime)]); - await Say(target, _stringLocalizer["tpaValidation:combat:target", sender.DisplayName]); + await Say(target, _stringLocalizer["tpaValidation:combat:self", Math.Round(waitTime)]); + await Say(sender, _stringLocalizer["tpaValidation:combat:other", target.DisplayName]); return false; } diff --git a/Feli.OpenMod.Teleporting/translations.yaml b/Feli.OpenMod.Teleporting/translations.yaml index e89d923..6534fdf 100644 --- a/Feli.OpenMod.Teleporting/translations.yaml +++ b/Feli.OpenMod.Teleporting/translations.yaml @@ -41,8 +41,8 @@ tpaValidation: target: "The teleport was cancelled because {0} moved" combat: - sender: "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds" - target: "The teleport was cancelled because {0} is in combat" + self: "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds" + other: "The teleport was cancelled because {0} is in combat" balance: sender: "You dont have enough balance to teleport. Teleport cost: {0}" diff --git a/Feli.RocketMod.Teleporting/Plugin.cs b/Feli.RocketMod.Teleporting/Plugin.cs index 9af42c2..cfb916a 100644 --- a/Feli.RocketMod.Teleporting/Plugin.cs +++ b/Feli.RocketMod.Teleporting/Plugin.cs @@ -23,7 +23,7 @@ protected override void Load() ? new ExperienceEconomyProvider() as IEconomyProvider : new UconomyEconomyProvider(); - Logger.Log($"Teleporting plugin v1.6.2 loaded !"); + Logger.Log($"Teleporting plugin v1.6.3 loaded !"); Logger.Log("Do you want more cool plugins? Join now: https://discord.gg/4FF2548 !"); Logger.Log($"Economy Provider: {EconomyProvider.GetType().Name}"); } @@ -62,8 +62,8 @@ protected override void Unload() {"TpaValidation:Leave", "The teleport was cancelled because {0} left the server"}, {"TpaValidation:Move:Sender", "The teleport was cancelled because your moved"}, {"TpaValidation:Move:Target", "The teleport was cancelled because {0} moved"}, - {"TpaValidation:Combat:Sender", "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds"}, - {"TpaValidation:Combat:Target", "The teleport was cancelled because {0} is in combat"}, + {"TpaValidation:Combat:Selft", "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds"}, + {"TpaValidation:Combat:Other", "The teleport was cancelled because {0} is in combat"}, {"TpaValidation:Balance:Sender", "You dont have enough balance to teleport. Teleport cost: {0}"}, {"TpaValidation:Balance:Target", "The teleport was cancelled because {0} does not have enough balance"}, {"TpaValidation:Dead:Alive", "The teleport was cancelled because {0} is dead" }, diff --git a/Feli.RocketMod.Teleporting/TeleportsManager.cs b/Feli.RocketMod.Teleporting/TeleportsManager.cs index 27cd075..65f6e89 100644 --- a/Feli.RocketMod.Teleporting/TeleportsManager.cs +++ b/Feli.RocketMod.Teleporting/TeleportsManager.cs @@ -223,21 +223,32 @@ private bool ValidateRequest(Tuple request) if (!_configuration.TeleportCombatAllowed) { - var combat = GetLastCombat(sender); + var senderCombat = GetLastCombat(sender); + var targetCombat = GetLastCombat(target); - var combatTime = combat.AddSeconds(_configuration.TeleportCombatTime); + var senderCombatTime = senderCombat.AddSeconds(_configuration.TeleportCombatTime); + var targetCombatTime = targetCombat.AddSeconds(_configuration.TeleportCombatTime); - if (combatTime > DateTime.Now) + if(senderCombatTime > DateTime.Now) { - var waitTime = (combatTime - DateTime.Now).TotalSeconds; + var waitTime = (senderCombatTime - DateTime.Now).TotalSeconds; - Say(sender, _plugin.Translate("TpaValidation:Combat:Sender", Math.Round(waitTime)), _messageColor, _messageIcon); - Say(target, _plugin.Translate("TpaValidation:Combat:Target", sender.DisplayName), _messageColor, _messageIcon); + Say(sender, _plugin.Translate("TpaValidation:Combat:Self", Math.Round(waitTime)), _messageColor, _messageIcon); + Say(target, _plugin.Translate("TpaValidation:Combat:Other", sender.DisplayName), _messageColor, _messageIcon); + + return false; + } + else if(targetCombatTime > DateTime.Now) + { + var waitTime = (targetCombatTime - DateTime.Now).TotalSeconds; + + Say(target, _plugin.Translate("TpaValidation:Combat:Self", Math.Round(waitTime)), _messageColor, _messageIcon); + Say(sender, _plugin.Translate("TpaValidation:Combat:Other", target.DisplayName), _messageColor, _messageIcon); return false; } } - + return true; }