forked from sharkbound/MessageAnnouncer
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTextCommandProvider.cs
54 lines (45 loc) · 1.42 KB
/
TextCommandProvider.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
45
46
47
48
49
50
51
52
53
54
using System.Collections.Generic;
using System.Linq;
using Rocket.API;
using Rocket.API.Commands;
using Rocket.API.Plugins;
namespace fr34kyn01535.MessageAnnouncer
{
public class TextCommandProvider : ICommandProvider
{
private readonly IPluginManager _pluginManager;
public TextCommandProvider(IPluginManager pluginManager)
{
_pluginManager = pluginManager;
}
public string ServiceName => "TextCommands";
public ILifecycleObject GetOwner(ICommand command)
{
return _pluginManager.GetPlugin("MessageAnnouncer");
}
public void Init()
{
}
public void Rebuild()
{
_commands.Clear();
}
private readonly List<ICommand> _commands = new List<ICommand>();
public IEnumerable<ICommand> Commands
{
get
{
var owner = (MessageAnnouncerPlugin)GetOwner(null);
if (!owner.IsAlive)
return new List<ICommand>();
foreach (var cmd in owner.ConfigurationInstance.TextCommands)
{
if (_commands.Any(c => c.Name.Equals(cmd.Name)))
continue;
_commands.Add(new RocketTextCommand(cmd.Name, cmd.Help, cmd.Permission, cmd.Lines.ToList()));
}
return _commands;
}
}
}
}