-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathCmdAnnounce.cs
56 lines (47 loc) · 2.44 KB
/
CmdAnnounce.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
using System;
using MCGalaxy;
namespace MCGalaxy.Commands.CPE {
public sealed class CmdAnnounce : Command2 {
public override string name { get { return "Announce"; } }
public override string shortcut { get { return "ann"; } }
public override string type { get { return "other"; } }
public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Operator, "can announce messages to the level they are in."),
new CommandPerm(LevelPermission.Admin, "can announce messages to the whole server.") }; }
}
public override void Use(Player p, string message, CommandData data) {
string[] args = message.SplitSpaces(2);
if (args[0].Length > 0) {
if (args[0].CaselessEq("level") || args[0].CaselessEq("global")) {
if (args[0].CaselessEq("level")) {
if (args[1].Length > 0) {
if (!HasExtraPerm(p, data.Rank, 1)) return;
foreach (Player pl in PlayerInfo.Online.Items) {
if (pl.level != p.level) continue;
pl.SendCpeMessage(CpeMessageType.Announcement, args[1]);
}
} else { Help(p); }
}
else if (args[0].CaselessEq("global")) {
if (args[1].Length > 0) {
if (!HasExtraPerm(p, data.Rank, 2)) return;
foreach (Player pl in PlayerInfo.Online.Items) {
pl.SendCpeMessage(CpeMessageType.Announcement, args[1]);
}
}
else { Help(p); }
}
}
else {
p.SendCpeMessage(CpeMessageType.Announcement, message);
}
}
else { Help(p); }
}
public override void Help(Player p) {
p.Message("&T/Announce [message] &H- Displays a message on your screen.");
p.Message("&T/Announce level [message] &H- Displays a message on players' screens in your level.");
p.Message("&T/Announce global [message] &H- Displays a message on players' screens globally.");
}
}
}