-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
75 lines (62 loc) · 2.54 KB
/
Plugin.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using MCGalaxy;
using MCGalaxy.Events.PlayerEvents;
using MongoDB.Bson;
using MongoDB.Driver;
public sealed class Bancho : Plugin {
public static BanchoConfig Config = new BanchoConfig();
public static MongoClient Mongo;
public static IMongoDatabase BanchoDB;
public static IMongoCollection<BsonDocument> BanchoPlayers;
public override int build {
get { return 2; }
}
public override string creator {
get { return "siriusmart"; }
}
public override string name {
get { return "Bancho"; }
}
public override string welcome {
get { return "Bancho is now online!"; }
}
public override void Load(bool startup) {
Config.Load();
Mongo = new MongoClient(Config.MongoAddress);
BanchoDB = Mongo.GetDatabase(Config.MongoName);
BanchoPlayers = BanchoDB.GetCollection<BsonDocument>("players");
OnlinePlayers.Init();
Games.OnLoad();
Command.Register(new PartyEntry());
Command.Register(new FriendEntry());
Command.Register(new ChatEntry());
Command.Register(new ChatGlobal());
Command.Register(new ChatLocal());
Command.Register(new ChatParty());
Command.Register(new ChatMsg());
Command.Register(new ChatReply());
Command.Register(new HelpEntry());
OnPlayerConnectEvent.Register(OnlinePlayers.PlayerConnect,
Priority.Critical);
OnPlayerDisconnectEvent.Register(OnlinePlayers.PlayerDisconnect,
Priority.Critical);
OnPlayerChatEvent.Register(OnlinePlayers.Message, Priority.Normal);
OnPlayerSpawningEvent.Register(OnlinePlayers.PlayerSpawn,
Priority.Normal);
}
public override void Unload(bool shutdown) {
Games.OnUnload();
Command.Unregister(Command.Find("party"));
Command.Unregister(Command.Find("friend"));
Command.Unregister(Command.Find("chat"));
Command.Unregister(Command.Find("msg"));
Command.Unregister(Command.Find("reply"));
Command.Unregister(Command.Find("ac"));
Command.Unregister(Command.Find("lc"));
Command.Unregister(Command.Find("help"));
OnPlayerConnectEvent.Unregister(OnlinePlayers.PlayerConnect);
OnPlayerDisconnectEvent.Unregister(OnlinePlayers.PlayerDisconnect);
OnPlayerChatEvent.Unregister(OnlinePlayers.Message);
OnPlayerSpawningEvent.Unregister(OnlinePlayers.PlayerSpawn);
OnlinePlayers.Exit();
}
}