-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLangCommand.cs
44 lines (36 loc) · 1.34 KB
/
LangCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Rocket.API;
using Steamworks;
using System.Collections.Generic;
using System.Linq;
using static SMultiLangTranslations.Utils;
using Color = UnityEngine.Color;
using IRP = Rocket.API.IRocketPlayer;
namespace SMultiLangTranslations
{
public class LangCommand : MultiLangRocketCommand
{
public override AllowedCaller AllowedCaller => AllowedCaller.Both;
public override string Name => "lang";
public override string Help => "Changes translation language of player.";
public override string Syntax => "";
public override List<string> Aliases => new List<string> { "language" };
public override List<string> Permissions => new List<string> { Name };
public override void Execute(IRP caller, string[] args)
{
var message = Translate(caller, LangError);
var color = Color.yellow;
string lang;
var id = caller.GetId();
if (args.Length == 1 && (lang = args[0]).All(x => char.IsLetter(x)))
{
conf.SetLanguage(id, lang);
message = Translate(lang, LangChanged, lang);
color = Color.green;
}
caller.Say(message, color);
}
internal const string
LangChanged = nameof(LangChanged),
LangError = nameof(LangError);
}
}