-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoleplayCommands.cs
65 lines (60 loc) · 2.15 KB
/
RoleplayCommands.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
55
56
57
58
59
60
61
62
63
64
65
using PoliceMP.Client.Services.Interfaces;
using PoliceMP.Core.Client;
using PoliceMP.Core.Client.Commands.Interfaces;
using PoliceMP.Core.Client.Communications.Interfaces;
using PoliceMP.Core.Shared;
using PoliceMP.Shared.Constants;
using System.Threading.Tasks;
namespace PoliceMP.Client.Scripts
{
public class RoleplayCommands : Script
{
private readonly IClientCommunicationsManager _comms;
private readonly ILogger<RoleplayCommands> _logger;
private readonly ICommandManager _commands;
private readonly INotificationService _notifications;
public RoleplayCommands(ILogger<RoleplayCommands> logger, ICommandManager commands, IClientCommunicationsManager comms, INotificationService notifications)
{
_logger = logger;
_commands = commands;
_comms = comms;
_notifications = notifications;
}
protected override Task OnStartAsync()
{
_commands.Register("me").HasGreedyArgs().WithHandler((message) =>
{
try
{
if (string.IsNullOrEmpty(message) || message == "" || message == string.Empty)
{
_notifications.Error("Command Error", "/me [Emote Text]");
return;
}
_comms.ToServer(ServerEvents.SendMeCommandToServer, message);
}
catch
{
return;
}
});
_commands.Register("do").HasGreedyArgs().WithHandler((message) =>
{
try
{
if (string.IsNullOrEmpty(message) || message == "" || message == string.Empty)
{
_notifications.Error("Command Error", "/do [Emote Text]");
return;
}
_comms.ToServer(ServerEvents.SendDoCommandToServer, message);
}
catch
{
return;
}
});
return Task.FromResult(0);
}
}
}