Skip to content

Commit 5c05252

Browse files
authored
Added in localization for cooldown times
1 parent 4933049 commit 5c05252

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

Recycle.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ private void LoadMessages() {
146146
{ "Denied -> Balloon", youCannot("on a balloon") },
147147
{ "Denied -> Safe Zone", youCannot("in a safe zone") },
148148
{ "Denied -> Hook Denied", "You can't recycle right now" },
149-
{ "Cooldown -> In", "You need to wait {0} before recycling" }
149+
{ "Cooldown -> In", "You need to wait {0} before recycling" },
150+
{ "Timings -> second", "second" },
151+
{ "Timings -> seconds", "seconds" },
152+
{ "Timings -> minute", "minute" },
153+
{ "Timings -> minutes", "minutes" }
150154
}, this);
151155
}
152156

@@ -376,11 +380,11 @@ private int[] GetCooldown(ulong uid) {
376380
return new int[] { diff.Minutes, diff.Seconds };
377381
}
378382

379-
private string CooldownTimesToString(int[] times) {
383+
private string CooldownTimesToString(int[] times, BasePlayer p) {
380384
if (times == null || times.Length != 2) return "";
381-
if (times[0] == 0) return (times[1] == 1 ? "1 second" : times[1] + " seconds");
382-
return ((times[0] > 0 ? times[0] == 1 ? "1 minute" : times[0] + " minutes" : "") + " " +
383-
(times[1] > 0 ? times[1] == 1 ? "1 second" : times[1] + " seconds" : "")).Trim();
385+
int mins = times[0], secs = times[1];
386+
return (mins == 0 ? "" : ("{0} " + this.GetMessage("Timings", mins == 1 ? "minute" : "minutes", p)) +
387+
" {1} " + this.GetMessage("Timings", secs == 1 ? "second" : "seconds", p)).Trim();
384388
}
385389

386390
#endregion
@@ -423,7 +427,7 @@ public bool IsRecycleBox(BaseNetworkable e) {
423427
public bool CanPlayerOpenRecycler(BasePlayer p) {
424428
if (p == null || p.IsDead()) this.PrintToChat(p, this.GetMessage("Denied", "Hook Denied", p));
425429
else if (!this.CanUseRecycler(p.userID) && !this.CanManageRecyclers(p.userID)) this.PrintToChat(p, this.GetMessage("Denied", "Permission", p));
426-
else if (this.Data.Settings.Cooldown > 0 && this.IsOnCooldown(p.userID)) this.PrintToChat(p, this.GetMessage("Cooldown", "In", p), this.CooldownTimesToString(this.GetCooldown(p.userID)));
430+
else if (this.Data.Settings.Cooldown > 0 && this.IsOnCooldown(p.userID)) this.PrintToChat(p, this.GetMessage("Cooldown", "In", p), this.CooldownTimesToString(this.GetCooldown(p.userID), p));
427431
else if (p.IsWounded()) this.PrintToChat(p, this.GetMessage("Denied", "Wounded", p));
428432
else if (!p.CanBuild()) this.PrintToChat(p, this.GetMessage("Denied", "Privilege", p));
429433
else if (this.Data.Settings.RadiationMax > 0 && p.radiationLevel > this.Data.Settings.RadiationMax) this.PrintToChat(p, this.GetMessage("Denied", "Irradiation", p));
@@ -473,4 +477,4 @@ public void RemoveNPC(string id) {
473477

474478
}
475479

476-
}
480+
}

0 commit comments

Comments
 (0)