-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cs
55 lines (48 loc) · 2.36 KB
/
Main.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
using SuchByte.MacroDeck.ActionButton;
using SuchByte.MacroDeck.GUI.CustomControls;
using SuchByte.MacroDeck.GUI;
using SuchByte.MacroDeck.Plugins;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace hashashin.FxCommands
{
public class Main : MacroDeckPlugin
{
public static MacroDeckPlugin Instance { get; internal set; }
// Optional; If your plugin can be configured, set to "true". It'll make the "Configure" button appear in the package manager.
public override bool CanConfigure => false;
// Gets called when the plugin is loaded
public override void Enable()
{
this.Actions = new List<PluginAction>{
// add the instances of your actions here
new FxCommands(),
};
}
public class FxCommands : PluginAction
{
private ConnectionManager connectionManager;
// The name of the action
public override string Name => "FxCommand";
// A short description what the action can do
public override string Description => "Send a command to the Fivem client console, do not add the / at the beginning";
// Optional; Add if this action can be configured. This will make the ActionConfigurator calling GetActionConfigurator();
public override bool CanConfigure => true;
// Optional; Add if you added CanConfigure; Gets called when the action can be configured and the action got selected in the ActionSelector. You need to return a user control with the "ActionConfigControl" class as base class
public override ActionConfigControl GetActionConfigControl(ActionConfigurator actionConfigurator)
{
return new FxCommandsActionConfWnd(this);
}
// Gets called when the action is triggered by a button press or an event
public override void Trigger(string clientId, ActionButton actionButton)
{
JObject configurationObject = JObject.Parse(this.Configuration);
var command = configurationObject["command"].ToString();
connectionManager = new ConnectionManager();
connectionManager.InitializeClients();
connectionManager.SendMessage(command);
connectionManager.Dispose();
}
}
}
}