forked from Novex/stardew-remote-control
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathModApi.cs
53 lines (46 loc) · 1.76 KB
/
ModApi.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
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RemoteControl
{
/* Allow other mods to add custom commands
* eg. commandTrigger = dosomething would run functionToRun when someone messages !dosomething
*/
public class ModApi
{
private Action<string, Action<Farmer, string>> addHostCommand;
private Action<string, Action<Farmer, string>> addAdminCommand;
private Action<string, Action<Farmer, string>> addUserCommand;
public ModApi(Action<string, Action<Farmer, string>> addHostCommand, Action<string, Action<Farmer, string>> addAdminCommand, Action<string, Action<Farmer, string>> addUserCommand)
{
this.addHostCommand = addHostCommand;
this.addAdminCommand = addAdminCommand;
this.addUserCommand = addUserCommand;
}
public void AddHostCommand(string commandTrigger, Action<Farmer, string> functionToRun)
{
addHostCommand(commandTrigger, functionToRun);
}
public void AddAdminCommand(string commandTrigger, Action<Farmer, string> functionToRun)
{
addAdminCommand(commandTrigger, functionToRun);
}
public void AddUserCommand(string commandTrigger, Action<Farmer, string> functionToRun)
{
addUserCommand(commandTrigger, functionToRun);
}
// Send a message to everyone
public void publishSystemMessage(string msg)
{
Utilities.publishSystemMessage(msg);
}
// Send a PM
public void publishPrivateMessage(Farmer toPlayer, string msg)
{
Utilities.publishPrivateMessage(toPlayer, msg);
}
}
}