-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdocs_core.json
More file actions
1444 lines (1444 loc) · 71.3 KB
/
docs_core.json
File metadata and controls
1444 lines (1444 loc) · 71.3 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"Hooks": [
{
"Type": 0,
"Name": "OnFrame",
"HookName": "OnFrame",
"HookParameters": {
"args": "object[]"
},
"ReturnBehavior": 0,
"TargetType": "CSharpExtension",
"Category": "Server",
"HookDescription": "Called each frame",
"MethodData": {
"MethodName": "OnFrame",
"ReturnType": "void",
"Arguments": {
"delta": "float"
}
},
"CodeAfterInjection": "private void OnFrame(float delta)\r\n{\r\n\tobject[] args = new object[] { delta };\r\n\tforeach (System.Collections.Generic.KeyValuePair<string, Core.Plugins.Plugin> kv in loader.LoadedPlugins)\r\n\t{\r\n\t\tCSharpPlugin plugin = kv.Value as CSharpPlugin;\r\n\t\tif (plugin != null && plugin.HookedOnFrame)\r\n\t\t{\r\n\t\t\tplugin.CallHook(\"OnFrame\", args);\r\n\t\t}\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "Loaded",
"HookName": "Loaded",
"HookParameters": {},
"ReturnBehavior": 0,
"TargetType": "CSharpPlugin",
"Category": "Server",
"HookDescription": "Called when a plugin has finished loading\r\nOther plugins may or may not be present, dependant on load order",
"MethodData": {
"MethodName": "HandleAddedToManager",
"ReturnType": "void",
"Arguments": {}
},
"CodeAfterInjection": "public override void HandleAddedToManager(PluginManager manager)\r\n{\r\n\tbase.HandleAddedToManager(manager);\r\n\r\n\tif (Filename != null)\r\n\t{\r\n\t\tWatcher.AddMapping(Name);\r\n\t}\r\n\r\n\tManager.OnPluginAdded += OnPluginLoaded;\r\n\tManager.OnPluginRemoved += OnPluginUnloaded;\r\n\r\n\tforeach (var member in pluginReferenceMembers)\r\n\t{\r\n\t\tif (member.Value.MemberType == MemberTypes.Property)\r\n\t\t{\r\n\t\t\t((PropertyInfo)member.Value).SetValue(this, manager.GetPlugin(member.Key), null);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t((FieldInfo)member.Value).SetValue(this, manager.GetPlugin(member.Key));\r\n\t\t}\r\n\t}\r\n\ttry\r\n\t{\r\n\t\tOnCallHook(\"Loaded\", null);\r\n\t}\r\n\tcatch (Exception ex)\r\n\t{\r\n\t\tInterface.Oxide.LogException($\"Failed to initialize plugin '{Name} v{Version}'\", ex);\r\n\t\tLoader.PluginErrors[Name] = ex.Message;\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "Unload",
"HookName": "Unload",
"HookParameters": {},
"ReturnBehavior": 0,
"TargetType": "CSharpPlugin",
"Category": "Server",
"HookDescription": "Called when a plugin is being unloaded",
"MethodData": {
"MethodName": "HandleRemovedFromManager",
"ReturnType": "void",
"Arguments": {
"manager": "PluginManager"
}
},
"CodeAfterInjection": "public override void HandleRemovedFromManager(PluginManager manager)\r\n{\r\n\tif (IsLoaded)\r\n\t{\r\n\t\tCallHook(\"Unload\", null);\r\n\t}\r\n\r\n\tWatcher.RemoveMapping(Name);\r\n\r\n\tManager.OnPluginAdded -= OnPluginLoaded;\r\n\tManager.OnPluginRemoved -= OnPluginUnloaded;\r\n\r\n\tforeach (var member in pluginReferenceMembers)\r\n\t{\r\n\t\tif (member.Value.MemberType == MemberTypes.Property)\r\n\t\t{\r\n\t\t\t((PropertyInfo)member.Value).SetValue(this, null, null);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t((FieldInfo)member.Value).SetValue(this, null);\r\n\t\t}\r\n\t}\r\n\r\n\tbase.HandleRemovedFromManager(manager);\r\n}"
},
{
"Type": 0,
"Name": "OnPermissionRegistered",
"HookName": "OnPermissionRegistered",
"HookParameters": {
"name": "string",
"owner": "Plugin"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a permission has been registered",
"MethodData": {
"MethodName": "RegisterPermission",
"ReturnType": "void",
"Arguments": {
"permission": "permission",
"owner": "Plugin"
}
},
"CodeAfterInjection": "public void RegisterPermission(c permission, Plugin owner)\r\n{\r\n\tif (string.IsNullOrEmpty(permission))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tif (PermissionExists(permission))\r\n\t{\r\n\t\tInterface.Oxide.LogWarning(\"Duplicate permission registered '{0}' (by plugin '{1}')\", permission, owner.Title);\r\n\t\treturn;\r\n\t}\r\n\tif (!registeredPermissions.TryGetValue(owner, out HashSet<string> set))\r\n\t{\r\n\t\tset = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\r\n\t\tregisteredPermissions.Add(owner, set);\r\n\t\towner.OnRemovedFromManager.Add(owner_OnRemovedFromManager);\r\n\t}\r\n\tset.Add(permission);\r\n\tInterface.CallHook(\"OnPermissionRegistered\", permission, owner);\r\n\tif (!permission.StartsWith($\"{owner.Name}.\", StringComparison.OrdinalIgnoreCase) && !owner.IsCorePlugin)\r\n\t{\r\n\t\tInterface.Oxide.LogWarning(\"Missing plugin name prefix '{0}' for permission '{1}' (by plugin '{2}')\", owner.Name.ToLower(), permission, owner.Title);\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnUserNameUpdated",
"HookName": "OnUserNameUpdated",
"HookParameters": {
"playerId": "string",
"oldName": "string",
"newName": "string"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a player's stored nickname has been changed",
"MethodData": {
"MethodName": "UpdateNickname",
"ReturnType": "void",
"Arguments": {
"playerId": "string",
"playerName": "string"
}
},
"CodeAfterInjection": "public void UpdateNickname(string playerId, string playerName)\r\n{\r\n\tif (UserExists(playerId))\r\n\t{\r\n\t\tUserData userData = GetUserData(playerId);\r\n\t\tstring oldName = userData.LastSeenNickname;\r\n\t\tstring newName = playerName.Sanitize();\r\n\t\tuserData.LastSeenNickname = playerName.Sanitize();\r\n\r\n\t\tInterface.CallHook(\"OnUserNameUpdated\", playerId, oldName, newName);\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnGroupCreated",
"HookName": "OnGroupCreated",
"HookParameters": {
"name": "string"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a group has been created successfully",
"MethodData": {
"MethodName": "CreateGroup",
"ReturnType": "bool",
"Arguments": {
"groupName": "string",
"groupTitle": "string",
"groupRank": "int"
}
},
"CodeAfterInjection": "public bool CreateGroup(string groupName, string groupTitle, int groupRank)\r\n{\r\n\t// Check if it already exists\r\n\tif (GroupExists(groupName) || string.IsNullOrEmpty(groupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t// Create the data\r\n\tGroupData groupData = new GroupData { Title = groupTitle, Rank = groupRank };\r\n\t// Add the group\r\n\tgroupsData.Add(groupName, groupData);\r\n\tInterface.CallHook(\"OnGroupCreated\", groupName, groupTitle, groupRank);\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "OnGroupDeleted",
"HookName": "OnGroupDeleted",
"HookParameters": {
"name": "string"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a group has been deleted successfully",
"MethodData": {
"MethodName": "RemoveGroup",
"ReturnType": "bool",
"Arguments": {
"groupName": "string"
}
},
"CodeAfterInjection": "public bool RemoveGroup(string groupName)\r\n{\r\n\t// Check if it even exists\r\n\tif (!GroupExists(groupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t// Remove the group\r\n\tbool removed = groupsData.Remove(groupName);\r\n\tif (removed)\r\n\t{\r\n\t\t// Set children to having no parent group\r\n\t\tforeach (GroupData child in groupsData.Values.Where(g => g.ParentGroup == groupName))\r\n\t\t{\r\n\t\t\tchild.ParentGroup = string.Empty;\r\n\t\t}\r\n\t}\r\n\t// Remove group from users\r\n\tbool changed = usersData.Values.Aggregate(false, (current, userData) => current | userData.Groups.Remove(groupName));\r\n\tif (changed)\r\n\t{\r\n\t\tSaveUsers();\r\n\t}\r\n\tif (removed)\r\n\t{\r\n\t\tInterface.CallHook(\"OnGroupDeleted\", groupName);\r\n\t}\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "OnGroupTitleSet",
"HookName": "OnGroupTitleSet",
"HookParameters": {
"name": "string",
"title": "string"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a group title has been updated",
"MethodData": {
"MethodName": "SetGroupTitle",
"ReturnType": "bool",
"Arguments": {
"groupName": "string",
"groupTitle": "string"
}
},
"CodeAfterInjection": "public bool SetGroupTitle(string groupName, string groupTitle)\r\n{\r\n\tif (!GroupExists(groupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// First, get the group data\r\n\tif (!groupsData.TryGetValue(groupName, out GroupData groupData))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Change the title\r\n\tif (groupData.Title == groupTitle)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\tgroupData.Title = groupTitle;\r\n\r\n\tInterface.CallHook(\"OnGroupTitleSet\", groupName, groupTitle);\r\n\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "OnGroupRankSet",
"HookName": "OnGroupRankSet",
"HookParameters": {
"name": "string",
"title": "string"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a group title has been updated",
"MethodData": {
"MethodName": "SetGroupRank",
"ReturnType": "bool",
"Arguments": {
"groupName": "string",
"groupRank": "int"
}
},
"CodeAfterInjection": "public bool SetGroupRank(string groupName, int groupRank)\r\n{\r\n\tif (!GroupExists(groupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// First, get the group data\r\n\tif (!groupsData.TryGetValue(groupName, out GroupData groupData))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Change the rank\r\n\tif (groupData.Rank == groupRank)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\tgroupData.Rank = groupRank;\r\n\r\n\tInterface.CallHook(\"OnGroupRankSet\", groupName, groupRank);\r\n\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "OnGroupParentSet",
"HookName": "OnGroupParentSet",
"HookParameters": {
"name": "string",
"parent": "string"
},
"ReturnBehavior": 0,
"TargetType": "Permission",
"Category": "Permission",
"HookDescription": "Called when a group parent has been updated",
"MethodData": {
"MethodName": "SetGroupParent",
"ReturnType": "bool",
"Arguments": {
"groupName": "string",
"parentGroupName": "string"
}
},
"CodeAfterInjection": "public bool SetGroupParent(string groupName, string parentGroupName)\r\n{\r\n\tif (!GroupExists(groupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// First, get the group data\r\n\tif (!groupsData.TryGetValue(groupName, out GroupData groupData))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (string.IsNullOrEmpty(parentGroupName))\r\n\t{\r\n\t\tgroupData.ParentGroup = null;\r\n\t\treturn true;\r\n\t}\r\n\r\n\tif (!GroupExists(parentGroupName) || groupName.Equals(parentGroupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (!string.IsNullOrEmpty(groupData.ParentGroup) && groupData.ParentGroup.Equals(parentGroupName))\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\tif (HasCircularParent(groupName, parentGroupName))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Change the parent group\r\n\tgroupData.ParentGroup = parentGroupName;\r\n\r\n\tInterface.CallHook(\"OnGroupParentSet\", groupName, parentGroupName);\r\n\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "OnPluginLoaded",
"HookName": "OnPluginLoaded",
"HookParameters": {
"plugin": "Plugin"
},
"ReturnBehavior": 0,
"TargetType": "OxideMod",
"Category": "Server",
"HookDescription": "Called when any plugin has been loaded. Not to be confused with Loaded",
"MethodData": {
"MethodName": "PluginLoaded",
"ReturnType": "bool",
"Arguments": {
"plugin": "Plugin"
}
},
"CodeAfterInjection": "public bool PluginLoaded(Plugin plugin)\r\n{\r\n\tplugin.OnError += plugin_OnError;\r\n\ttry\r\n\t{\r\n\t\tplugin.Loader?.PluginErrors.Remove(plugin.Name);\r\n\t\tRootPluginManager.AddPlugin(plugin);\r\n\t\tif (plugin.Loader != null)\r\n\t\t{\r\n\t\t\tif (plugin.Loader.PluginErrors.ContainsKey(plugin.Name))\r\n\t\t\t{\r\n\t\t\t\tUnloadPlugin(plugin.Name);\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\tplugin.IsLoaded = true;\r\n\t\tCallHook(\"OnPluginLoaded\", plugin);\r\n\t\tLogInfo(\"Loaded plugin {0} v{1} by {2}\", plugin.Title, plugin.Version, plugin.Author);\r\n\t\treturn true;\r\n\t}\r\n\tcatch (Exception ex)\r\n\t{\r\n\t\tif (plugin.Loader != null)\r\n\t\t{\r\n\t\t\tplugin.Loader.PluginErrors[plugin.Name] = ex.Message;\r\n\t\t}\r\n\r\n\t\tLogException($\"Could not initialize plugin '{plugin.Name} v{plugin.Version}'\", ex);\r\n\t\treturn false;\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnPluginUnloaded",
"HookName": "OnPluginUnloaded",
"HookParameters": {
"plugin": "Plugin"
},
"ReturnBehavior": 0,
"TargetType": "OxideMod",
"Category": "Server",
"HookDescription": "Called when any plugin has been unloaded. Not to be confused with Unload",
"MethodData": {
"MethodName": " UnloadPlugin()",
"ReturnType": "bool",
"Arguments": {
"name": "string"
}
},
"CodeAfterInjection": "public bool UnloadPlugin(string name)\r\n{\r\n\t// Get the plugin\r\n\tPlugin plugin = RootPluginManager.GetPlugin(name);\r\n\tif (plugin == null || (plugin.IsCorePlugin && !IsShuttingDown))\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\t// Let the plugin loader know that this plugin is being unloaded\r\n\tPluginLoader loader = extensionManager.GetPluginLoaders().SingleOrDefault(l => l.LoadedPlugins.ContainsKey(name));\r\n\tloader?.Unloading(plugin);\r\n\r\n\t// Unload it\r\n\tRootPluginManager.RemovePlugin(plugin);\r\n\r\n\t// Let other plugins know that this plugin has been unloaded\r\n\tif (plugin.IsLoaded)\r\n\t{\r\n\t\tCallHook(\"OnPluginUnloaded\", plugin);\r\n\t}\r\n\r\n\tplugin.IsLoaded = false;\r\n\r\n\tLogInfo(\"Unloaded plugin {0} v{1} by {2}\", plugin.Title, plugin.Version, plugin.Author);\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "Init",
"HookName": "Init",
"HookParameters": {},
"ReturnBehavior": 0,
"TargetType": "CSPlugin",
"Category": "Server",
"HookDescription": "Called when a plugin is being initialized.\r\n Other plugins may or may not be present, dependant on load order",
"MethodData": {
"MethodName": "HandleAddedToManager",
"ReturnType": "void",
"Arguments": {
"manager": "PluginManager"
}
},
"CodeAfterInjection": "public override void HandleAddedToManager(PluginManager manager)\r\n{\r\n\t// Let base work\r\n\tbase.HandleAddedToManager(manager);\r\n\r\n\t// Subscribe us\r\n\tforeach (string hookname in Hooks.Keys)\r\n\t{\r\n\t\tSubscribe(hookname);\r\n\t}\r\n\r\n\ttry\r\n\t{\r\n\t\t// Let the plugin know that it is loading\r\n\t\tOnCallHook(\"Init\", null);\r\n\t}\r\n\tcatch (Exception ex)\r\n\t{\r\n\t\tInterface.Oxide.LogException($\"Failed to initialize plugin '{Name} v{Version}'\", ex);\r\n\t\tif (Loader != null)\r\n\t\t{\r\n\t\t\tLoader.PluginErrors[Name] = ex.Message;\r\n\t\t}\r\n\t}\r\n\t//---"
},
{
"Type": 0,
"Name": "LoadDefaultConfig",
"HookName": "LoadDefaultConfig",
"HookParameters": {},
"ReturnBehavior": 0,
"TargetType": "Plugin",
"Category": "Server",
"HookDescription": "Called when the config for a plugin should be initialized.\r\n Only called if the config file does not already exist",
"MethodData": {
"MethodName": "LoadDefaultConfig",
"ReturnType": "void",
"Arguments": {}
},
"CodeAfterInjection": "protected virtual void LoadDefaultConfig() => CallHook(\"LoadDefaultConfig\", null);"
},
{
"Type": 0,
"Name": "LoadDefaultMessages",
"HookName": "LoadDefaultMessages",
"HookParameters": {},
"ReturnBehavior": 0,
"TargetType": "Plugin",
"Category": "Server",
"HookDescription": "Called when the localization for a plugin should be registered",
"MethodData": {
"MethodName": "LoadDefaultMessages",
"ReturnType": "void",
"Arguments": {}
},
"CodeAfterInjection": "protected virtual void LoadDefaultMessages() => CallHook(\"LoadDefaultMessages\", null);"
},
{
"Type": 0,
"Name": "OnRconCommand",
"HookName": "OnRconCommand",
"HookParameters": {
"UserEndPoint": "IPEndPoint",
"command": "string",
"args": "string[]"
},
"ReturnBehavior": 1,
"TargetType": "RemoteConsole",
"Category": "Server",
"HookDescription": "Called when a rcon command is received",
"MethodData": {
"MethodName": "OnMessage",
"ReturnType": "void",
"Arguments": {
"event": "MessageEventArgs",
"connection": "WebSocketContext"
}
},
"CodeAfterInjection": "private void OnMessage(MessageEventArgs e, WebSocketContext connection)\r\n{\r\n\tif (covalence == null)\r\n\t{\r\n\t\tInterface.Oxide.LogError(\"[Rcon] Failed to process command, Covalence is null\");\r\n\t\treturn;\r\n\t}\r\n\tRemoteMessage message = RemoteMessage.GetMessage(e.Data);\r\n\tif (message == null)\r\n\t{\r\n\t\tInterface.Oxide.LogError(\"[Rcon] Failed to process command, RemoteMessage is null\");\r\n\t\treturn;\r\n\t}\r\n\tif (string.IsNullOrEmpty(message.Message))\r\n\t{\r\n\t\tInterface.Oxide.LogError(\"[Rcon] Failed to process command, RemoteMessage.Text is not set\");\r\n\t\treturn;\r\n\t}\r\n\tstring[] fullCommand = CommandLine.Split(message.Message);\r\n\tstring command = fullCommand[0].ToLower();\r\n\tstring[] args = fullCommand.Skip(1).ToArray();\r\n\tif (Interface.CallHook(\"OnRconCommand\", connection.UserEndPoint, command, args) != null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tcovalence.Server.Command(command, args);\r\n}"
},
{
"Type": 0,
"Name": "OnMessagePlayer",
"HookName": "OnMessagePlayer",
"HookParameters": {
"formatted": "string",
"player": "BasePlayer",
"userId": "ulong"
},
"ReturnBehavior": 1,
"TargetType": "Player",
"Category": "Server",
"HookDescription": "Called when a message is sent to a player",
"MethodData": {
"MethodName": "Message",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer",
"message": "string",
"prefix": "string",
"userId": "ulong",
"params": "object[] args"
}
},
"CodeAfterInjection": "public void Message(BasePlayer player, string message, string prefix, ulong userId = 0, params object[] args)\r\n{\r\n\tif (string.IsNullOrEmpty(message))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tmessage = args.Length > 0 ? string.Format(Formatter.ToUnity(message), args) : Formatter.ToUnity(message);\r\n\tstring formatted = prefix != null ? $\"{prefix} {message}\" : message;\r\n\tif (Interface.CallHook(\"OnMessagePlayer\", formatted, player, userId) != null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tplayer.SendConsoleCommand(\"chat.add\", 2, userId, formatted);\r\n}"
},
{
"Type": 0,
"Name": "OnServerInitialized",
"HookName": "OnServerInitialized",
"HookParameters": {
"serverInitialized": "bool"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "Let plugins know server startup is complete",
"MethodData": {
"MethodName": "OnPluginLoaded",
"ReturnType": "void",
"Arguments": {
"plugin": "Plugin"
}
},
"CodeAfterInjection": "private void OnPluginLoaded(Plugin plugin)\r\n{\r\n\tif (serverInitialized)\r\n\t{\r\n\t\t// Call OnServerInitialized for hotloaded plugins\r\n\t\tplugin.CallHook(\"OnServerInitialized\", false);\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnServerInitialized",
"HookName": "OnServerInitialized",
"HookParameters": {
"serverInitialized": "bool"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "Let plugins know server startup is complete",
"MethodData": {
"MethodName": "IOnServerInitialized",
"ReturnType": "void",
"Arguments": {}
},
"CodeAfterInjection": "private void IOnServerInitialized()\r\n{\r\n\tif (!serverInitialized)\r\n\t{\r\n\t\tAnalytics.Collect();\r\n\r\n\t\tif (!Interface.Oxide.Config.Options.Modded)\r\n\t\t{\r\n\t\t\tInterface.Oxide.LogWarning(\"The server is currently listed under Community. Please be aware that Facepunch only allows admin tools\" +\r\n\t\t\t\t\" (that do not affect gameplay) under the Community section\");\r\n\t\t}\r\n\r\n\t\tserverInitialized = true;\r\n\r\n\t\t// Let plugins know server startup is complete\r\n\t\tInterface.CallHook(\"OnServerInitialized\", serverInitialized);\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnServerShutdown",
"HookName": "OnServerShutdown",
"HookParameters": {},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "Server is shutting down",
"MethodData": {
"MethodName": "IOnServerShutdown",
"ReturnType": "void",
"Arguments": {}
},
"CodeAfterInjection": "private void IOnServerShutdown()\r\n{\r\n\tInterface.Oxide.CallHook(\"OnServerShutdown\");\r\n\tInterface.Oxide.OnShutdown();\r\n\tCovalence.PlayerManager.SavePlayerData();\r\n}"
},
{
"Type": 0,
"Name": "CanUseUI",
"HookName": "CanUseUI",
"HookParameters": {
"player": "BasePlayer",
"json": "string"
},
"ReturnBehavior": 1,
"TargetType": "CUIHelper",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "AddUi",
"ReturnType": "bool",
"Arguments": {
"player": "BasePlayer",
"json": "string"
}
},
"CodeAfterInjection": "public static bool AddUi(BasePlayer player, string json)\r\n{\r\n\tif (player?.net != null && Interface.CallHook(\"CanUseUI\", player, json) == null)\r\n\t{\r\n\t\tCommunityEntity.ServerInstance.ClientRPC(RpcTarget.Player(\"AddUI\", player.net.connection ), json);\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}"
},
{
"Type": 0,
"Name": "OnDestroyUI",
"HookName": "OnDestroyUI",
"HookParameters": {
"player": "BasePlayer",
"elem": "string"
},
"ReturnBehavior": 0,
"TargetType": "CUIHelper",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "DestroyUi",
"ReturnType": "bool",
"Arguments": {
"player": "BasePlayer",
"elem": "string"
}
},
"CodeAfterInjection": "public static bool DestroyUi(BasePlayer player, string elem)\r\n{\r\n\tif (player?.net != null)\r\n\t{\r\n\t\tInterface.CallHook(\"OnDestroyUI\", player, elem);\r\n\t\tCommunityEntity.ServerInstance.ClientRPC(RpcTarget.Player(\"DestroyUI\", player.net.connection ), elem);\r\n\t\treturn true;\r\n\t}\r\n\r\n\treturn false;\r\n}"
},
{
"Type": 0,
"Name": "OnEntityTakeDamage",
"HookName": "OnEntityTakeDamage",
"HookParameters": {
"entity": "BaseCombatEntity",
"hitInfo": "HitInfo"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Entity",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnBaseCombatEntityHurt",
"ReturnType": "object",
"Arguments": {
"entity": "BaseCombatEntity",
"hitInfo": "HitInfo"
}
},
"CodeAfterInjection": "private object IOnBaseCombatEntityHurt(BaseCombatEntity entity, HitInfo hitInfo)\r\n{\r\n\treturn entity is BasePlayer ? null : Interface.CallHook(\"OnEntityTakeDamage\", entity, hitInfo);\r\n}"
},
{
"Type": 0,
"Name": "OnNpcTarget [AI]",
"HookName": "OnNpcTarget",
"HookParameters": {
"npc": "BaseNpc",
"target": "BaseEntity"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "NPC",
"HookDescription": "AI targetting other BaseEntity.",
"MethodData": {
"MethodName": "IOnNpcTarget",
"ReturnType": "object",
"Arguments": {
"npc": "BaseNpc",
"target": "BaseEntity"
}
},
"CodeAfterInjection": "private object IOnNpcTarget(BaseNpc npc, BaseEntity target)\r\n{\r\n\tif (Interface.CallHook(\"OnNpcTarget\", npc, target) != null)\r\n\t{\r\n\t\tnpc.SetFact(BaseNpc.Facts.HasEnemy, 0);\r\n\t\tnpc.SetFact(BaseNpc.Facts.EnemyRange, 3);\r\n\t\tnpc.SetFact(BaseNpc.Facts.AfraidRange, 1);\r\n\r\n\t\t//TODO: Find replacements of those:\r\n\t\t// npc.AiContext.EnemyPlayer = null;\r\n\t\t// npc.AiContext.LastEnemyPlayerScore = 0f;\r\n\r\n\t\tnpc.playerTargetDecisionStartTime = 0f;\r\n\t\treturn 0f;\r\n\t}\r\n\r\n\treturn null;\r\n}"
},
{
"Type": 0,
"Name": "OnNpcTarget [AI.Gen2]",
"HookName": "OnNpcTarget",
"HookParameters": {
"npc": "BaseEntity",
"target": "BaseEntity"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "NPC",
"HookDescription": "Rust.AI.Gen2 targetting other BaseEntity.",
"MethodData": {
"MethodName": "IOnNpcTarget",
"ReturnType": "object",
"Arguments": {
"sense": "SenseComponent",
"target": "BaseEntity"
}
},
"CodeAfterInjection": "private object IOnNpcTarget(SenseComponent sense, BaseEntity target)\r\n{\r\n\tif (!sense || !target)\r\n\t{\r\n\t\treturn null;\r\n\t}\r\n\tBaseEntity baseEntity = sense.baseEntity;\r\n\tif (!baseEntity)\r\n\t{\r\n\t\treturn null;\r\n\t}\r\n\tif (Interface.CallHook(\"OnNpcTarget\", baseEntity, target) != null)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\treturn null;\r\n}"
},
{
"Type": 0,
"Name": "OnEntitySaved",
"HookName": "OnEntitySaved",
"HookParameters": {
"baseNetworkable": "BaseNetworkable",
"saveInfo": "BaseNetworkable.SaveInfo"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Entity",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnEntitySaved",
"ReturnType": "void",
"Arguments": {
"baseNetworkable": "BaseNetworkable",
"saveInfo": "BaseNetworkable.SaveInfo"
}
},
"CodeAfterInjection": "private void IOnEntitySaved(BaseNetworkable baseNetworkable, BaseNetworkable.SaveInfo saveInfo)\r\n{\r\n\t// Only call when saving for the network since we don't expect plugins to want to intercept saving to disk\r\n\tif (!serverInitialized || saveInfo.forConnection == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tInterface.CallHook(\"OnEntitySaved\", baseNetworkable, saveInfo);\r\n}"
},
{
"Type": 0,
"Name": "OnLoseCondition",
"HookName": "OnLoseCondition",
"HookParameters": {
"item": "Item",
"amount": "ref float"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Item",
"HookDescription": "Called right before the condition of the item is modified",
"MethodData": {
"MethodName": "IOnLoseCondition",
"ReturnType": "object",
"Arguments": {
"item": "Item",
"amount": "float"
}
},
"CodeAfterInjection": "private object IOnLoseCondition(Item item, float amount)\r\n{\r\n\tobject[] arguments = { item, amount };\r\n\tInterface.CallHook(\"OnLoseCondition\", arguments);\r\n\tamount = (float)arguments[1];\r\n\tfloat condition = item.condition;\r\n\titem.condition -= amount;\r\n\tif (item.condition <= 0f && item.condition < condition)\r\n\t{\r\n\t\titem.OnBroken();\r\n\t}\r\n\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "CanPickupEntity",
"HookName": "CanPickupEntity",
"HookParameters": {
"basePlayer": "BasePlayer",
"entity": "DoorCloser"
},
"ReturnTypeOverwrite": "bool",
"ReturnBehavior": 3,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "Called when a player attempts to pickup a deployed entity (AutoTurret, BaseMountable, BearTrap, DecorDeployable, Door, DoorCloser, ReactiveTarget, SamSite, SleepingBag, SpinnerWheel, StorageContainer, etc.)",
"MethodData": {
"MethodName": "ICanPickupEntity",
"ReturnType": "object",
"Arguments": {
"basePlayer": "BasePlayer",
"entity": "DoorCloser"
}
},
"CodeAfterInjection": "private object ICanPickupEntity(BasePlayer basePlayer, DoorCloser entity)\r\n{\r\n\tobject callHook = Interface.CallHook(\"CanPickupEntity\", basePlayer, entity);\r\n\treturn callHook is bool result && !result ? (object)true : null;\r\n}"
},
{
"Type": 0,
"Name": "OnEntityTakeDamage",
"HookName": "OnEntityTakeDamage",
"HookParameters": {
"basePlayer": "BasePlayer",
"hitInfo": "HitInfo"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Entity",
"HookDescription": "Alternatively, modify the HitInfo object to change the damage.\r\n It should be okay to set the damage to 0, but if you don't return non-null, the player's client will receive a damage indicator (if entity is a BasePlayer).\r\n HitInfo has all kinds of useful things in it, such as Weapon, damageProperties or damageTypes",
"MethodData": {
"MethodName": "IOnBasePlayerAttacked",
"ReturnType": "object",
"Arguments": {
"basePlayer": "BasePlayer",
"hitInfo": "HitInfo"
}
},
"CodeAfterInjection": "private object IOnBasePlayerAttacked(BasePlayer basePlayer, HitInfo hitInfo)\r\n{\r\n\tif (!serverInitialized || basePlayer == null || hitInfo == null || basePlayer.IsDead() || isPlayerTakingDamage || basePlayer is NPCPlayer)\r\n\t{\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (Interface.CallHook(\"OnEntityTakeDamage\", basePlayer, hitInfo) != null)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\tisPlayerTakingDamage = true;\r\n\ttry\r\n\t{\r\n\t\tbasePlayer.OnAttacked(hitInfo);\r\n\t}\r\n\tfinally\r\n\t{\r\n\t\tisPlayerTakingDamage = false;\r\n\t}\r\n\treturn true;\r\n}"
},
{
"Type": 0,
"Name": "OnEntityTakeDamage",
"HookName": "OnEntityTakeDamage",
"HookParameters": {
"basePlayer": "BasePlayer",
"hitInfo": "HitInfo"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Entity",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnBasePlayerHurt",
"ReturnType": "object",
"Arguments": {
"basePlayer": "BasePlayer",
"hitInfo": "HitInfo"
}
},
"CodeAfterInjection": "private object IOnBasePlayerHurt(BasePlayer basePlayer, HitInfo hitInfo)\r\n{\r\n\treturn isPlayerTakingDamage ? null : Interface.CallHook(\"OnEntityTakeDamage\", basePlayer, hitInfo);\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerBanned",
"HookName": "OnPlayerBanned",
"HookParameters": {
"playerName": "string",
"steamId": "ulong",
"Address": "string",
"reason": "string",
"expiry": "long"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "OnServerUserSet",
"ReturnType": "void",
"Arguments": {
"steamId": "ulong",
"group": "ServerUsers.UserGroup",
"playerName": "string",
"reason": "string",
"expiry": "long"
}
},
"CodeAfterInjection": "private void OnServerUserSet(ulong steamId, ServerUsers.UserGroup group, string playerName, string reason, long expiry)\r\n{\r\n\tif (serverInitialized && group == ServerUsers.UserGroup.Banned)\r\n\t{\r\n\t\tstring playerId = steamId.ToString();\r\n\t\tIPlayer player = Covalence.PlayerManager.FindPlayerById(playerId);\r\n\t\tInterface.CallHook(\"OnPlayerBanned\", playerName, steamId, player?.Address ?? \"0\", reason, expiry);\r\n\t\tInterface.CallHook(\"OnUserBanned\", playerName, playerId, player?.Address ?? \"0\", reason, expiry);\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnUserBanned",
"HookName": "OnUserBanned",
"HookParameters": {
"playerName": "string",
"steamId": "string",
"Address": "string",
"reason": "string",
"expiry": "long"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "OnServerUserSet",
"ReturnType": "void",
"Arguments": {
"steamId": "ulong",
"group": "ServerUsers.UserGroup",
"playerName": "string",
"reason": "string",
"expiry": "long"
}
},
"CodeAfterInjection": "private void OnServerUserSet(ulong steamId, ServerUsers.UserGroup group, string playerName, string reason, long expiry)\r\n{\r\n\tif (serverInitialized && group == ServerUsers.UserGroup.Banned)\r\n\t{\r\n\t\tstring playerId = steamId.ToString();\r\n\t\tIPlayer player = Covalence.PlayerManager.FindPlayerById(playerId);\r\n\t\tInterface.CallHook(\"OnPlayerBanned\", playerName, steamId, player?.Address ?? \"0\", reason, expiry);\r\n\t\tInterface.CallHook(\"OnUserBanned\", playerName, playerId, player?.Address ?? \"0\", reason, expiry);\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerUnbanned",
"HookName": "OnPlayerUnbanned",
"HookParameters": {
"playerName": "string",
"steamId": "ulong",
"address": "string"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "OnServerUserRemove",
"ReturnType": "void",
"Arguments": {
"steamId": "ulong"
}
},
"CodeAfterInjection": "private void OnServerUserRemove(ulong steamId)\r\n{\r\n\tif (serverInitialized && ServerUsers.users.ContainsKey(steamId) && ServerUsers.users[steamId].group == ServerUsers.UserGroup.Banned)\r\n\t{\r\n\t\tstring playerId = steamId.ToString();\r\n\t\tIPlayer player = Covalence.PlayerManager.FindPlayerById(playerId);\r\n\t\tInterface.CallHook(\"OnPlayerUnbanned\", player?.Name ?? \"Unnamed\", steamId, player?.Address ?? \"0\");\r\n\t\tInterface.CallHook(\"OnUserUnbanned\", player?.Name ?? \"Unnamed\", playerId, player?.Address ?? \"0\");\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "OnUserUnbanned",
"HookName": "OnUserUnbanned",
"HookParameters": {
"playerName": "string",
"steamId": "string",
"address": "string"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "OnServerUserRemove",
"ReturnType": "void",
"Arguments": {
"steamId": "ulong"
}
},
"CodeAfterInjection": "private void OnServerUserRemove(ulong steamId)\r\n{\r\n\tif (serverInitialized && ServerUsers.users.ContainsKey(steamId) && ServerUsers.users[steamId].group == ServerUsers.UserGroup.Banned)\r\n\t{\r\n\t\tstring playerId = steamId.ToString();\r\n\t\tIPlayer player = Covalence.PlayerManager.FindPlayerById(playerId);\r\n\t\tInterface.CallHook(\"OnPlayerUnbanned\", player?.Name ?? \"Unnamed\", steamId, player?.Address ?? \"0\");\r\n\t\tInterface.CallHook(\"OnUserUnbanned\", player?.Name ?? \"Unnamed\", playerId, player?.Address ?? \"0\");\r\n\t}\r\n}"
},
{
"Type": 0,
"Name": "CanClientLogin",
"HookName": "CanClientLogin",
"HookParameters": {
"connection": "Connection"
},
"ReturnTypeOverwrite": "bool",
"ReturnBehavior": 3,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "Called when a player attempt to login the server. return bool to reject connection, or string for reason of rejection",
"MethodData": {
"MethodName": "IOnUserApprove",
"ReturnType": "object",
"Arguments": {
"connection": "Connection"
}
},
"CodeAfterInjection": "private object IOnUserApprove(Connection connection)\r\n{\r\n\tstring playerName = connection.username;\r\n\tstring connectionId = connection.userid.ToString();\r\n\tstring connectionIp = Regex.Replace(connection.ipaddress, ipPattern, \"\");\r\n\tuint authLevel = connection.authLevel;\r\n\r\n\t// Update name and groups with permissions\r\n\tif (permission.IsLoaded)\r\n\t{\r\n\t\tpermission.UpdateNickname(connectionId, playerName);\r\n\t\tOxideConfig.DefaultGroups defaultGroups = Interface.Oxide.Config.Options.DefaultGroups;\r\n\t\tif (!permission.UserHasGroup(connectionId, defaultGroups.Players))\r\n\t\t{\r\n\t\t\tpermission.AddUserGroup(connectionId, defaultGroups.Players);\r\n\t\t}\r\n\t\tif (authLevel >= 2 && !permission.UserHasGroup(connectionId, defaultGroups.Administrators))\r\n\t\t{\r\n\t\t\tpermission.AddUserGroup(connectionId, defaultGroups.Administrators);\r\n\t\t}\r\n\t}\r\n\r\n\t// Let covalence know\r\n\tCovalence.PlayerManager.PlayerJoin(connection.userid, playerName);\r\n\r\n\t// Call hooks for plugins\r\n\tobject loginSpecific = Interface.CallHook(\"CanClientLogin\", connection);\r\n\tobject loginCovalence = Interface.CallHook(\"CanUserLogin\", playerName, connectionId, connectionIp);\r\n\tobject canLogin = loginSpecific is null ? loginCovalence : loginSpecific;\r\n\tif (canLogin is string || canLogin is bool loginBlocked && !loginBlocked)\r\n\t{\r\n\t\tConnectionAuth.Reject(connection, canLogin is string ? canLogin.ToString() : lang.GetMessage(\"ConnectionRejected\", this, connectionId));\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// Call hooks for plugins\r\n\tobject approvedSpecific = Interface.CallHook(\"OnUserApprove\", connection);\r\n\tobject approvedCovalence = Interface.CallHook(\"OnUserApproved\", playerName, connectionId, connectionIp);\r\n\treturn approvedSpecific is null ? approvedCovalence : approvedSpecific;\r\n}"
},
{
"Type": 0,
"Name": "CanUserLogin",
"HookName": "CanUserLogin",
"HookParameters": {
"playerName": "string",
"connectionId": "string",
"connectionIp": "string"
},
"ReturnTypeOverwrite": "bool",
"ReturnBehavior": 3,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "Called when a player attempt to login the server. return bool to reject connection, or string for reason of rejection",
"MethodData": {
"MethodName": "IOnUserApprove",
"ReturnType": "object",
"Arguments": {
"connection": "Connection"
}
},
"CodeAfterInjection": "private object IOnUserApprove(Connection connection)\r\n{\r\n\tstring playerName = connection.username;\r\n\tstring connectionId = connection.userid.ToString();\r\n\tstring connectionIp = Regex.Replace(connection.ipaddress, ipPattern, \"\");\r\n\tuint authLevel = connection.authLevel;\r\n\r\n\t// Update name and groups with permissions\r\n\tif (permission.IsLoaded)\r\n\t{\r\n\t\tpermission.UpdateNickname(connectionId, playerName);\r\n\t\tOxideConfig.DefaultGroups defaultGroups = Interface.Oxide.Config.Options.DefaultGroups;\r\n\t\tif (!permission.UserHasGroup(connectionId, defaultGroups.Players))\r\n\t\t{\r\n\t\t\tpermission.AddUserGroup(connectionId, defaultGroups.Players);\r\n\t\t}\r\n\t\tif (authLevel >= 2 && !permission.UserHasGroup(connectionId, defaultGroups.Administrators))\r\n\t\t{\r\n\t\t\tpermission.AddUserGroup(connectionId, defaultGroups.Administrators);\r\n\t\t}\r\n\t}\r\n\r\n\t// Let covalence know\r\n\tCovalence.PlayerManager.PlayerJoin(connection.userid, playerName);\r\n\r\n\t// Call hooks for plugins\r\n\tobject loginSpecific = Interface.CallHook(\"CanClientLogin\", connection);\r\n\tobject loginCovalence = Interface.CallHook(\"CanUserLogin\", playerName, connectionId, connectionIp);\r\n\tobject canLogin = loginSpecific is null ? loginCovalence : loginSpecific;\r\n\tif (canLogin is string || canLogin is bool loginBlocked && !loginBlocked)\r\n\t{\r\n\t\tConnectionAuth.Reject(connection, canLogin is string ? canLogin.ToString() : lang.GetMessage(\"ConnectionRejected\", this, connectionId));\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// Call hooks for plugins\r\n\tobject approvedSpecific = Interface.CallHook(\"OnUserApprove\", connection);\r\n\tobject approvedCovalence = Interface.CallHook(\"OnUserApproved\", playerName, connectionId, connectionIp);\r\n\treturn approvedSpecific is null ? approvedCovalence : approvedSpecific;\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerBanned",
"HookName": "OnPlayerBanned",
"HookParameters": {
"connection": "Connection",
"status": "string"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnPlayerBanned",
"ReturnType": "void",
"Arguments": {
"connection": "Connection",
"status": "AuthResponse"
}
},
"CodeAfterInjection": "private void IOnPlayerBanned(Connection connection, AuthResponse status)\r\n{\r\n\t// TODO: Get BasePlayer and pass instead of Connection\r\n\tInterface.CallHook(\"OnPlayerBanned\", connection, status.ToString());\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerOfflineChat",
"HookName": "OnPlayerOfflineChat",
"HookParameters": {
"playerid": "ulong",
"playerName": "string",
"message": "string",
"channel": "Chat.ChatChannel"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "Hook is called when a chat message is sent to an offline player ",
"MethodData": {
"MethodName": "IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)",
"ReturnType": "object",
"Arguments": {
"playerId": "ulong",
"playerName": "string",
"message": "string",
"channel": "Chat.ChatChannel",
"player": "BasePlayer"
}
},
"CodeAfterInjection": "private object IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)\r\n{\r\n\t// Ignore empty and \"default\" text\r\n\tif (string.IsNullOrEmpty(message) || message.Equals(\"text\"))\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// Check if chat command\r\n\tstring chatCommandPrefix = CommandHandler.GetChatCommandPrefix(message);\r\n\tif ( chatCommandPrefix != null )\r\n\t{\r\n\t\tTryRunPlayerCommand( basePlayer, message, chatCommandPrefix );\r\n\t\treturn false;\r\n\t}\r\n\r\n\tmessage = message.EscapeRichText();\r\n\r\n\t// Check if using Rust+ app\r\n\tif (basePlayer == null || !basePlayer.IsConnected)\r\n\t{\r\n\t\t// Call offline chat hook\r\n\t\treturn Interface.CallHook(\"OnPlayerOfflineChat\", playerId, playerName, message, channel);\r\n\t}\r\n\r\n\t// Call hooks for plugins\r\n\tobject chatSpecific = Interface.CallHook(\"OnPlayerChat\", basePlayer, message, channel);\r\n\tobject chatCovalence = Interface.CallHook(\"OnUserChat\", basePlayer.IPlayer, message);\r\n\treturn chatSpecific is null ? chatCovalence : chatSpecific;\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerChat",
"HookName": "OnPlayerChat",
"HookParameters": {
"player": "BasePlayer",
"message": "string",
"channel": "Chat.ChatChannel"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)",
"ReturnType": "object",
"Arguments": {
"playerId": "ulong",
"playerName": "string",
"message": "string",
"channel": "Chat.ChatChannel",
"player": "BasePlayer"
}
},
"CodeAfterInjection": "private object IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)\r\n{\r\n\t// Ignore empty and \"default\" text\r\n\tif (string.IsNullOrEmpty(message) || message.Equals(\"text\"))\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// Check if chat command\r\n\tstring chatCommandPrefix = CommandHandler.GetChatCommandPrefix(message);\r\n\tif ( chatCommandPrefix != null )\r\n\t{\r\n\t\tTryRunPlayerCommand( basePlayer, message, chatCommandPrefix );\r\n\t\treturn false;\r\n\t}\r\n\r\n\tmessage = message.EscapeRichText();\r\n\r\n\t// Check if using Rust+ app\r\n\tif (basePlayer == null || !basePlayer.IsConnected)\r\n\t{\r\n\t\t// Call offline chat hook\r\n\t\treturn Interface.CallHook(\"OnPlayerOfflineChat\", playerId, playerName, message, channel);\r\n\t}\r\n\r\n\t// Call hooks for plugins\r\n\tobject chatSpecific = Interface.CallHook(\"OnPlayerChat\", basePlayer, message, channel);\r\n\tobject chatCovalence = Interface.CallHook(\"OnUserChat\", basePlayer.IPlayer, message);\r\n\treturn chatSpecific is null ? chatCovalence : chatSpecific;\r\n}"
},
{
"Type": 0,
"Name": "OnUserChat",
"HookName": "OnUserChat",
"HookParameters": {
"iplayer": "IPlayer",
"message": "string"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)",
"ReturnType": "object",
"Arguments": {
"playerId": "ulong",
"playerName": "string",
"message": "string",
"channel": "Chat.ChatChannel",
"player": "BasePlayer"
}
},
"CodeAfterInjection": "private object IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)\r\n{\r\n\t// Ignore empty and \"default\" text\r\n\tif (string.IsNullOrEmpty(message) || message.Equals(\"text\"))\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\t// Check if chat command\r\n\tstring chatCommandPrefix = CommandHandler.GetChatCommandPrefix(message);\r\n\tif ( chatCommandPrefix != null )\r\n\t{\r\n\t\tTryRunPlayerCommand( basePlayer, message, chatCommandPrefix );\r\n\t\treturn false;\r\n\t}\r\n\r\n\tmessage = message.EscapeRichText();\r\n\r\n\t// Check if using Rust+ app\r\n\tif (basePlayer == null || !basePlayer.IsConnected)\r\n\t{\r\n\t\t// Call offline chat hook\r\n\t\treturn Interface.CallHook(\"OnPlayerOfflineChat\", playerId, playerName, message, channel);\r\n\t}\r\n\r\n\t// Call hooks for plugins\r\n\tobject chatSpecific = Interface.CallHook(\"OnPlayerChat\", basePlayer, message, channel);\r\n\tobject chatCovalence = Interface.CallHook(\"OnUserChat\", basePlayer.IPlayer, message);\r\n\treturn chatSpecific is null ? chatCovalence : chatSpecific;\r\n}"
},
{
"Type": 0,
"Name": "OnApplicationCommand",
"HookName": "OnApplicationCommand",
"HookParameters": {
"player": "BasePlayer",
"cmd": "string",
"args": "string[]"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "TryRunPlayerCommand",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer",
"message": "string",
"commandPrefix": "string"
}
},
"CodeAfterInjection": "private void TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)\r\n{\r\n\tif (basePlayer == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tstring str = message.Replace(\"\\n\", \"\").Replace(\"\\r\", \"\").Trim();\r\n\r\n\t// Check if it is a chat command\r\n\tif (string.IsNullOrEmpty(str))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Parse the command\r\n\tParseCommand(str.Substring(commandPrefix.Length), out string cmd, out string[] args);\r\n\tif (cmd == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Check if using Rust+ app\r\n\tif (!basePlayer.IsConnected)\r\n\t{\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer, cmd, args);\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer.IPlayer, cmd, args);\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Is the command blocked?\r\n\tobject commandSpecific = Interface.CallHook(\"OnPlayerCommand\", basePlayer, cmd, args);\r\n\tobject commandCovalence = Interface.CallHook(\"OnUserCommand\", basePlayer.IPlayer, cmd, args);\r\n\tobject canBlock = commandSpecific is null ? commandCovalence : commandSpecific;\r\n\tif (canBlock != null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t//---\r\n}"
},
{
"Type": 0,
"Name": "OnApplicationCommand",
"HookName": "OnApplicationCommand",
"HookParameters": {
"iplayer": "IPlayer",
"cmd": "string",
"args": "string[]"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Server",
"HookDescription": "",
"MethodData": {
"MethodName": "TryRunPlayerCommand",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer",
"message": "string",
"commandPrefix": "string"
}
},
"CodeAfterInjection": "private void TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)\r\n{\r\n\tif (basePlayer == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tstring str = message.Replace(\"\\n\", \"\").Replace(\"\\r\", \"\").Trim();\r\n\r\n\t// Check if it is a chat command\r\n\tif (string.IsNullOrEmpty(str))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Parse the command\r\n\tParseCommand(str.Substring(commandPrefix.Length), out string cmd, out string[] args);\r\n\tif (cmd == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Check if using Rust+ app\r\n\tif (!basePlayer.IsConnected)\r\n\t{\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer, cmd, args);\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer.IPlayer, cmd, args);\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Is the command blocked?\r\n\tobject commandSpecific = Interface.CallHook(\"OnPlayerCommand\", basePlayer, cmd, args);\r\n\tobject commandCovalence = Interface.CallHook(\"OnUserCommand\", basePlayer.IPlayer, cmd, args);\r\n\tobject canBlock = commandSpecific is null ? commandCovalence : commandSpecific;\r\n\tif (canBlock != null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t//---\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerCommand",
"HookName": "OnPlayerCommand",
"HookParameters": {
"player": "BasePlayer",
"cmd": "string",
"args": "string[]"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "TryRunPlayerCommand",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer",
"message": "string",
"commandPrefix": "string"
}
},
"CodeAfterInjection": "private void TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)\r\n{\r\n\tif (basePlayer == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tstring str = message.Replace(\"\\n\", \"\").Replace(\"\\r\", \"\").Trim();\r\n\r\n\t// Check if it is a chat command\r\n\tif (string.IsNullOrEmpty(str))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Parse the command\r\n\tParseCommand(str.Substring(commandPrefix.Length), out string cmd, out string[] args);\r\n\tif (cmd == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Check if using Rust+ app\r\n\tif (!basePlayer.IsConnected)\r\n\t{\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer, cmd, args);\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer.IPlayer, cmd, args);\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Is the command blocked?\r\n\tobject commandSpecific = Interface.CallHook(\"OnPlayerCommand\", basePlayer, cmd, args);\r\n\tobject commandCovalence = Interface.CallHook(\"OnUserCommand\", basePlayer.IPlayer, cmd, args);\r\n\tobject canBlock = commandSpecific is null ? commandCovalence : commandSpecific;\r\n\tif (canBlock != null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t//---\r\n}"
},
{
"Type": 0,
"Name": "OnUserCommand",
"HookName": "OnUserCommand",
"HookParameters": {
"iplayer": "IPlayer",
"cmd": "string",
"args": "string[]"
},
"ReturnBehavior": 1,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "TryRunPlayerCommand",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer",
"message": "string",
"commandPrefix": "string"
}
},
"CodeAfterInjection": "private void TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)\r\n{\r\n\tif (basePlayer == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tstring str = message.Replace(\"\\n\", \"\").Replace(\"\\r\", \"\").Trim();\r\n\r\n\t// Check if it is a chat command\r\n\tif (string.IsNullOrEmpty(str))\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Parse the command\r\n\tParseCommand(str.Substring(commandPrefix.Length), out string cmd, out string[] args);\r\n\tif (cmd == null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Check if using Rust+ app\r\n\tif (!basePlayer.IsConnected)\r\n\t{\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer, cmd, args);\r\n\t\tInterface.CallHook(\"OnApplicationCommand\", basePlayer.IPlayer, cmd, args);\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Is the command blocked?\r\n\tobject commandSpecific = Interface.CallHook(\"OnPlayerCommand\", basePlayer, cmd, args);\r\n\tobject commandCovalence = Interface.CallHook(\"OnUserCommand\", basePlayer.IPlayer, cmd, args);\r\n\tobject canBlock = commandSpecific is null ? commandCovalence : commandSpecific;\r\n\tif (canBlock != null)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t//---\r\n}"
},
{
"Type": 0,
"Name": "OnUserConnected",
"HookName": "OnUserConnected",
"HookParameters": {
"iplayer": "IPlayer"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnPlayerConnected",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer"
}
},
"CodeAfterInjection": "private void IOnPlayerConnected(BasePlayer basePlayer)\r\n{\r\n\t// Set language for player\r\n\tlang.SetLanguage(basePlayer.net.connection.info.GetString(\"global.language\", \"en\"), basePlayer.UserIDString);\r\n\r\n\t// Send CUI to player manually\r\n\tbasePlayer.SendEntitySnapshot(CommunityEntity.ServerInstance);\r\n\r\n\t// Let covalence know\r\n\tCovalence.PlayerManager.PlayerConnected(basePlayer);\r\n\tIPlayer player = Covalence.PlayerManager.FindPlayerById(basePlayer.UserIDString);\r\n\tif (player != null)\r\n\t{\r\n\t\tbasePlayer.IPlayer = player;\r\n\t\tInterface.CallHook(\"OnUserConnected\", player);\r\n\t}\r\n\r\n\tInterface.Oxide.CallHook(\"OnPlayerConnected\", basePlayer);\r\n}"
},
{
"Type": 0,
"Name": "OnPlayerConnected",
"HookName": "OnPlayerConnected",
"HookParameters": {
"player": "BasePlayer"
},
"ReturnBehavior": 0,
"TargetType": "RustCore",
"Category": "Player",
"HookDescription": "",
"MethodData": {
"MethodName": "IOnPlayerConnected",
"ReturnType": "void",
"Arguments": {
"player": "BasePlayer"
}