Skip to content

Commit 387dc1a

Browse files
committed
Fix target combat
1 parent a9ca787 commit 387dc1a

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

Feli.OpenMod.Teleporting/Services/TeleportsManager.cs

+19-6
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,29 @@ private async Task<bool> ValidateRequest(Tuple<UnturnedUser, UnturnedUser> reque
256256

257257
if (!_configuration.GetSection("tpaOptions:combat:allow").Get<bool>())
258258
{
259-
var combat = GetLastCombat(sender);
259+
var senderCombat = GetLastCombat(sender);
260+
var targetCombat = GetLastCombat(target);
260261

261-
var combatTime = combat.AddSeconds(_configuration.GetSection("tpaOptions:combat:time").Get<double>());
262+
var time = _configuration.GetSection("teleportOptions:combat:time").Get<double>();
262263

263-
if (combatTime > DateTime.Now)
264+
var senderCombatTime = senderCombat.AddSeconds(time);
265+
var targetCombatTime = targetCombat.AddSeconds(time);
266+
267+
if (senderCombatTime > DateTime.Now)
264268
{
265-
var waitTime = (combatTime - DateTime.Now).TotalSeconds;
269+
var waitTime = (senderCombatTime - DateTime.Now).TotalSeconds;
270+
271+
await Say(sender, _stringLocalizer["tpaValidation:combat:self", Math.Round(waitTime)]);
272+
await Say(target, _stringLocalizer["tpaValidation:combat:other", sender.DisplayName]);
273+
274+
return false;
275+
}
276+
else if (targetCombatTime > DateTime.Now)
277+
{
278+
var waitTime = (targetCombatTime - DateTime.Now).TotalSeconds;
266279

267-
await Say(sender, _stringLocalizer["tpaValidation:combat:sender", Math.Round(waitTime)]);
268-
await Say(target, _stringLocalizer["tpaValidation:combat:target", sender.DisplayName]);
280+
await Say(target, _stringLocalizer["tpaValidation:combat:self", Math.Round(waitTime)]);
281+
await Say(sender, _stringLocalizer["tpaValidation:combat:other", target.DisplayName]);
269282

270283
return false;
271284
}

Feli.OpenMod.Teleporting/translations.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ tpaValidation:
4141
target: "The teleport was cancelled because {0} moved"
4242

4343
combat:
44-
sender: "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds"
45-
target: "The teleport was cancelled because {0} is in combat"
44+
self: "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds"
45+
other: "The teleport was cancelled because {0} is in combat"
4646

4747
balance:
4848
sender: "You dont have enough balance to teleport. Teleport cost: {0}"

Feli.RocketMod.Teleporting/Plugin.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected override void Load()
2323
? new ExperienceEconomyProvider() as IEconomyProvider
2424
: new UconomyEconomyProvider();
2525

26-
Logger.Log($"Teleporting plugin v1.6.2 loaded !");
26+
Logger.Log($"Teleporting plugin v1.6.3 loaded !");
2727
Logger.Log("Do you want more cool plugins? Join now: https://discord.gg/4FF2548 !");
2828
Logger.Log($"Economy Provider: {EconomyProvider.GetType().Name}");
2929
}
@@ -62,8 +62,8 @@ protected override void Unload()
6262
{"TpaValidation:Leave", "The teleport was cancelled because {0} left the server"},
6363
{"TpaValidation:Move:Sender", "The teleport was cancelled because your moved"},
6464
{"TpaValidation:Move:Target", "The teleport was cancelled because {0} moved"},
65-
{"TpaValidation:Combat:Sender", "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds"},
66-
{"TpaValidation:Combat:Target", "The teleport was cancelled because {0} is in combat"},
65+
{"TpaValidation:Combat:Selft", "The teleport was cancelled because you are in combat. The combat mode expires in {0} seconds"},
66+
{"TpaValidation:Combat:Other", "The teleport was cancelled because {0} is in combat"},
6767
{"TpaValidation:Balance:Sender", "You dont have enough balance to teleport. Teleport cost: {0}"},
6868
{"TpaValidation:Balance:Target", "The teleport was cancelled because {0} does not have enough balance"},
6969
{"TpaValidation:Dead:Alive", "The teleport was cancelled because {0} is dead" },

Feli.RocketMod.Teleporting/TeleportsManager.cs

+18-7
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,32 @@ private bool ValidateRequest(Tuple<UnturnedPlayer, UnturnedPlayer> request)
223223

224224
if (!_configuration.TeleportCombatAllowed)
225225
{
226-
var combat = GetLastCombat(sender);
226+
var senderCombat = GetLastCombat(sender);
227+
var targetCombat = GetLastCombat(target);
227228

228-
var combatTime = combat.AddSeconds(_configuration.TeleportCombatTime);
229+
var senderCombatTime = senderCombat.AddSeconds(_configuration.TeleportCombatTime);
230+
var targetCombatTime = targetCombat.AddSeconds(_configuration.TeleportCombatTime);
229231

230-
if (combatTime > DateTime.Now)
232+
if(senderCombatTime > DateTime.Now)
231233
{
232-
var waitTime = (combatTime - DateTime.Now).TotalSeconds;
234+
var waitTime = (senderCombatTime - DateTime.Now).TotalSeconds;
233235

234-
Say(sender, _plugin.Translate("TpaValidation:Combat:Sender", Math.Round(waitTime)), _messageColor, _messageIcon);
235-
Say(target, _plugin.Translate("TpaValidation:Combat:Target", sender.DisplayName), _messageColor, _messageIcon);
236+
Say(sender, _plugin.Translate("TpaValidation:Combat:Self", Math.Round(waitTime)), _messageColor, _messageIcon);
237+
Say(target, _plugin.Translate("TpaValidation:Combat:Other", sender.DisplayName), _messageColor, _messageIcon);
238+
239+
return false;
240+
}
241+
else if(targetCombatTime > DateTime.Now)
242+
{
243+
var waitTime = (targetCombatTime - DateTime.Now).TotalSeconds;
244+
245+
Say(target, _plugin.Translate("TpaValidation:Combat:Self", Math.Round(waitTime)), _messageColor, _messageIcon);
246+
Say(sender, _plugin.Translate("TpaValidation:Combat:Other", target.DisplayName), _messageColor, _messageIcon);
236247

237248
return false;
238249
}
239250
}
240-
251+
241252
return true;
242253
}
243254

0 commit comments

Comments
 (0)