summaryrefslogtreecommitdiffstats
path: root/Server/Plugins/APIDump/Classes/RankManager.lua
blob: 9695117a69efea92b2df88eb2f3e5fec9ef7ee53 (plain) (blame)
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
-- Describes the cRankManager class API

return
{
	cRankManager =
	{
		Desc = [[
			Manages the players' permissions. The players are assigned a single rank, which contains groups of
			permissions and restrictions. The functions in this class query or modify these.</p>
			<p>
			All the functions are static, call them using the <code>cRankManager:Function()</code> convention.</p>
			<p>
			The players are identified by their UUID, to support player renaming.</p>
			<p>
			The rank also contains specific "mesage visuals" - bits that are used for formatting messages from the
			players. There's a message prefix, which is put in front of every message the player sends, and the
			message suffix that is appended to each message. There's also a PlayerNameColorCode, which holds the
			color that is used for the player's name in the messages.</p>
			<p>
			Each rank can contain any number of permission groups. These groups allow for an easier setup of the
			permissions - you can share groups among ranks, so the usual approach is to group similar permissions
			together and add that group to any rank that should use those permissions.</p>
			<p>
			Permissions are added to individual groups. Each group can support unlimited permissions. Note that
			adding a permission to a group will make the permission available to all the ranks that contain that
			permission group.</p>
			<p>
			One rank is reserved as the Default rank. All players that don't have an explicit rank assigned to them
			will behave as if assigned to this rank. The default rank can be changed to any other rank at any time.
			Note that the default rank cannot be removed from the RankManager - RemoveRank() will change the default
			rank to the replacement rank, if specified, and fail if no replacement rank is specified. Renaming the
			default rank using RenameRank() will change the default rank to the new name.
		]],
		Functions =
		{
			AddGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Notes = "Adds the group of the specified name. Logs a warning and does nothing if the group already exists.",
			},
			AddGroupToRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Adds the specified group to the specified rank. Returns true on success, false on failure - if the group name or the rank name is not found.",
			},
			AddPermissionToGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "Permission",
						Type = "string",
					},
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Adds the specified permission to the specified group. Returns true on success, false on failure - if the group name is not found.",
			},
			AddRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
					{
						Name = "MsgPrefix",
						Type = "string",
					},
					{
						Name = "MsgSuffix",
						Type = "string",
					},
					{
						Name = "MsgNameColorCode",
						Type = "string",
					},
				},
				Notes = "Adds a new rank of the specified name and with the specified message visuals. Logs an info message and does nothing if the rank already exists.",
			},
			AddRestrictionToGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "Permission",
						Type = "string",
					},
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{ Type = "boolean" },
				},
				Notes = "Adds a new restriction to the specified group. Returns true if successful, false if it fails (no such group). No action if the group already has the restriction.",
			},
			ClearPlayerRanks =
			{
				IsStatic = true,
				Notes = "Removes all player ranks from the database. Note that this doesn't change the cPlayer instances for the already connected players, you need to update all the instances manually.",
			},
			GetAllGroups =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing the names of all the groups that are known to the manager.",
			},
			GetAllPermissions =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing all the permissions that are known to the manager.",
			},
			GetAllPermissionsRestrictions =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing all the permissions and restrictions (intermixed together) that are known to the manager.",
			},
			GetAllPlayerUUIDs =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns the short uuids of all players stored in the rank DB, sorted by the players' names (case insensitive).",
			},
			GetAllRanks =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing the names of all the ranks that are known to the manager.",
			},
			GetAllRestrictions =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing all the restrictions that are known to the manager.",
			},
			GetDefaultRank =
			{
				IsStatic = true,
				Returns =
				{
					{
						Type = "string",
					},
				},
				Notes = "Returns the name of the default rank. ",
			},
			GetGroupPermissions =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing the permissions that the specified group contains.",
			},
			GetGroupRestrictions =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing the restrictions that the specified group contains.",
			},
			GetPlayerGroups =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table of the names of the groups that are assigned to the specified player through their rank. Returns an empty table if the player is not known or has no rank or groups assigned to them.",
			},
			GetPlayerMsgVisuals =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Name = "MsgPrefix",
						Type = "string",
					},
					{
						Name = "MsgSuffix",
						Type = "string",
					},
					{
						Name = "MsgNameColorCode",
						Type = "string",
					},
				},
				Notes = "Returns the message visuals assigned to the player. If the player is not explicitly assigned a rank, the default rank's visuals are returned. If there is an error, no value is returned at all.",
			},
			GetPlayerName =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Name = "PlayerName",
						Type = "string",
					},
				},
				Notes = "Returns the last name that the specified player has, for a player in the ranks database. An empty string is returned if the player isn't in the database.",
			},
			GetPlayerPermissions =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table containing all permissions that the specified player is assigned through their rank. Returns the default rank's permissions if the player has no explicit rank assigned to them. Returns an empty array on error.",
			},
			GetPlayerRankName =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Notes = "Returns the name of the rank that is assigned to the specified player. An empty string (NOT the default rank) is returned if the player has no rank assigned to them.",
			},
			GetRankGroups =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table of the names of all the groups that are assigned to the specified rank. Returns an empty table if there is no such rank.",
			},
			GetRankPermissions =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table of all the permissions that are assigned to the specified rank through its groups. Returns an empty table if there is no such rank.",
			},
			GetRankRestrictions =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "table",
					},
				},
				Notes = "Returns an array-table of all the restrictions that are assigned to the specified rank through its groups. Returns an empty table if there is no such rank.",
			},
			GetRankVisuals =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Name = "MsgPrefix",
						Type = "string",
					},
					{
						Name = "MsgSuffix",
						Type = "string",
					},
					{
						Name = "MsgNameColorCode",
						Type = "string",
					},
				},
				Notes = "Returns the message visuals for the specified rank. Returns no value if the specified rank does not exist.",
			},
			GroupExists =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Returns true iff the specified group exists.",
			},
			IsGroupInRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Returns true iff the specified group is assigned to the specified rank.",
			},
			IsPermissionInGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "Permission",
						Type = "string",
					},
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Returns true iff the specified permission is assigned to the specified group.",
			},
			IsPlayerRankSet =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Returns true iff the specified player has a rank assigned to them.",
			},
			IsRestrictionInGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "Restriction",
						Type = "string",
					},
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Returns true iff the specified restriction is assigned to the specified group.",
			},
			RankExists =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Returns true iff the specified rank exists.",
			},
			RemoveGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Notes = "Removes the specified group completely. The group will be removed from all the ranks using it and then erased from the manager. Logs an info message and does nothing if the group doesn't exist.",
			},
			RemoveGroupFromRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "GroupName",
						Type = "string",
					},
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Notes = "Removes the specified group from the specified rank. The group will still exist, even if it isn't assigned to any rank. Logs an info message and does nothing if the group or rank doesn't exist.",
			},
			RemovePermissionFromGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "Permission",
						Type = "string",
					},
					{
						Name = "GroupName",
						Type = "string",
					},
				},
				Notes = "Removes the specified permission from the specified group. Logs an info message and does nothing if the group doesn't exist.",
			},
			RemovePlayerRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
				},
				Notes = "Removes the player's rank; the player's left without a rank. Note that this doesn't change the {{cPlayer}} instances for the already connected players, you need to update all the instances manually. No action if the player has no rank assigned to them already.",
			},
			RemoveRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
					{
						Name = "ReplacementRankName",
						Type = "string",
						IsOptional = true,
					},
				},
				Notes = "Removes the specified rank. If ReplacementRankName is given, the players that have RankName will get their rank set to ReplacementRankName. If it isn't given, or is an invalid rank, the players will be removed from the manager, their ranks will be unset completely. Logs an info message and does nothing if the rank is not found.",
			},
			RenameGroup =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "OldName",
						Type = "string",
					},
					{
						Name = "NewName",
						Type = "string",
					},
				},
				Notes = "Renames the specified group. Logs an info message and does nothing if the group is not found or the new name is already used.",
			},
			RenameRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "OldName",
						Type = "string",
					},
					{
						Name = "NewName",
						Type = "string",
					},
				},
				Notes = "Renames the specified rank. Logs an info message and does nothing if the rank is not found or the new name is already used.",
			},
			SetDefaultRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Returns =
				{
					{
						Type = "boolean",
					},
				},
				Notes = "Sets the specified rank as the default rank. Returns true on success, false on failure (rank doesn't exist).",
			},
			SetPlayerRank =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "PlayerUUID",
						Type = "string",
					},
					{
						Name = "PlayerName",
						Type = "string",
					},
					{
						Name = "RankName",
						Type = "string",
					},
				},
				Notes = "Updates the rank for the specified player. The player name is provided for reference, the UUID is used for identification. Logs a warning and does nothing if the rank is not found.",
			},
			SetRankVisuals =
			{
				IsStatic = true,
				Params =
				{
					{
						Name = "RankName",
						Type = "string",
					},
					{
						Name = "MsgPrefix",
						Type = "string",
					},
					{
						Name = "MsgSuffix",
						Type = "string",
					},
					{
						Name = "MsgNameColorCode",
						Type = "string",
					},
				},
				Notes = "Updates the rank's message visuals. Logs an info message and does nothing if rank not found.",
			},
		},
	},
}