-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
86 lines (78 loc) · 2.6 KB
/
Program.cs
File metadata and controls
86 lines (78 loc) · 2.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
namespace Oxide.Plugins
{
[Info("MessagePlugin", "Royboot", "0.1.0")]
[Description("Makes epic stuff happen")]
class MessagePlugin : CovalencePlugin
{
private static PluginConfig? _config;
private readonly List<float> _intervals = _config.Intervals; // 3600 seconds = 1 hour
private readonly List<string> _colors = _config.Colors;
private readonly List<string> _messages = _config.Messages;
private void Init()
{
timer.Every(_intervals[0], () =>
{
Puts("Message plugin enabled.");
BroadcastWipeMessage(_messages,_colors);
});
}
private void BroadcastWipeMessage(List<string> messages,List<string> colors)
{
const string closingTag = "</color>";
List<string> finalMessages = new List<string>();
for (int i = 0; i < messages.Count; i++)
{
if (i < colors.Count)
{
string colorTag = "<color=#" + colors[i] + ">";
finalMessages.Add(colorTag+messages[i]+closingTag);
}
}
foreach (var message in finalMessages)
{
server.Broadcast(message);
}
}
protected override void LoadConfig()
{
base.LoadConfig();
_config= Config.ReadObject<PluginConfig>();
if (_config == null)
{
PrintWarning("Configuration file is missing or invalid. Loading default settings.");
LoadDefaultConfig();
}
}
protected override void LoadDefaultConfig()
{
Config.WriteObject(GetDefaultConfig(), true);
}
private PluginConfig GetDefaultConfig()
{
return new PluginConfig
{
Messages = new List<string>()
{
"[Wipe Reminder] Server wipes every Friday at 5PM EST!",
"Join our Discord: <u><size=16>https://discord.gg/ZnEVyCtCQv</size></u>",
},
Colors = new List<string>()
{
"<color=#ffa500>",
"<color=#00ffff>",
},
Intervals = new List<float>()
{
3600f,
}
};
}
}
class PluginConfig
{
public List<string> Messages { get; set; }
public List<string> Colors = new List<string>();
public List<float> Intervals;
}
}