forked from ClassiCube/MCGalaxy-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PluginNoTP.cs
53 lines (42 loc) · 1.59 KB
/
PluginNoTP.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 System;
using MCGalaxy;
using MCGalaxy.Events.PlayerEvents;
namespace PluginNoTP {
public sealed class Core : Plugin_Simple {
public override string creator { get { return "Not UnknownShadow200"; } }
public override string name { get { return "NoTp"; } }
public override string MCGalaxy_Version { get { return "1.9.1.2"; } }
public override void Load(bool startup) {
OnPlayerCommandEvent.Register(OnPlayerCommand, Priority.Low);
}
public override void Unload(bool shutdown) {
OnPlayerCommandEvent.Unregister(OnPlayerCommand);
}
static bool OnGameMap(string map) {
return map.CaselessStarts("zs");
}
void OnPlayerCommand(Player p, string cmd, string args, CommandData data) {
cmd = cmd.ToLower();
if (!(cmd == "tp" || cmd == "teleport" || cmd == "tpa" || cmd == "spawn")) return;
if (OnGameMap(p.level.name)) {
p.Message("You cannot use that command in this gamemode.");
p.cancelcommand = true;
return;
}
if (cmd == "spawn") return; // don't do player check for spawn
string[] bits = args.SplitSpaces();
if (bits.Length > 1) return; // Don't want to do /tp x y z
// don't want to intercept /tpaccept and /tpdeny
if (cmd == "tpa" && (bits[0].CaselessEq("accept") || bits[0].CaselessEq("deny"))) return;
Player who = PlayerInfo.FindMatches(p, bits[0]);
if (who == null) {
p.cancelcommand = true; return; // Don't want double 'Player not found' message
}
if (OnGameMap(who.level.name)) {
p.Message("You cannot teleport to someone in that gamemode.");
p.cancelcommand = true;
return;
}
}
}
}