forked from ClassiCube/MCGalaxy-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rainbow.cs
40 lines (34 loc) · 1.37 KB
/
Rainbow.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
using System;
using MCGalaxy;
using MCGalaxy.Network;
using MCGalaxy.Tasks;
namespace PluginRainbowColors
{
public sealed class RainbowPlugin : Plugin
{
public override string creator { get { return "Not UnknownShadow200"; } }
public override string MCGalaxy_Version { get { return "1.9.1.4"; } }
public override string name { get { return "Rainbow"; } }
SchedulerTask task;
public override void Load(bool startup) {
task = Server.MainScheduler.QueueRepeat(RainbowCallback, null,
TimeSpan.FromMilliseconds(100));
}
public override void Unload(bool shutdown) {
if (task == null) return;
Server.MainScheduler.Cancel(task);
}
static string[] colors = { "9400D3", "4B0082", "0000FF", "00FF00", "FFFF00", "FF7F00", "FF0000" };
static int index;
static void RainbowCallback(SchedulerTask task) {
index = (index + 1) % colors.Length;
ColorDesc desc = Colors.ParseHex(colors[index]);
desc.Code = 'r';
Player[] players = PlayerInfo.Online.Items;
foreach (Player p in players) {
if (!p.Supports(CpeExt.TextColors)) continue;
p.Send(Packet.SetTextColor(desc));
}
}
}
}