forked from AdKats/AdKats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdKats.cs
14808 lines (13755 loc) · 788 KB
/
AdKats.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
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
/*
* AdKats - Advanced In-Game Admin and Ban Enforcer for Procon Frostbite.
*
* Copyright 2014 A Different Kind, LLC
*
* AdKats was inspired by the gaming community A Different Kind (ADK). Visit http://www.ADKGamers.com/ for more information.
*
* The AdKats Frostbite Plugin is free software: You can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version. AdKats is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. To view this license, visit http://www.gnu.org/licenses/.
*
* Code Credit:
* Modded Levenshtein Distance algorithm from Micovery's InsaneLimits
* Twitter Interaction System from Micovery's InsaneLimits
* Email System from MorpheusX(AUT)'s "Notify Me!"
*
* Development by ColColonCleaner
*
* AdKats.cs
* Version 4.0.0.0
*/
using System;
using System.Globalization;
using System.IO;
using System.Net.Mime;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Security.Cryptography;
using System.Collections;
using System.Net;
using System.Linq;
using System.Net.Mail;
using System.Threading;
using System.Diagnostics;
using MySql.Data.MySqlClient;
using PRoCon.Core;
using PRoCon.Core.Plugin;
using PRoCon.Core.Plugin.Commands;
using PRoCon.Core.Players;
using PRoCon.Core.HttpServer;
namespace PRoConEvents {
public class AdKats : PRoConPluginAPI, IPRoConPluginInterface {
#region Variables
//Current version of the plugin
private const String PluginVersion = "4.0.0.0";
//When fullDebug is enabled, on any exception slomo is activated
private const Boolean FullDebug = false;
//When slowmo is activated, there will be a 1 second pause between each print to console
//This will slow the program as a whole whenever the console is printed to
private Boolean _Slowmo = false;
//Match command showing whether AdKats is installed and running
private readonly MatchCommand _IssueCommandMatchCommand;
private readonly MatchCommand _FetchAuthorizedSoldiersMatchCommand;
//Messaging
public enum ConsoleMessageType {
Warning,
Error,
Exception,
Normal,
Success
};
//Plugin Info
private volatile Boolean _FetchedPluginInformation = false;
private volatile String _PluginVersionStatus = null;
private volatile String _PluginDescription = null;
private volatile String _PluginChangelog = null;
//Constants
//IDs of the two teams as the server understands it
private const Int32 UsTeamID = 1;
private const Int32 RuTeamID = 2;
//General Plugin Settings/Status
private volatile Boolean _IsEnabled = false;
private volatile Boolean _ThreadsReady = false;
private volatile Boolean _UseKeepAlive = false;
//Player Lists
private readonly Dictionary<String, AdKatsPlayer> _PlayerDictionary = new Dictionary<String, AdKatsPlayer>();
private DateTime _LastSuccessfulPlayerList = DateTime.UtcNow - TimeSpan.FromSeconds(5);
//player counts per team
private Int32 _UsPlayerCount = 0;
private Int32 _RuPlayerCount = 0;
//User Settings
private Dictionary<long, AdKatsUser> _UserCache = new Dictionary<long, AdKatsUser>();
private DateTime _LastUserFetch = DateTime.UtcNow;
//Frequency in seconds to fetch user changes at
private const Int32 DbUserFetchFrequency = 300;
//Database Settings
private String _MySqlHostname = "";
private String _MySqlPort = "";
private String _MySqlDatabaseName = "";
private String _MySqlUsername = "";
private String _MySqlPassword = "";
private readonly MySqlConnectionStringBuilder _DbCommStringBuilder = new MySqlConnectionStringBuilder();
private const Boolean UseConnectionPooling = true;
private const Int32 MinConnectionPoolSize = 0;
private const Int32 MaxConnectionPoolSize = 20;
private const Boolean UseCompressedConnection = false;
private volatile Boolean _DbSettingsChanged = true;
//Action fetching from database
private Boolean _FetchActionsFromDb = false;
private DateTime _LastDbActionFetch = DateTime.UtcNow;
//frequency in seconds to fetch actions at
private const Int32 DbActionFetchFrequency = 10;
//Error Catching
private Boolean _DatabaseConnectionCriticalState = false;
private const Int32 DatabaseTimeoutThreshold = 3;
private Int32 _DatabaseTimeouts = 0;
private const Int32 DatabaseSuccessThreshold = 3;
private Int32 _DatabaseSuccess = 0;
private DateTime _LastDatabaseTimeout = DateTime.UtcNow;
//Server Settings
private Int64 _ServerID = -1;
private String _ServerName = null;
private String _ServerIP = null;
private CServerInfo _ServerInfo = null;
public enum GameVersion {
BF3,
BF4
};
private GameVersion _GameVersion = GameVersion.BF3;
private Int32 _GameID = -1;
//Assume the BF3 version unless universal is detected
private String _StatLoggerVersion = "BF3";
private String _GamePatchVersion = "UNKNOWN";
private String _ServerType = "UNKNOWN";
private Boolean _FairFightEnabled = false;
private Boolean _HitIndicatorEnabled = false;
private Boolean _CommanderEnabled = false;
private Boolean _ForceReloadWholeMags = false;
private Int32 _MaxSpectators = -1;
//Setting Import
private Int64 _SettingImportID = -1;
private DateTime _LastDbSettingFetch = DateTime.UtcNow;
private const Int32 DbSettingFetchFrequency = 300;
//Round Settings
private Boolean _UseRoundTimer = false;
private Boolean _RoundEnded = false;
private Double _RoundTimeMinutes = 30;
//ADK Settings
//This will automatically change to true on ADK servers
private Boolean _IsTestingAuthorized = false;
//Experimental Tools Settings
private Boolean _UseExperimentalTools = false;
//NO EX Limiter
private Boolean _UseWeaponLimiter = false;
private String _WeaponLimiterString = "M320|RPG|SMAW|C4|M67|Claymore|FGM-148|FIM92|ROADKILL|Death|_LVG|_HE|_Frag|_XM25|_FLASH|_V40|_M34|_Flashbang|_SMK|_Smoke|_FGM148|_Grenade|_SLAM|_NLAW|_RPG7|_C4|_Claymore|_FIM92|_M67|_SMAW|_SRAW|_Sa18IGLA|_Tomahawk";
private String _WeaponLimiterExceptionString = "_Flechette|_Slug";
//Grenade Cook Catcher
private Boolean _UseGrenadeCookCatcher = false;
private Dictionary<String, AdKatsPlayer> _RoundCookers = null;
//Hacker Checker
private Boolean _UseHackerChecker = false;
private String[] _HackerCheckerWhitelist = {"ColColonCleaner"};
private Boolean _UseDpsChecker = false;
private Double _DpsTriggerLevel = 50.0;
private Boolean _UseHskChecker = false;
private Double _HskTriggerLevel = 70.0;
//Infraction Management Settings
//Whether to combine server punishments
private Boolean _CombineServerPunishments = false;
//IRO punishment setting
private Boolean _IROActive = true;
private Int32 _IROTimeout = 10;
private Boolean _IROOverridesLowPop = false;
//Default hierarchy of punishments
private String[] _PunishmentHierarchy = {"kill", "kill", "kick", "tban60", "tban120", "tbanday", "tbanweek", "tban2weeks", "tbanmonth", "ban"};
private readonly List<String> _PunishmentSeverityIndex = null;
//When punishing, only kill players when server is in low population
private Boolean _OnlyKillOnLowPop = true;
//Default for low populations
private Int32 _LowPopPlayerCount = 20;
//Ban Management Settings
//General
private Boolean _UseBanAppend = false;
private String _BanAppend = "Appeal at your_site.com";
//Ban Enforcer
private Boolean _UseBanEnforcer = false;
private String _CBanAdminName = "BanEnforcer";
private Boolean _UseBanEnforcerPreviousState = false;
private Boolean _DefaultEnforceName = false;
private Boolean _DefaultEnforceGUID = true;
private Boolean _DefaultEnforceIP = false;
private Boolean _BansQueuing = false;
private DateTime _LastBanListCall = DateTime.UtcNow;
private DateTime _LastSuccessfulBanList = DateTime.UtcNow - TimeSpan.FromSeconds(5);
private DateTime _LastDbBanFetch = DateTime.UtcNow - TimeSpan.FromSeconds(5);
private const Int32 DbBanFetchFrequency = 60;
private DateTime _PermaBanEndTime = DateTime.UtcNow.AddYears(20);
private Int64 _NameBanCount = -1;
private Int64 _GUIDBanCount = -1;
private Int64 _IPBanCount = -1;
private DateTime _LastNameBanCountFetch = DateTime.UtcNow;
private DateTime _LastGUIDBanCountFetch = DateTime.UtcNow;
private DateTime _LastIPBanCountFetch = DateTime.UtcNow;
private List<AdKatsBan> _BanEnforcerSearchResults = new List<AdKatsBan>();
//AdKats WebAdmin Settings
//This is currently a constant
private Boolean _UsingAwa = false;
//Debug Settings
private volatile Int32 _DebugLevel;
private Boolean _ToldCol = false;
//Debug Soldier (Used for displaying command action duration in-game)
private String _DebugSoldierName = "ColColonCleaner";
private DateTime _CommandStartTime = DateTime.UtcNow;
//Orchestration Settings
private Boolean _FeedMultiBalancerWhitelist = false;
private Boolean _FeedServerReservedSlots = false;
private Boolean _FeedServerSpectatorList = false;
private Boolean _FeedStatLoggerSettings = false;
private List<String> _CurrentReservedSlotPlayers = null;
private List<String> _CurrentSpectatorListPlayers = null;
private Hashtable _LastStatLoggerStatusUpdate = null;
private DateTime _LastStatLoggerStatusUpdateTime = DateTime.MinValue;
//Messaging Settings
//Pre-Message Settings
private List<String> _PreMessageList;
private Boolean _RequirePreMessageUse = false;
//Yell Settings
private Int32 _YellDuration = 5;
//Role Settings
//Dictionary of roles store by role ID (ID parsing)
private readonly Dictionary<long, AdKatsRole> _RoleIDDictionary = new Dictionary<long, AdKatsRole>();
//Dictionary of roles stored by role key (Raw key parsing)
private readonly Dictionary<String, AdKatsRole> _RoleKeyDictionary = new Dictionary<String, AdKatsRole>();
//Dictionary of roles stored by role id (Setting parsing)
private readonly Dictionary<String, AdKatsRole> _RoleNameDictionary = new Dictionary<String, AdKatsRole>();
//In-Game Command Settings
//Dictionary of commands store by command ID (database parsing)
private readonly Dictionary<long, AdKatsCommand> _CommandIDDictionary = new Dictionary<long, AdKatsCommand>();
//Dictionary of commands stored by command key (Source parsing)
private readonly Dictionary<String, AdKatsCommand> _CommandKeyDictionary = new Dictionary<String, AdKatsCommand>();
//Dictionary of commands stored by command id (Name parsing)
private readonly Dictionary<String, AdKatsCommand> _CommandNameDictionary = new Dictionary<String, AdKatsCommand>();
//Dictionary of commands stored by command text (In-game parsing)
private readonly Dictionary<String, AdKatsCommand> _CommandTextDictionary = new Dictionary<String, AdKatsCommand>();
//Default required reason length for admins
private Int32 _RequiredReasonLength = 4;
//Whether commands parse via admin.say will be allowed
private Boolean _AllowAdminSayCommands = true;
//External Access Settings
private String _ExternalCommandAccessKey = "NoPasswordSet";
//TeamSwap Settings
//The list of players on RU wishing to move to US (This list takes first priority)
private Queue<CPlayerInfo> _UsMoveQueue = new Queue<CPlayerInfo>();
//the list of players on US wishing to move to RU (This list takes secondary)
private Queue<CPlayerInfo> _RuMoveQueue = new Queue<CPlayerInfo>();
//the lowest ticket count of either team
private volatile Int32 _LowestTicketCount = 500000;
//the highest ticket count of either team
private volatile Int32 _HighestTicketCount = 0;
private volatile Int32 _UsTicketCount = 0;
private volatile Int32 _RuTicketCount = 0;
//the highest ticket count of either team to allow self move
private Int32 _TeamSwapTicketWindowHigh = 500000;
//the lowest ticket count of either team to allow self move
private Int32 _TeamSwapTicketWindowLow = 0;
//Round only whitelist
private Dictionary<String, bool> _TeamswapRoundWhitelist = new Dictionary<String, bool>();
//Number of random players to whitelist at the beginning of the round
private Int32 _PlayersToAutoWhitelist = 2;
//Force move action queue
private readonly Queue<CPlayerInfo> _TeamswapForceMoveQueue = new Queue<CPlayerInfo>();
//Delayed move list
private Dictionary<String, CPlayerInfo> _TeamswapOnDeathMoveDic = new Dictionary<String, CPlayerInfo>();
//Delayed move checking queue
private readonly Queue<CPlayerInfo> _TeamswapOnDeathCheckingQueue = new Queue<CPlayerInfo>();
//Report/Admin Call Settings
//Reports for the current round
private Dictionary<String, AdKatsRecord> _RoundReports = new Dictionary<String, AdKatsRecord>();
//Player Mute Settings
private String _MutedPlayerMuteMessage = "You have been muted by an admin, talking will cause punishment. You can speak again next round.";
private String _MutedPlayerKillMessage = "Do not talk while muted. You can speak again next round.";
private String _MutedPlayerKickMessage = "Talking excessively while muted.";
private Int32 _MutedPlayerChances = 5;
private Dictionary<String, Int32> _RoundMutedPlayers = new Dictionary<String, Int32>();
//Admin Assistant Settings
private Boolean _EnableAdminAssistantPerk = true;
private Int32 _MinimumRequiredMonthlyReports = 10;
//Twitter Settings
/*
private Boolean _UseTwitter = false;
*/
/*
private TwitterHandler _TwitterHandler = null;
*/
//Email Settings
private Boolean _UseEmail = false;
private EmailHandler _EmailHandler = null;
//Multi-Threading Settings
//Threads
private Thread _PlayerListingThread;
private Thread _KillProcessingThread;
private Thread _MessageProcessingThread;
private Thread _CommandParsingThread;
private Thread _DatabaseCommunicationThread;
private Thread _ActionHandlingThread;
private Thread _TeamSwapThread;
private Thread _BanEnforcerThread;
private Thread _HackerCheckerThread;
private Thread _Activator;
private Thread _Finalizer;
private Thread _DisconnectHandlingThread;
private Thread _RoundTimerThread;
//Mutexes
private readonly Object _PlayersMutex = new Object();
/*
private Object _KillProcessingMutex = new Object();
*/
/*
private Object _BanListMutex = new Object();
*/
private readonly Object _ReportsMutex = new Object();
private readonly Object _ActionConfirmMutex = new Object();
private readonly Object _UserMutex = new Object();
private readonly Object _TeamswapMutex = new Object();
private readonly Object _ServerInfoMutex = new Object();
private readonly Object _UnparsedMessageMutex = new Object();
private readonly Object _UnparsedCommandMutex = new Object();
private readonly Object _UnprocessedRecordMutex = new Object();
private readonly Object _UnprocessedActionMutex = new Object();
private readonly Object _BanEnforcerMutex = new Object();
private readonly Object _HackerCheckerMutex = new Object();
private readonly Object _RoundEndingMutex = new Object();
//Handles
private EventWaitHandle _TeamswapWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _PlayerListProcessingWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _KillProcessingWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _PlayerListUpdateWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _MessageParsingWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _CommandParsingWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _DbCommunicationWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _ActionHandlingWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _BanEnforcerWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _ServerInfoWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _StatLoggerStatusWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _HackerCheckerWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _WeaponStatsWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _PluginDescriptionWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle _RoundEndingWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
//Threading Queues
private readonly Queue<List<CPlayerInfo>> _PlayerListProcessingQueue = new Queue<List<CPlayerInfo>>();
private readonly Queue<Kill> _KillProcessingQueue = new Queue<Kill>();
private readonly Queue<KeyValuePair<String, String>> _UnparsedMessageQueue = new Queue<KeyValuePair<String, String>>();
private readonly Queue<KeyValuePair<String, String>> _UnparsedCommandQueue = new Queue<KeyValuePair<String, String>>();
private readonly Queue<AdKatsRecord> _UnprocessedRecordQueue = new Queue<AdKatsRecord>();
private readonly Queue<AdKatsRecord> _UnprocessedActionQueue = new Queue<AdKatsRecord>();
private readonly Queue<AdKatsUser> _UserUploadQueue = new Queue<AdKatsUser>();
private readonly Queue<AdKatsUser> _UserRemovalQueue = new Queue<AdKatsUser>();
private readonly Queue<AdKatsPlayer> _BanEnforcerCheckingQueue = new Queue<AdKatsPlayer>();
private readonly Queue<AdKatsPlayer> _HackerCheckerQueue = new Queue<AdKatsPlayer>();
private readonly Queue<AdKatsBan> _BanEnforcerProcessingQueue = new Queue<AdKatsBan>();
private readonly Queue<CBanInfo> _CBanProcessingQueue = new Queue<CBanInfo>();
private readonly Queue<CPluginVariable> _SettingUploadQueue = new Queue<CPluginVariable>();
private readonly Queue<AdKatsCommand> _CommandUploadQueue = new Queue<AdKatsCommand>();
private readonly Queue<AdKatsCommand> _CommandRemovalQueue = new Queue<AdKatsCommand>();
private readonly Queue<AdKatsRole> _RoleUploadQueue = new Queue<AdKatsRole>();
private readonly Queue<AdKatsRole> _RoleRemovalQueue = new Queue<AdKatsRole>();
//MISC Settings
private Boolean _ShowAdminNameInSay = false;
private Boolean _WeaponCodesTableTested = false;
private Boolean _WeaponCodesTableConfirmed = false;
//When an action requires confirmation, this dictionary holds those actions until player confirms action
private Dictionary<String, AdKatsRecord> _ActionConfirmDic = new Dictionary<String, AdKatsRecord>();
//Action will be taken when the player next spawns
private Dictionary<String, AdKatsRecord> _ActOnSpawnDictionary = new Dictionary<String, AdKatsRecord>();
//VOIP information
private String _ServerVoipAddress = "(TS3) TS.ADKGamers.com:3796";
//Rules information
private Double _ServerRulesDelay = 0.5;
private Double _ServerRulesInterval = 5;
private String[] _ServerRulesList = {"This server has not set rules yet.", "This server has not set rules yet.", "This server has not set rules yet."};
//Hacker Checker
private StatLibrary _StatLibrary = null;
private String _HackerCheckerDPSBanMessage = "Hacking/Cheating DPS Automatic Ban";
private String _HackerCheckerHSKBanMessage = "Hacking/Cheating HSK Automatic Ban";
#endregion
public AdKats() {
//Set defaults for webclient
System.Net.ServicePointManager.Expect100Continue = false;
//By default plugin is not enabled or ready
this._IsEnabled = false;
this._ThreadsReady = false;
//Assign the match commands
this._IssueCommandMatchCommand = new MatchCommand("AdKats", "IssueCommand", new List<String>(), "AdKats_IssueCommand", new List<MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.None), "Useable by other plugins to call AdKats commands.");
this._FetchAuthorizedSoldiersMatchCommand = new MatchCommand("AdKats", "FetchAuthorizedSoldiers", new List<String>(), "AdKats_FetchAuthorizedSoldiers", new List<MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.None), "Useable by other plugins to fetch authorized soldiers.");
//Debug level is 0 by default
this._DebugLevel = 0;
//Randomize the external access key
this._ExternalCommandAccessKey = AdKats.GetRandom32BitHashCode();
//Init the punishment severity index
this._PunishmentSeverityIndex = new List<String> {
"kill",
"kick",
"tban60",
"tban120",
"tbanday",
"tbanweek",
"tban2weeks",
"tbanmonth",
"ban"
};
//Init the pre-message list
this._PreMessageList = new List<String> {
"US TEAM: DO NOT BASERAPE, YOU WILL BE PUNISHED.",
"RU TEAM: DO NOT BASERAPE, YOU WILL BE PUNISHED.",
"US TEAM: DO NOT ENTER THE STREETS BEYOND 'A', YOU WILL BE PUNISHED.",
"RU TEAM: DO NOT GO BEYOND THE BLACK LINE ON CEILING BY 'C' FLAG, YOU WILL BE PUNISHED.",
"THIS SERVER IS NO EXPLOSIVES, YOU WILL BE PUNISHED FOR INFRACTIONS.",
"JOIN OUR TEAMSPEAK AT TS.ADKGAMERS.COM:3796"
};
//Fetch the plugin description and changelog
this.FetchPluginDescAndChangelog();
//Prepare the keep-alive
this.SetupKeepAlive();
}
#region Plugin details
public String GetPluginName() {
return "AdKats - Advanced In-Game Admin";
}
public String GetPluginVersion() {
return PluginVersion;
}
public String GetPluginAuthor() {
return "[ADK]ColColonCleaner";
}
public String GetPluginWebsite() {
return "https://github.com/ColColonCleaner/AdKats/";
}
public String GetPluginDescription() {
if (!this._FetchedPluginInformation) {
//Wait up to 10 seconds for the description to fetch
this.DebugWrite("Waiting for plugin description...", 1);
if (!this._PluginDescriptionWaitHandle.WaitOne(10000)) {
this.ConsoleError("Unable to fetch plugin description.");
}
}
//Parse out the descriptions
String concat = String.Empty;
if (!String.IsNullOrEmpty(this._PluginVersionStatus)) {
concat += this._PluginVersionStatus;
}
if (!String.IsNullOrEmpty(this._PluginDescription)) {
concat += this._PluginDescription;
}
if (!String.IsNullOrEmpty(this._PluginChangelog)) {
concat += this._PluginChangelog;
}
//Check if the description fetched
if (String.IsNullOrEmpty(concat)) {
concat = "Plugin description failed to download. Please visit AdKats on github to view the plugin description.";
}
return concat;
}
private void FetchPluginDescAndChangelog()
{
this._PluginDescriptionWaitHandle.Reset();
//Create a new thread to fetch the plugin description and changelog
Thread descFetcher = new Thread(new ThreadStart(delegate
{
try
{
//Create web client
WebClient client = new WebClient();
//Download the readme and changelog
this.DebugWrite("Fetching plugin readme...", 2);
try
{
this._PluginDescription = client.DownloadString("https://raw.github.com/ColColonCleaner/AdKats/master/README.md");
this.DebugWrite("Plugin description fetched.", 1);
}
catch (Exception)
{
this.ConsoleError("Failed to fetch plugin description.");
}
this.DebugWrite("Fetching plugin changelog...", 2);
try
{
this._PluginChangelog = client.DownloadString("https://raw.github.com/ColColonCleaner/AdKats/master/CHANGELOG.md");
this.DebugWrite("Plugin changelog fetched.", 1);
}
catch (Exception)
{
this.ConsoleError("Failed to fetch plugin changelog.");
}
if (this._PluginDescription != "DESCRIPTION FETCH FAILED|")
{
//Extract the latest stable version
String latestStableVersion = this.ExtractString(this._PluginDescription, "latest_stable_release");
if (!String.IsNullOrEmpty(latestStableVersion))
{
//Convert it to an integer
String trimmedLatestStableVersion = latestStableVersion.Replace(".", "");
Int32 latestStableVersionInt = Int32.Parse(trimmedLatestStableVersion);
//Get current plugin version
Int32 currentVersionInt = Int32.Parse(PluginVersion.Replace(".", ""));
String versionStatus = String.Empty;
//Add the appropriate message to plugin description
if (latestStableVersionInt > currentVersionInt)
{
versionStatus = @"
<h2 style='color:#DF0101;'>
You are running an outdated build of AdKats! Version " + latestStableVersion + @" is available for download!
</h2>
<a href='https://github.com/ColColonCleaner/AdKats/blob/master/CHANGELOG.md' target='_blank'>
New in Version " + latestStableVersion + @"!
</a><br/>
Download link below.";
}
else if (latestStableVersionInt == currentVersionInt)
{
versionStatus = @"
<h2 style='color:#01DF01;'>
Congrats! You are running the latest stable build of AdKats!
</h2>";
}
else if (latestStableVersionInt < currentVersionInt)
{
versionStatus = @"
<h2 style='color:#FF8000;'>
CAUTION! You are running a BETA or TEST build of AdKats! Functionality might be untested.
</h2> Below documentation is for stable build " + latestStableVersion + ".";
}
//Prepend the message
this._PluginVersionStatus = versionStatus;
}
}
this.DebugWrite("Setting desc fetch handle.", 1);
this._FetchedPluginInformation = true;
this._PluginDescriptionWaitHandle.Set();
}
catch (Exception e)
{
this.HandleException(new AdKatsException("Error while fetching plugin description and changelog.", e));
}
}));
//Start the thread
descFetcher.Start();
}
private void FetchWeaponStats()
{
this._WeaponStatsWaitHandle.Reset();
//Create a new thread to fetch the plugin description and changelog
Thread descFetcher = new Thread(new ThreadStart(delegate
{
try
{
//Create web client
WebClient client = new WebClient();
//Download the readme and changelog
this.DebugWrite("Fetching weapon stats...", 2);
try
{
this._PluginDescription = client.DownloadString("https://raw.github.com/ColColonCleaner/AdKats/master/adkatsweaponstats.json");
this.DebugWrite("Weapon stats fetched.", 1);
}
catch (Exception)
{
this.ConsoleError("Failed to fetch weapon stats.");
}
if (this._PluginDescription != "DESCRIPTION FETCH FAILED|")
{
}
this.DebugWrite("Setting weapon stat fetch handle.", 1);
this._WeaponStatsWaitHandle.Set();
}
catch (Exception e)
{
this.HandleException(new AdKatsException("Error while fetching plugin description and changelog.", e));
}
}));
//Start the thread
descFetcher.Start();
}
private void SetupKeepAlive() {
//Create a new thread to handle keep-alive
//This thread will remain running for the duration the layer is online
Thread keepAliveThread = new Thread(new ThreadStart(delegate {
try {
while (true) {
Thread.Sleep(TimeSpan.FromSeconds(60));
if (this._UseKeepAlive) {
this.Enable();
}
}
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error while running keep-alive.", e));
}
}));
//Start the thread
keepAliveThread.Start();
}
#endregion
#region Plugin setting
public List<CPluginVariable> GetDisplayPluginVariables() {
try
{
List<CPluginVariable> lstReturn;
const string separator = " | ";
//Only fetch the following settings when plugin disabled
if (!this._ThreadsReady)
{
lstReturn = new List<CPluginVariable>();
if (this._UseKeepAlive)
{
lstReturn.Add(new CPluginVariable("0. Instance Settings|Auto-Enable/Keep-Alive", typeof(Boolean), true));
}
lstReturn.Add(new CPluginVariable("Complete these settings before enabling.", typeof(String), "Once enabled, more settings will appear."));
//SQL Settings
lstReturn.Add(new CPluginVariable("1. MySQL Settings|MySQL Hostname", typeof(String), this._MySqlHostname));
lstReturn.Add(new CPluginVariable("1. MySQL Settings|MySQL Port", typeof(String), this._MySqlPort));
lstReturn.Add(new CPluginVariable("1. MySQL Settings|MySQL Database", typeof(String), this._MySqlDatabaseName));
lstReturn.Add(new CPluginVariable("1. MySQL Settings|MySQL Username", typeof(String), this._MySqlUsername));
lstReturn.Add(new CPluginVariable("1. MySQL Settings|MySQL Password", typeof(String), this._MySqlPassword));
//Debugging Settings
lstReturn.Add(new CPluginVariable("2. Debugging|Debug level", typeof(Int32), this._DebugLevel));
}
else
{
//If plugin is enabled, return the full storage list
lstReturn = this.GetPluginVariables();
//Add display variables
//Server Settings
lstReturn.Add(new CPluginVariable("1. Server Settings|Server ID (Display)", typeof(int), this._ServerID));
lstReturn.Add(new CPluginVariable("1. Server Settings|Server IP (Display)", typeof(String), this._ServerIP));
lstReturn.Add(new CPluginVariable("1. Server Settings|Setting Import", typeof(String), this._ServerID));
if (!this._UsingAwa)
{
const string userSettingsPrefix = "3. User Settings|";
//User Settings
lstReturn.Add(new CPluginVariable(userSettingsPrefix + "Add User", typeof(String), ""));
if (this._UserCache.Count > 0)
{
//Sort access list by access level, then by id
List<AdKatsUser> tempAccess = this._UserCache.Values.ToList();
tempAccess.Sort((a1, a2) => (a1.user_role.role_id == a2.user_role.role_id) ? (System.String.CompareOrdinal(a1.user_name, a2.user_name)) : ((a1.user_role.role_id < a2.user_role.role_id) ? (-1) : (1)));
String roleEnum = String.Empty;
if (this._RoleKeyDictionary.Count > 0)
{
Random random = new Random();
foreach (AdKatsRole role in this._RoleKeyDictionary.Values)
{
if (String.IsNullOrEmpty(roleEnum))
{
roleEnum += "enum.RoleEnum_" + random.Next(100000, 999999) + "(";
}
else
{
roleEnum += "|";
}
roleEnum += role.role_name;
}
roleEnum += ")";
}
foreach (AdKatsUser user in tempAccess)
{
String userPrefix = userSettingsPrefix + "USR" + user.user_id + separator + user.user_name + separator;
if (this._UseEmail)
{
lstReturn.Add(new CPluginVariable(userPrefix + "User Email", typeof(String), user.user_email));
}
//Do not display phone input until that operation is available for use
//lstReturn.Add(new CPluginVariable(userPrefix + "User Phone", typeof(String), user.user_phone));
lstReturn.Add(new CPluginVariable(userPrefix + "User Role", roleEnum, user.user_role.role_name));
lstReturn.Add(new CPluginVariable(userPrefix + "Delete User?", typeof(String), ""));
lstReturn.Add(new CPluginVariable(userPrefix + "Add Soldier?", typeof(String), ""));
String soldierPrefix = userPrefix + "Soldiers" + separator;
lstReturn.AddRange(user.soldierDictionary.Values.Select(aPlayer => new CPluginVariable(soldierPrefix + aPlayer.player_id + separator + aPlayer.player_name + separator + "Delete Soldier?", typeof(String), "")));
}
}
else
{
lstReturn.Add(new CPluginVariable(userSettingsPrefix + "No Users in User List", typeof(String), "Add Users with 'Add User'."));
}
lstReturn.Add(new CPluginVariable("5. Command Settings|Minimum Required Reason Length", typeof(int), this._RequiredReasonLength));
lstReturn.Add(new CPluginVariable("5. Command Settings|Allow Commands from Admin Say", typeof(Boolean), this._AllowAdminSayCommands));
//Role Settings
const string roleListPrefix = "4. Role Settings|";
lstReturn.Add(new CPluginVariable(roleListPrefix + "Add Role", typeof(String), ""));
if (this._RoleKeyDictionary.Count > 0)
{
lock (this._RoleKeyDictionary)
{
foreach (AdKatsRole aRole in this._RoleKeyDictionary.Values)
{
lock (this._CommandNameDictionary)
{
String rolePrefix = roleListPrefix + "RLE" + aRole.role_id + separator + aRole.role_name + separator;
lstReturn.AddRange(from aCommand in this._CommandNameDictionary.Values where aCommand.command_active == AdKatsCommand.CommandActive.Active select new CPluginVariable(rolePrefix + "CDE" + aCommand.command_id + separator + aCommand.command_name, "enum.roleAllowCommandEnum(Allow|Deny)", aRole.allowedCommands.ContainsKey(aCommand.command_key) ? ("Allow") : ("Deny")));
//Do not display the delete option for default guest
if (aRole.role_key != "guest_default")
{
lstReturn.Add(new CPluginVariable(rolePrefix + "Delete Role? (All assignments will be removed)", typeof(String), ""));
}
}
}
}
}
else
{
lstReturn.Add(new CPluginVariable(roleListPrefix + "Role List Empty", typeof(String), "No valid roles found in database."));
}
//Command Settings
const string commandListPrefix = "6. Command List|";
if (this._CommandNameDictionary.Count > 0)
{
foreach (AdKatsCommand command in this._CommandNameDictionary.Values)
{
if (command.command_active != AdKatsCommand.CommandActive.Invisible)
{
String commandPrefix = commandListPrefix + "CDE" + command.command_id + separator + command.command_name + separator;
lstReturn.Add(new CPluginVariable(commandPrefix + "Active", "enum.commandActiveEnum(Active|Disabled)", command.command_active.ToString()));
if (command.command_active != AdKatsCommand.CommandActive.Disabled)
{
if (command.command_logging != AdKatsCommand.CommandLogging.Mandatory && command.command_logging != AdKatsCommand.CommandLogging.Unable)
{
lstReturn.Add(new CPluginVariable(commandPrefix + "Logging", "enum.commandLoggingEnum(Log|Ignore)", command.command_logging.ToString()));
}
lstReturn.Add(new CPluginVariable(commandPrefix + "Text", typeof(String), command.command_text));
}
}
}
}
else
{
lstReturn.Add(new CPluginVariable(commandListPrefix + "Command List Empty", typeof(String), "No valid commands found in database."));
}
}
else
{
lstReturn.Add(new CPluginVariable("3. Player Access Settings|You are using AdKats WebAdmin", typeof(String), "Manage admin settings there."));
}
if (this._UseBanEnforcer)
{
const string banManagementPrefix = "A13-3. Mini Ban Management|";
lstReturn.Add(new CPluginVariable(banManagementPrefix + "NAME Ban Count", typeof(int), this._NameBanCount));
lstReturn.Add(new CPluginVariable(banManagementPrefix + "GUID Ban Count", typeof(int), this._GUIDBanCount));
lstReturn.Add(new CPluginVariable(banManagementPrefix + "IP Ban Count", typeof(int), this._IPBanCount));
lstReturn.Add(new CPluginVariable(banManagementPrefix + "Ban Search", typeof(String), ""));
lstReturn.AddRange(this._BanEnforcerSearchResults.Select(aBan => new CPluginVariable(banManagementPrefix + "BAN" + aBan.ban_id + separator + aBan.ban_record.target_name + separator + aBan.ban_record.record_message, "enum.commandActiveEnum(Active|Disabled|Expired)", aBan.ban_status)));
}
}
return lstReturn;
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error while fetching display vars.", e));
return new List<CPluginVariable>();
}
}
public List<CPluginVariable> GetPluginVariables() {
List<CPluginVariable> lstReturn = new List<CPluginVariable>();
const string separator = " | ";
try {
//Auto-Enable Settings
lstReturn.Add(new CPluginVariable("0. Instance Settings|Auto-Enable/Keep-Alive", typeof (Boolean), this._UseKeepAlive));
//SQL Settings
lstReturn.Add(new CPluginVariable("2. MySQL Settings|MySQL Hostname", typeof (String), _MySqlHostname));
lstReturn.Add(new CPluginVariable("2. MySQL Settings|MySQL Port", typeof (String), _MySqlPort));
lstReturn.Add(new CPluginVariable("2. MySQL Settings|MySQL Database", typeof (String), _MySqlDatabaseName));
lstReturn.Add(new CPluginVariable("2. MySQL Settings|MySQL Username", typeof (String), _MySqlUsername));
lstReturn.Add(new CPluginVariable("2. MySQL Settings|MySQL Password", typeof (String), _MySqlPassword));
//Punishment Settings
lstReturn.Add(new CPluginVariable("7. Punishment Settings|Punishment Hierarchy", typeof (String[]), this._PunishmentHierarchy));
lstReturn.Add(new CPluginVariable("7. Punishment Settings|Combine Server Punishments", typeof (Boolean), this._CombineServerPunishments));
lstReturn.Add(new CPluginVariable("7. Punishment Settings|Only Kill Players when Server in low population", typeof (Boolean), this._OnlyKillOnLowPop));
if (this._OnlyKillOnLowPop) {
lstReturn.Add(new CPluginVariable("7. Punishment Settings|Low Population Value", typeof (int), this._LowPopPlayerCount));
}
lstReturn.Add(new CPluginVariable("7. Punishment Settings|Use IRO Punishment", typeof (Boolean), this._IROActive));
if (this._IROActive) {
lstReturn.Add(new CPluginVariable("7. Punishment Settings|IRO Timeout Minutes", typeof (Int32), this._IROTimeout));
lstReturn.Add(new CPluginVariable("7. Punishment Settings|IRO Punishment Overrides Low Pop", typeof (Boolean), this._IROOverridesLowPop));
}
//Email Settings
lstReturn.Add(new CPluginVariable("8. Email Settings|Send Emails", typeof (bool), this._UseEmail));
if (this._UseEmail) {
lstReturn.Add(new CPluginVariable("8. Email Settings|Use SSL?", typeof (Boolean), this._EmailHandler.UseSSL));
lstReturn.Add(new CPluginVariable("8. Email Settings|SMTP-Server address", typeof (String), this._EmailHandler.SMTPServer));
lstReturn.Add(new CPluginVariable("8. Email Settings|SMTP-Server port", typeof (int), this._EmailHandler.SMTPPort));
lstReturn.Add(new CPluginVariable("8. Email Settings|Sender address", typeof (String), this._EmailHandler.SenderEmail));
lstReturn.Add(new CPluginVariable("8. Email Settings|SMTP-Server username", typeof(String), this._EmailHandler.SMTPUser));
lstReturn.Add(new CPluginVariable("8. Email Settings|SMTP-Server password", typeof(String), this._EmailHandler.SMTPPassword));
lstReturn.Add(new CPluginVariable("8. Email Settings|Custom HTML Addition", typeof(String), this._EmailHandler.CustomHTMLAddition));
lstReturn.Add(new CPluginVariable("8. Email Settings|Extra Recipient Email Addresses", typeof (String[]), this._EmailHandler.RecipientEmails.ToArray()));
}
//TeamSwap Settings
lstReturn.Add(new CPluginVariable("9. TeamSwap Settings|Auto-Whitelist Count", typeof (String), this._PlayersToAutoWhitelist));
lstReturn.Add(new CPluginVariable("9. TeamSwap Settings|Ticket Window High", typeof (int), this._TeamSwapTicketWindowHigh));
lstReturn.Add(new CPluginVariable("9. TeamSwap Settings|Ticket Window Low", typeof (int), this._TeamSwapTicketWindowLow));
//Admin Assistant Settings
lstReturn.Add(new CPluginVariable("A10. Admin Assistant Settings|Enable Admin Assistant Perk", typeof (Boolean), this._EnableAdminAssistantPerk));
lstReturn.Add(new CPluginVariable("A10. Admin Assistant Settings|Minimum Confirmed Reports Per Month", typeof (int), this._MinimumRequiredMonthlyReports));
//Muting Settings
lstReturn.Add(new CPluginVariable("A11. Player Mute Settings|On-Player-Muted Message", typeof (String), this._MutedPlayerMuteMessage));
lstReturn.Add(new CPluginVariable("A11. Player Mute Settings|On-Player-Killed Message", typeof (String), this._MutedPlayerKillMessage));
lstReturn.Add(new CPluginVariable("A11. Player Mute Settings|On-Player-Kicked Message", typeof (String), this._MutedPlayerKickMessage));
lstReturn.Add(new CPluginVariable("A11. Player Mute Settings|# Chances to give player before kicking", typeof (int), this._MutedPlayerChances));
//Message Settings
lstReturn.Add(new CPluginVariable("A12. Messaging Settings|Display Admin Name in Kick and Ban Announcement", typeof (Boolean), this._ShowAdminNameInSay));
lstReturn.Add(new CPluginVariable("A12. Messaging Settings|Yell display time seconds", typeof (int), this._YellDuration));
lstReturn.Add(new CPluginVariable("A12. Messaging Settings|Pre-Message List", typeof (String[]), this._PreMessageList.ToArray()));
lstReturn.Add(new CPluginVariable("A12. Messaging Settings|Require Use of Pre-Messages", typeof (Boolean), this._RequirePreMessageUse));
//Ban Settings
lstReturn.Add(new CPluginVariable("A13. Banning Settings|Use Additional Ban Message", typeof (Boolean), this._UseBanAppend));
if (this._UseBanAppend) {
lstReturn.Add(new CPluginVariable("A13. Banning Settings|Additional Ban Message", typeof (String), this._BanAppend));
}
lstReturn.Add(new CPluginVariable("A13. Banning Settings|Procon Ban Admin Name", typeof (String), this._CBanAdminName));
const string banEnforcerPrefix = "A13-2. Ban Enforcer Settings|";
if (!this._UsingAwa) {
lstReturn.Add(new CPluginVariable(banEnforcerPrefix + "Use Ban Enforcer", typeof(Boolean), this._UseBanEnforcer));
}
if (this._UseBanEnforcer) {
lstReturn.Add(new CPluginVariable(banEnforcerPrefix + "Enforce New Bans by NAME", typeof(Boolean), this._DefaultEnforceName));
lstReturn.Add(new CPluginVariable(banEnforcerPrefix + "Enforce New Bans by GUID", typeof(Boolean), this._DefaultEnforceGUID));
lstReturn.Add(new CPluginVariable(banEnforcerPrefix + "Enforce New Bans by IP", typeof(Boolean), this._DefaultEnforceIP));
}
//External Command Settings
lstReturn.Add(new CPluginVariable("A14. External Command Settings|HTTP External Access Key", typeof (String), this._ExternalCommandAccessKey));
if (!this._UseBanEnforcer && !this._UsingAwa) {
lstReturn.Add(new CPluginVariable("A14. External Command Settings|Fetch Actions from Database", typeof (Boolean), this._FetchActionsFromDb));
}
lstReturn.Add(new CPluginVariable("A15. VOIP Settings|Server VOIP Address", typeof (String), this._ServerVoipAddress));
lstReturn.Add(new CPluginVariable("A16. Orchestration Settings|Feed MULTIBalancer Whitelist", typeof(Boolean), this._FeedMultiBalancerWhitelist));
lstReturn.Add(new CPluginVariable("A16. Orchestration Settings|Feed Server Reserved Slots", typeof(Boolean), this._FeedServerReservedSlots));
lstReturn.Add(new CPluginVariable("A16. Orchestration Settings|Feed Server Spectator List", typeof(Boolean), this._FeedServerSpectatorList));
lstReturn.Add(new CPluginVariable("A16. Orchestration Settings|Feed Stat Logger Settings", typeof (Boolean), this._FeedStatLoggerSettings));
lstReturn.Add(new CPluginVariable("A17. Round Settings|Round Timer: Enable", typeof (Boolean), this._UseRoundTimer));
if (this._UseRoundTimer) {
lstReturn.Add(new CPluginVariable("A17. Round Settings|Round Timer: Round Duration Minutes", typeof (Double), this._RoundTimeMinutes));
}
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: Enable", typeof (Boolean), this._UseHackerChecker));
if (this._UseHackerChecker) {
if (this._IsTestingAuthorized) {
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|Hacker-Check Player", typeof (String), ""));
}
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: Whitelist", typeof (String[]), this._HackerCheckerWhitelist));
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: DPS Checker: Enable", typeof (Boolean), this._UseDpsChecker));
if (this._UseDpsChecker) {
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: DPS Checker: Trigger Level", typeof(Double), this._DpsTriggerLevel));
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: DPS Checker: Ban Message", typeof(String), this._HackerCheckerDPSBanMessage));
}
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: HSK Checker: Enable", typeof (Boolean), this._UseHskChecker));
if (this._UseHskChecker) {
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: HSK Checker: Trigger Level", typeof(Double), this._HskTriggerLevel));
lstReturn.Add(new CPluginVariable("A18. Internal Hacker-Checker Settings|HackerChecker: HSK Checker: Ban Message", typeof(String), this._HackerCheckerHSKBanMessage));
}
}
//Server rules Settings
lstReturn.Add(new CPluginVariable("A19. Server Rules Settings|Rule Print Delay", typeof (Double), this._ServerRulesDelay));
lstReturn.Add(new CPluginVariable("A19. Server Rules Settings|Rule Print Interval", typeof (Double), this._ServerRulesInterval));
lstReturn.Add(new CPluginVariable("A19. Server Rules Settings|Server Rule List", typeof (String[]), this._ServerRulesList));
//Debug settings
lstReturn.Add(new CPluginVariable("Z99. Debugging|Debug level", typeof (int), this._DebugLevel));
lstReturn.Add(new CPluginVariable("Z99. Debugging|Debug Soldier Name", typeof (String), this._DebugSoldierName));
lstReturn.Add(new CPluginVariable("Z99. Debugging|Command Entry", typeof (String), ""));
//Experimental tools
if (this._IsTestingAuthorized) {
lstReturn.Add(new CPluginVariable("X99. Experimental|Use Experimental Tools", typeof (Boolean), this._UseExperimentalTools));
if (this._UseExperimentalTools) {
lstReturn.Add(new CPluginVariable("X99. Experimental|Send Query", typeof (String), ""));
lstReturn.Add(new CPluginVariable("X99. Experimental|Send Non-Query", typeof (String), ""));
lstReturn.Add(new CPluginVariable("X99. Experimental|Use NO EXPLOSIVES Limiter", typeof (Boolean), this._UseWeaponLimiter));
if (this._UseWeaponLimiter) {
lstReturn.Add(new CPluginVariable("X99. Experimental|NO EXPLOSIVES Weapon String", typeof (String), this._WeaponLimiterString));
lstReturn.Add(new CPluginVariable("X99. Experimental|NO EXPLOSIVES Exception String", typeof (String), this._WeaponLimiterExceptionString));
}
lstReturn.Add(new CPluginVariable("X99. Experimental|Use Grenade Cook Catcher", typeof (Boolean), this._UseGrenadeCookCatcher));
}
}
}
catch (Exception e) {
this.HandleException(new AdKatsException("Error While Fetching Settings", e));
}
return lstReturn;
}
public void SetPluginVariable(String strVariable, String strValue) {
if (strValue == null) {
return;
}
try {
//this.ConsoleWrite("'" + strVariable + "' -> '" + strValue + "'");
if (strVariable == "UpdateSettings") {
//Do nothing. Settings page will be updated after return.
}
else if (Regex.Match(strVariable, @"Auto-Enable/Keep-Alive").Success) {
Boolean autoEnable = Boolean.Parse(strValue);
if (autoEnable != this._UseKeepAlive) {
if(autoEnable)
this.Enable();
this._UseKeepAlive = autoEnable;
//Once setting has been changed, upload the change to database
this.QueueSettingForUpload(new CPluginVariable(@"Auto-Enable/Keep-Alive", typeof (Boolean), this._UseKeepAlive));
}
}
else if (Regex.Match(strVariable, @"Send Query").Success) {
this.SendQuery(strValue, true);
}
else if (Regex.Match(strVariable, @"Send Non-Query").Success) {
this.SendNonQuery("Experimental Query", strValue, true);
}
else if (Regex.Match(strVariable, @"Hacker-Check Player").Success) {
if (String.IsNullOrEmpty(strValue) || !this._ThreadsReady) {
return;
}
this.ConsoleWarn("Preparing to hacker check " + strValue);
if (String.IsNullOrEmpty(strValue) || strValue.Length < 3) {
this.ConsoleError("Player name must be at least 3 characters long.");