forked from RocketModPlugins/Kits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandKitRemove.cs
More file actions
68 lines (60 loc) · 2.02 KB
/
Copy pathCommandKitRemove.cs
File metadata and controls
68 lines (60 loc) · 2.02 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Rocket.API;
using Rocket.Core.Logging;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using System.Collections.Generic;
using System.Linq;
namespace fr34kyn01535.Kits
{
public class CommandKitRemove : IRocketCommand
{
public string Help
{
get { return "Removes a kit"; }
}
public string Name
{
get { return "kitremove"; }
}
public string Syntax
{
get { return "<kitName>"; }
}
public bool RunFromConsole
{
get { return false; }
}
public System.Collections.Generic.List<string> Aliases => new System.Collections.Generic.List<string> { "removekit","kitdelete","deletekit" };
public AllowedCaller AllowedCaller
{
get { return Rocket.API.AllowedCaller.Player; }
}
public List<string> Permissions
{
get
{
return new List<string>() { "kits.kitremove" };
}
}
public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
if (command.Length < 1)
{
UnturnedChat.Say(caller, Kits.Instance.Translations.Instance.Translate("command_kit_invalid_parameter"));
throw new WrongUsageOfCommandException(caller, this);
}
int kitX = Kits.Instance.Configuration.Instance.Kits.FindIndex(k => k.Name.ToLower() == command[0].ToLower());
if(kitX==-1)
{
UnturnedChat.Say(caller, Kits.Instance.Translations.Instance.Translate("command_kitdel_exists", command[0]));
return;
}
Kits.Instance.Configuration.Instance.Kits.RemoveAt(kitX);
UnturnedChat.Say(caller, Kits.Instance.Translations.Instance.Translate("command_kitdel_success", command[0]));
Kits.Instance.Configuration.Save();
}
}
}