forked from AdKats/AdKats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdKats.cs
9560 lines (8822 loc) · 455 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 is a MySQL reflected admin tool for Procon Frostbite. It includes editable in-game commands, database
* reflected punishment and forgiveness, proper player report and admin call handling, player name completion,
* player muting, yell/say pre-recording, and internal implementation of TeamSwap. It requires a MySQL Database
* connection for proper use, and will set up needed tables in the database if they are not there already.
*
* Copyright 2013 A Different Kind, LLC
*
* AdKats was inspired by the gaming community A Different Kind (ADK), with help from the BF3 Admins within the
* community. 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
* Threading Examples from Micovery's InsaneLimits
* Email System from "Notify Me!" By MorpheusX(AUT)
* Twitter Post System from Micovery's InsaneLimits
*
* AdKats.cs
*/
using System;
using System.IO;
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.Net.Mail;
using System.Web;
using System.Data;
using System.Threading;
using System.Timers;
using System.Diagnostics;
using System.Reflection;
using MySql.Data.MySqlClient;
using PRoCon.Core;
using PRoCon.Core.Plugin;
using PRoCon.Core.Plugin.Commands;
using PRoCon.Core.Players;
using PRoCon.Core.Players.Items;
using PRoCon.Core.Battlemap;
using PRoCon.Core.Maps;
using PRoCon.Core.HttpServer;
namespace PRoConEvents
{
//Aliases
using EventType = PRoCon.Core.Events.EventType;
using CapturableEvent = PRoCon.Core.Events.CapturableEvents;
public class AdKats : PRoConPluginAPI, IPRoConPluginInterface
{
#region Variables
string plugin_version = "0.3.1.1";
private MatchCommand AdKatsAvailableIndicator;
//Enumerations
//Messaging
public enum MessageTypeEnum
{
Warning,
Error,
Exception,
Normal,
Success
};
//Admin Commands
public enum AdKat_CommandType
{
//Case for use while parsing and handling errors
Default,
//Confirm or cancel a command
ConfirmCommand,
CancelCommand,
//Moving players
MovePlayer,
ForceMovePlayer,
Teamswap,
RoundWhitelistPlayer,
//Punishing players
KillPlayer,
KickPlayer,
TempBanPlayer,
PermabanPlayer,
PunishPlayer,
ForgivePlayer,
MutePlayer,
//Reporting players
ReportPlayer,
CallAdmin,
//Phantom Command
ConfirmReport,
//Round Commands
RestartLevel,
NextLevel,
EndLevel,
//Messaging
AdminSay,
PlayerSay,
AdminYell,
PlayerYell,
WhatIs,
//Power Corner
NukeServer,
KickAll,
//Ban Enforcer
EnforceBan
};
//Source of commands
public enum AdKat_CommandSource
{
Default,
InGame,
Console,
Settings,
Database,
HTTP
}
// General settings
private Int64 server_id = -1;
private Int64 settingImportID = -1;
private DateTime lastDBSettingFetch = DateTime.Now;
private DateTime lastBanListCall = DateTime.Now;
private int dbSettingFetchFrequency = 300;
private Boolean usingAWA = false;
//Whether the plugin is enabled
private volatile bool isEnabled;
private volatile bool threadsReady;
//Current debug level
private volatile int debugLevel;
private String debugSoldierName = "ColColonCleaner";
private Boolean isADK = false;
private Boolean useExperimentalTools = false;
private Boolean useNoExplosivesLimit = false;
//IDs of the two teams as the server understands it
private static int USTeamID = 1;
private static int RUTeamID = 2;
//last time a manual call to listplayers was made
private DateTime lastListPlayersRequest = DateTime.Now;
//All server info
private string server_ip = null;
private CServerInfo serverInfo = null;
// Player Lists
private Dictionary<string, AdKat_Player> playerDictionary = new Dictionary<string, AdKat_Player>();
//player counts per team
private int USPlayerCount = 0;
private int RUPlayerCount = 0;
// Admin Settings
private Dictionary<string, AdKat_Access> playerAccessCache = new Dictionary<string, AdKat_Access>();
private Boolean toldCol = false;
//MySQL Settings
private volatile Boolean dbSettingsChanged = true;
private string mySqlHostname = "";
private string mySqlPort = "";
private string mySqlDatabaseName = "";
private string mySqlUsername = "";
private string mySqlPassword = "";
//frequency in seconds to fetch access changes at
private DateTime lastDBAccessFetch = DateTime.Now;
private int dbAccessFetchFrequency = 300;
//Action fetch from database settings
private Boolean fetchActionsFromDB = false;
private DateTime lastDBActionFetch = DateTime.Now;
private int dbActionFrequency = 10;
//Database Time Conversion (default to no difference)
private TimeSpan dbTimeConversion = new TimeSpan(0);
//current ban type
private Boolean useBanAppend = false;
private string banAppend = "Appeal at your_site.com";
//Command Strings for Input
private DateTime commandStartTime = DateTime.Now;
//Player Interaction
private string m_strKillCommand = "kill";
private string m_strKickCommand = "kick";
private string m_strTemporaryBanCommand = "tban";
private string m_strPermanentBanCommand = "ban";
private string m_strPunishCommand = "punish";
private string m_strForgiveCommand = "forgive";
private string m_strMuteCommand = "mute";
private string m_strRoundWhitelistCommand = "roundwhitelist";
private string m_strMoveCommand = "move";
private string m_strForceMoveCommand = "fmove";
private string m_strTeamswapCommand = "moveme";
private string m_strReportCommand = "report";
private string m_strCallAdminCommand = "admin";
//Admin messaging
private string m_strSayCommand = "say";
private string m_strPlayerSayCommand = "psay";
private string m_strYellCommand = "yell";
private string m_strPlayerYellCommand = "pyell";
private string m_strWhatIsCommand = "whatis";
private List<string> preMessageList = new List<string>();
private Boolean requirePreMessageUse = false;
private int m_iShowMessageLength = 5;
private string m_strShowMessageLength = "5";
//Map control
private string m_strRestartLevelCommand = "restart";
private string m_strNextLevelCommand = "nextlevel";
private string m_strEndLevelCommand = "endround";
//Power corner
private string m_strNukeCommand = "nuke";
private string m_strKickAllCommand = "kickall";
//Confirm and cancel
private string m_strConfirmCommand = "yes";
private string m_strCancelCommand = "no";
//Used to parse incoming commands quickly
public Dictionary<string, AdKat_CommandType> AdKat_CommandStrings;
public Dictionary<AdKat_CommandType, int> AdKat_CommandAccessRank;
//Database record types
public Dictionary<AdKat_CommandType, string> AdKat_RecordTypes;
public Dictionary<string, AdKat_CommandType> AdKat_RecordTypesInv;
//Logging settings
public Dictionary<AdKat_CommandType, Boolean> AdKat_LoggingSettings;
//External Access Settings
//Randomized on startup
private string externalCommandAccessKey = "NoPasswordSet";
//When an action requires confirmation, this dictionary holds those actions until player confirms action
private Dictionary<string, AdKat_Record> actionConfirmDic = new Dictionary<string, AdKat_Record>();
//Action will be taken when the player next spawns
private Dictionary<string, AdKat_Record> actOnSpawnDictionary = new Dictionary<string, AdKat_Record>();
//Whether to combine server punishments
private Boolean combineServerPunishments = false;
//IRO punishment setting
private Boolean IROOverridesLowPop = false;
//Default hierarchy of punishments
private string[] punishmentHierarchy =
{
"kill",
"kill",
"kick",
"tban60",
"tbanday",
"tbanweek",
"tban2weeks",
"tbanmonth",
"ban"
};
//When punishing, only kill players when server is in low population
private Boolean onlyKillOnLowPop = true;
//Default for low populations
private int lowPopPlayerCount = 20;
//Default required reason length
private int requiredReasonLength = 5;
//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>();
//whether to allow all players, or just players in the whitelist
private Boolean requireTeamswapWhitelist = true;
//the lowest ticket count of either team
private volatile int lowestTicketCount = 500000;
//the highest ticket count of either team
private volatile int highestTicketCount = 0;
//the highest ticket count of either team to allow self move
private int teamSwapTicketWindowHigh = 500000;
//the lowest ticket count of either team to allow self move
private int 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 int playersToAutoWhitelist = 2;
//Reports for the current round
private Dictionary<string, AdKat_Record> round_reports = new Dictionary<string, AdKat_Record>();
//Player Muting
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 int mutedPlayerChances = 5;
private Dictionary<string, int> round_mutedPlayers = new Dictionary<string, int>();
//Admin Assistants
private Boolean enableAdminAssistants = true;
private Dictionary<string, bool> adminAssistantCache = new Dictionary<string, bool>();
private int minimumRequiredWeeklyReports = 5;
//Twitter Settings
private Boolean useTwitter = false;
private TwitterHandler twitterHandler = null;
//private Boolean tweetedPluginEnable = false;
//Mail Settings
private Boolean useEmail = false;
private EmailHandler emailHandler = null;
//Multi-Threading
//Threads
private Thread MessagingThread;
private Thread CommandParsingThread;
private Thread DatabaseCommThread;
private Thread ActionHandlingThread;
private Thread TeamSwapThread;
private Thread BanEnforcerThread;
private Thread activator;
private Thread finalizer;
//Mutexes
public Object playersMutex = new Object();
public Object banListMutex = new Object();
public Object reportsMutex = new Object();
public Object actionConfirmMutex = new Object();
public Object playerAccessMutex = new Object();
public Object teamswapMutex = new Object();
public Object serverInfoMutex = new Object();
public Object unparsedMessageMutex = new Object();
public Object unparsedCommandMutex = new Object();
public Object unprocessedRecordMutex = new Object();
public Object unprocessedActionMutex = new Object();
public Object banEnforcerMutex = new Object();
//Handles
private EventWaitHandle teamswapHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle listPlayersHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle messageParsingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle commandParsingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle dbCommHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle actionHandlingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle banEnforcerHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private EventWaitHandle serverInfoHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
//Threading Queues
private Queue<KeyValuePair<String, String>> unparsedMessageQueue = new Queue<KeyValuePair<String, String>>();
private Queue<KeyValuePair<String, String>> unparsedCommandQueue = new Queue<KeyValuePair<String, String>>();
private Queue<AdKat_Record> unprocessedRecordQueue = new Queue<AdKat_Record>();
private Queue<AdKat_Record> unprocessedActionQueue = new Queue<AdKat_Record>();
private Queue<AdKat_Access> playerAccessUpdateQueue = new Queue<AdKat_Access>();
private Queue<String> playerAccessRemovalQueue = new Queue<String>();
private Queue<AdKat_Player> banEnforcerCheckingQueue = new Queue<AdKat_Player>();
private Queue<AdKat_Ban> banEnforcerProcessingQueue = new Queue<AdKat_Ban>();
private Queue<CBanInfo> cBanProcessingQueue = new Queue<CBanInfo>();
//Force move action queue
private Queue<CPlayerInfo> teamswapForceMoveQueue = new Queue<CPlayerInfo>();
//Delayed move list
private Dictionary<String, CPlayerInfo> teamswapOnDeathMoveDic = new Dictionary<String, CPlayerInfo>();
//Delayed move checking queue
private Queue<CPlayerInfo> teamswapOnDeathCheckingQueue = new Queue<CPlayerInfo>();
private Queue<CPluginVariable> settingUploadQueue = new Queue<CPluginVariable>();
//Ban Settings
private Boolean useBanEnforcer = false;
private Boolean useBanEnforcerPreviousState = false;
private Boolean bansFirstListed = false;
private DateTime lastSuccessfulBanList = DateTime.Now - TimeSpan.FromSeconds(5);
private Boolean defaultEnforceName = false;
private Boolean defaultEnforceGUID = true;
private Boolean defaultEnforceIP = false;
private DateTime lastDBBanFetch = DateTime.Now - TimeSpan.FromSeconds(5);
private int dbBanFetchFrequency = 60;
private DateTime permaBanEndTime = DateTime.Now.AddYears(20);
#endregion
public AdKats()
{
this.isEnabled = false;
this.threadsReady = false;
this.AdKatsAvailableIndicator = new MatchCommand("AdKats", "NoCallableMethod", new List<string>(), "AdKats_NoCallableMethod", new List<MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.None), "Useable by other plugins to determine whether this one is installed and enabled.");
debugLevel = 0;
this.externalCommandAccessKey = AdKats.GetRandom32BitHashCode();
preMessageList.Add("US TEAM: DO NOT BASERAPE, YOU WILL BE PUNISHED.");
preMessageList.Add("RU TEAM: DO NOT BASERAPE, YOU WILL BE PUNISHED.");
preMessageList.Add("US TEAM: DO NOT ENTER THE STREETS BEYOND 'A', YOU WILL BE PUNISHED.");
preMessageList.Add("RU TEAM: DO NOT GO BEYOND THE BLACK LINE ON CEILING BY 'C' FLAG, YOU WILL BE PUNISHED.");
preMessageList.Add("THIS SERVER IS NO EXPLOSIVES, YOU WILL BE PUNISHED FOR INFRACTIONS.");
preMessageList.Add("JOIN OUR TEAMSPEAK AT TS.ADKGAMERS.COM:3796");
//Create command and logging dictionaries
this.AdKat_CommandStrings = new Dictionary<string, AdKat_CommandType>();
this.AdKat_LoggingSettings = new Dictionary<AdKat_CommandType, Boolean>();
//Fill command and logging dictionaries by calling rebind
this.rebindAllCommands();
//Create database dictionaries
this.AdKat_RecordTypes = new Dictionary<AdKat_CommandType, string>();
this.AdKat_RecordTypesInv = new Dictionary<string, AdKat_CommandType>();
this.AdKat_CommandAccessRank = new Dictionary<AdKat_CommandType, int>();
//Fill DB record types for outgoing database commands
this.AdKat_RecordTypes.Add(AdKat_CommandType.MovePlayer, "Move");
this.AdKat_RecordTypes.Add(AdKat_CommandType.ForceMovePlayer, "ForceMove");
this.AdKat_RecordTypes.Add(AdKat_CommandType.Teamswap, "Teamswap");
this.AdKat_RecordTypes.Add(AdKat_CommandType.KillPlayer, "Kill");
this.AdKat_RecordTypes.Add(AdKat_CommandType.KickPlayer, "Kick");
this.AdKat_RecordTypes.Add(AdKat_CommandType.TempBanPlayer, "TempBan");
this.AdKat_RecordTypes.Add(AdKat_CommandType.PermabanPlayer, "PermaBan");
this.AdKat_RecordTypes.Add(AdKat_CommandType.PunishPlayer, "Punish");
this.AdKat_RecordTypes.Add(AdKat_CommandType.ForgivePlayer, "Forgive");
this.AdKat_RecordTypes.Add(AdKat_CommandType.MutePlayer, "Mute");
this.AdKat_RecordTypes.Add(AdKat_CommandType.RoundWhitelistPlayer, "RoundWhitelist");
this.AdKat_RecordTypes.Add(AdKat_CommandType.ReportPlayer, "Report");
this.AdKat_RecordTypes.Add(AdKat_CommandType.CallAdmin, "CallAdmin");
this.AdKat_RecordTypes.Add(AdKat_CommandType.ConfirmReport, "ConfirmReport");
this.AdKat_RecordTypes.Add(AdKat_CommandType.AdminSay, "AdminSay");
this.AdKat_RecordTypes.Add(AdKat_CommandType.PlayerSay, "PlayerSay");
this.AdKat_RecordTypes.Add(AdKat_CommandType.AdminYell, "AdminYell");
this.AdKat_RecordTypes.Add(AdKat_CommandType.PlayerYell, "PlayerYell");
this.AdKat_RecordTypes.Add(AdKat_CommandType.RestartLevel, "RestartLevel");
this.AdKat_RecordTypes.Add(AdKat_CommandType.NextLevel, "NextLevel");
this.AdKat_RecordTypes.Add(AdKat_CommandType.EndLevel, "EndLevel");
this.AdKat_RecordTypes.Add(AdKat_CommandType.NukeServer, "Nuke");
this.AdKat_RecordTypes.Add(AdKat_CommandType.KickAll, "KickAll");
this.AdKat_RecordTypes.Add(AdKat_CommandType.EnforceBan, "EnforceBan");
//Fill DB Inverse record types for incoming database commands
this.AdKat_RecordTypesInv.Add("Move", AdKat_CommandType.MovePlayer);
this.AdKat_RecordTypesInv.Add("ForceMove", AdKat_CommandType.ForceMovePlayer);
this.AdKat_RecordTypesInv.Add("Teamswap", AdKat_CommandType.Teamswap);
this.AdKat_RecordTypesInv.Add("Kill", AdKat_CommandType.KillPlayer);
this.AdKat_RecordTypesInv.Add("Kick", AdKat_CommandType.KickPlayer);
this.AdKat_RecordTypesInv.Add("TempBan", AdKat_CommandType.TempBanPlayer);
this.AdKat_RecordTypesInv.Add("PermaBan", AdKat_CommandType.PermabanPlayer);
this.AdKat_RecordTypesInv.Add("Punish", AdKat_CommandType.PunishPlayer);
this.AdKat_RecordTypesInv.Add("Forgive", AdKat_CommandType.ForgivePlayer);
this.AdKat_RecordTypesInv.Add("Mute", AdKat_CommandType.MutePlayer);
this.AdKat_RecordTypesInv.Add("RoundWhitelist", AdKat_CommandType.RoundWhitelistPlayer);
this.AdKat_RecordTypesInv.Add("Report", AdKat_CommandType.ReportPlayer);
this.AdKat_RecordTypesInv.Add("CallAdmin", AdKat_CommandType.CallAdmin);
this.AdKat_RecordTypesInv.Add("ConfirmReport", AdKat_CommandType.ConfirmReport);
this.AdKat_RecordTypesInv.Add("AdminSay", AdKat_CommandType.AdminSay);
this.AdKat_RecordTypesInv.Add("PlayerSay", AdKat_CommandType.PlayerSay);
this.AdKat_RecordTypesInv.Add("AdminYell", AdKat_CommandType.AdminYell);
this.AdKat_RecordTypesInv.Add("PlayerYell", AdKat_CommandType.PlayerYell);
this.AdKat_RecordTypesInv.Add("RestartLevel", AdKat_CommandType.RestartLevel);
this.AdKat_RecordTypesInv.Add("NextLevel", AdKat_CommandType.NextLevel);
this.AdKat_RecordTypesInv.Add("EndLevel", AdKat_CommandType.EndLevel);
this.AdKat_RecordTypesInv.Add("Nuke", AdKat_CommandType.NukeServer);
this.AdKat_RecordTypesInv.Add("KickAll", AdKat_CommandType.KickAll);
this.AdKat_RecordTypesInv.Add("EnforceBan", AdKat_CommandType.EnforceBan);
//Fill all command access ranks
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.RestartLevel, 0);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.NextLevel, 0);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.EndLevel, 0);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.NukeServer, 0);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.KickAll, 0);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.PermabanPlayer, 1);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.TempBanPlayer, 2);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.RoundWhitelistPlayer, 2);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.KillPlayer, 3);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.KickPlayer, 3);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.PunishPlayer, 3);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.ForgivePlayer, 3);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.MutePlayer, 3);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.MovePlayer, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.ForceMovePlayer, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.AdminSay, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.AdminYell, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.PlayerSay, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.PlayerYell, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.WhatIs, 4);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.Teamswap, 5);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.ReportPlayer, 6);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.CallAdmin, 6);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.ConfirmReport, 6);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.ConfirmCommand, 6);
this.AdKat_CommandAccessRank.Add(AdKat_CommandType.CancelCommand, 6);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.AdminSay, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.AdminYell, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.CallAdmin, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.CancelCommand, false);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.ConfirmCommand, false);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.ConfirmReport, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.Default, false);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.EndLevel, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.EnforceBan, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.ForceMovePlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.ForgivePlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.KickAll, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.KickPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.KillPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.MovePlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.MutePlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.NextLevel, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.NukeServer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.PermabanPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.PlayerSay, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.PlayerYell, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.PunishPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.ReportPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.RestartLevel, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.RoundWhitelistPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.Teamswap, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.TempBanPlayer, true);
this.AdKat_LoggingSettings.Add(AdKat_CommandType.WhatIs, false);
//Initialize the threads
//TODO find if necessary
//this.InitThreads();
}
#region Plugin details
public string GetPluginName()
{
return "AdKats";
}
public string GetPluginVersion()
{
return this.plugin_version;
}
public string GetPluginAuthor()
{
return "ColColonCleaner";
}
public string GetPluginWebsite()
{
return "https://github.com/ColColonCleaner/AdKats/";
}
public string GetPluginDescription()
{
string pluginDescription = "DESCRIPTION FETCH FAILED|";
string pluginChangelog = "CHANGELOG FETCH FAILED";
WebClient client = new WebClient();
pluginDescription = client.DownloadString("https://raw.github.com/ColColonCleaner/AdKats/master/README.md");
pluginChangelog = client.DownloadString("https://raw.github.com/ColColonCleaner/AdKats/master/CHANGELOG.md");
return pluginDescription + pluginChangelog;
}
#endregion
#region Plugin settings
public List<CPluginVariable> GetDisplayPluginVariables()
{
//Get storage variables
List<CPluginVariable> lstReturn;
if (!this.threadsReady)
{
lstReturn = new List<CPluginVariable>();
lstReturn.Add(new CPluginVariable("Complete these settings before enabling.", typeof(string), "Once enabled, more settings will appear."));
//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));
//Debugging Settings
lstReturn.Add(new CPluginVariable("3. Debugging|Debug level", typeof(int), this.debugLevel));
}
else
{
lstReturn = this.GetPluginVariables();
//Add display variables
//Server Settings
lstReturn.Add(new CPluginVariable("1. Server Settings|Server ID (Display)", typeof(int), this.server_id));
lstReturn.Add(new CPluginVariable("1. Server Settings|Server IP (Display)", typeof(string), this.server_ip));
lstReturn.Add(new CPluginVariable("1. Server Settings|Setting Import", typeof(string), this.server_id));
if (!this.usingAWA)
{
//Admin Settings
lstReturn.Add(new CPluginVariable("3. Player Access Settings|Add Access", typeof(string), ""));
lstReturn.Add(new CPluginVariable("3. Player Access Settings|Remove Access", typeof(string), ""));
if (this.playerAccessCache.Count > 0)
{
//Sort list by access level, then by name
List<AdKat_Access> tempAccess = new List<AdKat_Access>();
foreach (AdKat_Access access in this.playerAccessCache.Values)
{
tempAccess.Add(access);
}
tempAccess.Sort(
delegate(AdKat_Access a1, AdKat_Access a2)
{
return (a1.access_level == a2.access_level)
?
(String.Compare(a1.player_name, a2.player_name))
:
((a1.access_level < a2.access_level) ? (-1) : (1));
}
);
foreach (AdKat_Access access in tempAccess)
{
lstReturn.Add(new CPluginVariable("3. Player Access Settings|" + access.player_name + "|Access Level", typeof(int), access.access_level));
//lstReturn.Add(new CPluginVariable("3. Player Access Settings|" + access.player_name + "|Email Address", typeof(string), access.player_email));
}
}
else
{
lstReturn.Add(new CPluginVariable("3. Player Access Settings|No Players in Access List", typeof(string), "Add Players with 'Add Access', or Re-Enable AdKats to fetch."));
}
}
else
{
lstReturn.Add(new CPluginVariable("3. Player Access Settings|You are using AdKats WebAdmin", typeof(string), "Manage admin settings there."));
}
}
return lstReturn;
}
public List<CPluginVariable> GetPluginVariables()
{
List<CPluginVariable> lstReturn = new List<CPluginVariable>();
try
{
//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));
//In-Game Command Settings
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Minimum Required Reason Length", typeof(int), this.requiredReasonLength));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Confirm Command", typeof(string), m_strConfirmCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Cancel Command", typeof(string), m_strCancelCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Kill Player", typeof(string), m_strKillCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Kick Player", typeof(string), m_strKickCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Temp-Ban Player", typeof(string), m_strTemporaryBanCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Permaban Player", typeof(string), m_strPermanentBanCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Punish Player", typeof(string), m_strPunishCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Forgive Player", typeof(string), m_strForgiveCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Mute Player", typeof(string), m_strMuteCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Round Whitelist Player", typeof(string), m_strRoundWhitelistCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|OnDeath Move Player", typeof(string), m_strMoveCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Force Move Player", typeof(string), m_strForceMoveCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Teamswap Self", typeof(string), m_strTeamswapCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Report Player", typeof(string), m_strReportCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Call Admin on Player", typeof(string), m_strCallAdminCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Admin Say", typeof(string), m_strSayCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Player Say", typeof(string), m_strPlayerSayCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Admin Yell", typeof(string), m_strYellCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Player Yell", typeof(string), m_strPlayerYellCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|What Is", typeof(string), m_strWhatIsCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Restart Level", typeof(string), m_strRestartLevelCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Next Level", typeof(string), m_strNextLevelCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|End Level", typeof(string), m_strEndLevelCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Nuke Server", typeof(string), m_strNukeCommand));
lstReturn.Add(new CPluginVariable("4. In-Game Command Settings|Kick All NonAdmins", typeof(string), m_strKickAllCommand));
//Punishment Settings
lstReturn.Add(new CPluginVariable("5. Punishment Settings|Punishment Hierarchy", typeof(string[]), this.punishmentHierarchy));
lstReturn.Add(new CPluginVariable("5. Punishment Settings|Combine Server Punishments", typeof(Boolean), this.combineServerPunishments));
lstReturn.Add(new CPluginVariable("5. Punishment Settings|Only Kill Players when Server in low population", typeof(Boolean), this.onlyKillOnLowPop));
if (this.onlyKillOnLowPop)
{
lstReturn.Add(new CPluginVariable("5. Punishment Settings|Low Population Value", typeof(int), this.lowPopPlayerCount));
lstReturn.Add(new CPluginVariable("5. Punishment Settings|IRO Punishment Overrides Low Pop", typeof(Boolean), this.IROOverridesLowPop));
}
//Player Report Settings
lstReturn.Add(new CPluginVariable("6. Email Settings|Send Emails", typeof(bool), this.useEmail));
if (this.useEmail == true && false)
{
lstReturn.Add(new CPluginVariable("6. Email Settings|Email: Use SSL?", typeof(Boolean), this.emailHandler.blUseSSL));
lstReturn.Add(new CPluginVariable("6. Email Settings|SMTP-Server address", typeof(string), this.emailHandler.strSMTPServer));
lstReturn.Add(new CPluginVariable("6. Email Settings|SMTP-Server port", typeof(int), this.emailHandler.iSMTPPort));
lstReturn.Add(new CPluginVariable("6. Email Settings|Sender address", typeof(string), this.emailHandler.strSenderMail));
lstReturn.Add(new CPluginVariable("6. Email Settings|SMTP-Server username", typeof(string), this.emailHandler.strSMTPUser));
lstReturn.Add(new CPluginVariable("6. Email Settings|SMTP-Server password", typeof(string), this.emailHandler.strSMTPPassword));
}
//TeamSwap Settings
lstReturn.Add(new CPluginVariable("7. TeamSwap Settings|Require Whitelist for Access", typeof(Boolean), this.requireTeamswapWhitelist));
if (this.requireTeamswapWhitelist)
{
lstReturn.Add(new CPluginVariable("7. TeamSwap Settings|Auto-Whitelist Count", typeof(string), this.playersToAutoWhitelist));
}
lstReturn.Add(new CPluginVariable("7. TeamSwap Settings|Ticket Window High", typeof(int), this.teamSwapTicketWindowHigh));
lstReturn.Add(new CPluginVariable("7. TeamSwap Settings|Ticket Window Low", typeof(int), this.teamSwapTicketWindowLow));
//Admin Assistant Settings
lstReturn.Add(new CPluginVariable("8. Admin Assistant Settings|Enable Admin Assistant Perk", typeof(Boolean), this.enableAdminAssistants));
lstReturn.Add(new CPluginVariable("8. Admin Assistant Settings|Minimum Confirmed Reports Per Week", typeof(int), this.minimumRequiredWeeklyReports));
//Muting Settings
lstReturn.Add(new CPluginVariable("9. Player Mute Settings|On-Player-Muted Message", typeof(string), this.mutedPlayerMuteMessage));
lstReturn.Add(new CPluginVariable("9. Player Mute Settings|On-Player-Killed Message", typeof(string), this.mutedPlayerKillMessage));
lstReturn.Add(new CPluginVariable("9. Player Mute Settings|On-Player-Kicked Message", typeof(string), this.mutedPlayerKickMessage));
lstReturn.Add(new CPluginVariable("9. Player Mute Settings|# Chances to give player before kicking", typeof(int), this.mutedPlayerChances));
//Pre-Message Settings
lstReturn.Add(new CPluginVariable("A10. Messaging Settings|Yell display time seconds", typeof(int), this.m_iShowMessageLength));
lstReturn.Add(new CPluginVariable("A10. Messaging Settings|Pre-Message List", typeof(string[]), this.preMessageList.ToArray()));
lstReturn.Add(new CPluginVariable("A10. Messaging Settings|Require Use of Pre-Messages", typeof(Boolean), this.requirePreMessageUse));
//Ban Settings
lstReturn.Add(new CPluginVariable("A11. Banning Settings|Use Additional Ban Message", typeof(Boolean), this.useBanAppend));
if (this.useBanAppend)
{
lstReturn.Add(new CPluginVariable("A11. Banning Settings|Additional Ban Message", typeof(string), this.banAppend));
}
if (!this.usingAWA)
{
lstReturn.Add(new CPluginVariable("A11. Banning Settings|Use Ban Enforcer", typeof(Boolean), this.useBanEnforcer));
}
if (this.useBanEnforcer)
{
lstReturn.Add(new CPluginVariable("A11. Banning Settings|Enforce New Bans by NAME", typeof(Boolean), this.defaultEnforceName));
lstReturn.Add(new CPluginVariable("A11. Banning Settings|Enforce New Bans by GUID", typeof(Boolean), this.defaultEnforceGUID));
lstReturn.Add(new CPluginVariable("A11. Banning Settings|Enforce New Bans by IP", typeof(Boolean), this.defaultEnforceIP));
//lstReturn.Add(new CPluginVariable("A11. Banning Settings|NAME Ban Count", typeof(int), this.AdKat_BanList_Name.Count));
//lstReturn.Add(new CPluginVariable("A11. Banning Settings|GUID Ban Count", typeof(int), this.AdKat_BanList_GUID.Count));
//lstReturn.Add(new CPluginVariable("A11. Banning Settings|IP Ban Count", typeof(int), this.AdKat_BanList_IP.Count));
}
//External Command Settings
lstReturn.Add(new CPluginVariable("A12. External Command Settings|HTTP External Access Key", typeof(string), this.externalCommandAccessKey));
if (!this.useBanEnforcer && !this.usingAWA)
{
lstReturn.Add(new CPluginVariable("A12. External Command Settings|Fetch Actions from Database", typeof(Boolean), this.fetchActionsFromDB));
}
//Debug settings
lstReturn.Add(new CPluginVariable("A13. Debugging|Debug level", typeof(int), this.debugLevel));
lstReturn.Add(new CPluginVariable("A13. Debugging|Debug Soldier Name", typeof(string), this.debugSoldierName));
lstReturn.Add(new CPluginVariable("A13. Debugging|Command Entry", typeof(string), ""));
//Experimental tools
if (this.isADK)
{
lstReturn.Add(new CPluginVariable("X99. Experimental|Use Experimental Tools", typeof(Boolean), this.useExperimentalTools));
if (this.useExperimentalTools)
{
lstReturn.Add(new CPluginVariable("X99. Experimental|Use NO EXPLOSIVES Limiter", typeof(Boolean), this.useNoExplosivesLimit));
}
}
}
catch (Exception e)
{
this.ConsoleException("get vars: " + e.ToString());
}
return lstReturn;
}
public void SetPluginVariable(string strVariable, string strValue)
{
try
{
string[] variableParse = CPluginVariable.DecodeStringArray(strVariable);
if (strVariable.Equals("UpdateSettings"))
{
//Do nothing. Settings page will be updated after return.
}
else if (Regex.Match(strVariable, @"Setting Import").Success)
{
int tmp = -1;
if (int.TryParse(strValue, out tmp))
{
if (tmp != -1)
this.queueSettingImport(tmp);
}
else
{
this.ConsoleError("Invalid Input for Setting Import");
}
}
else if (Regex.Match(strVariable, @"Using AdKats WebAdmin").Success)
{
Boolean tmp = false;
if (Boolean.TryParse(strValue, out tmp))
{
this.usingAWA = tmp;
//Update necessary settings for AWA use
if (this.usingAWA)
{
this.useBanEnforcer = true;
this.fetchActionsFromDB = true;
this.dbCommHandle.Set();
}
}
else
{
this.ConsoleError("Invalid Input for Using AdKats WebAdmin");
}
}
#region debugging
else if (Regex.Match(strVariable, @"Command Entry").Success)
{
//Check if the message is a command
if (strValue.StartsWith("@") || strValue.StartsWith("!"))
{
strValue = strValue.Substring(1);
}
else if (strValue.StartsWith("/@") || strValue.StartsWith("/!"))
{
strValue = strValue.Substring(2);
}
else if (strValue.StartsWith("/"))
{
strValue = strValue.Substring(1);
}
AdKat_Record recordItem = new AdKat_Record();
recordItem.command_source = AdKat_CommandSource.Settings;
recordItem.source_name = "SettingsAdmin";
this.completeRecord(recordItem, strValue);
}
else if (Regex.Match(strVariable, @"Debug level").Success)
{
int tmp = 2;
if (int.TryParse(strValue, out tmp))
{
if (tmp != this.debugLevel)
{
this.debugLevel = tmp;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Debug level", typeof(Int32), this.debugLevel));
}
}
}
else if (Regex.Match(strVariable, @"Debug Soldier Name").Success)
{
if (this.soldierNameValid(strValue))
{
if (strValue != this.debugSoldierName)
{
this.debugSoldierName = strValue;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Debug Soldier Name", typeof(string), this.debugSoldierName));
}
}
}
else if (Regex.Match(strVariable, @"Use Experimental Tools").Success)
{
Boolean useEXP = Boolean.Parse(strValue);
if (useEXP != this.useExperimentalTools)
{
this.useExperimentalTools = useEXP;
if (this.useExperimentalTools)
{
this.ConsoleWarn("Using experimental tools. Take caution.");
}
else
{
this.ConsoleWarn("Experimental tools disabled.");
this.useNoExplosivesLimit = false;
}
}
}
else if (Regex.Match(strVariable, @"Use NO EXPLOSIVES Limiter").Success)
{
Boolean useLimiter = Boolean.Parse(strValue);
if (useLimiter != this.useNoExplosivesLimit)
{
this.useNoExplosivesLimit = useLimiter;
if (this.useNoExplosivesLimit)
{
this.ConsoleWarn("Internal NO EXPLOSIVES punish limit activated.");
}
else
{
this.ConsoleWarn("Internal NO EXPLOSIVES punish limit disabled.");
}
}
}
#endregion
#region HTTP settings
else if (Regex.Match(strVariable, @"External Access Key").Success)
{
if (strValue != this.externalCommandAccessKey)
{
this.externalCommandAccessKey = strValue;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"External Access Key", typeof(string), this.externalCommandAccessKey));
}
}
else if (Regex.Match(strVariable, @"Fetch Actions from Database").Success)
{
Boolean fetch;
if (fetch = Boolean.Parse(strValue))
{
if (fetch != this.fetchActionsFromDB)
{
this.fetchActionsFromDB = fetch;
this.dbCommHandle.Set();
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Fetch Actions from Database", typeof(Boolean), this.fetchActionsFromDB));
}
}
}
#endregion
#region ban settings
else if (Regex.Match(strVariable, @"Use Additional Ban Message").Success)
{
Boolean use = Boolean.Parse(strValue);
if (this.useBanAppend != use)
{
this.useBanAppend = use;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Use Additional Ban Message", typeof(Boolean), this.useBanAppend));
}
}
else if (Regex.Match(strVariable, @"Additional Ban Message").Success)
{
if (strValue.Length > 30)
{
strValue = strValue.Substring(0, 30);
this.ConsoleError("Ban append cannot be more than 30 characters.");
}
else
{
if (this.banAppend != strValue)
{
this.banAppend = strValue;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Additional Ban Message", typeof(string), this.banAppend));
}
}
}
else if (Regex.Match(strVariable, @"Use Ban Enforcer").Success)
{
Boolean use = Boolean.Parse(strValue);
if (this.useBanEnforcer != use)
{
this.useBanEnforcer = use;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Use Ban Enforcer", typeof(Boolean), this.useBanEnforcer));
if (this.useBanEnforcer)
{
this.fetchActionsFromDB = true;
this.dbCommHandle.Set();
}
}
}
else if (Regex.Match(strVariable, @"Enforce New Bans by NAME").Success)
{
Boolean enforceName = Boolean.Parse(strValue);
if (this.defaultEnforceName != enforceName)
{
this.defaultEnforceName = enforceName;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Enforce New Bans by NAME", typeof(Boolean), this.defaultEnforceName));
}
}
else if (Regex.Match(strVariable, @"Enforce New Bans by GUID").Success)
{
Boolean enforceGUID = Boolean.Parse(strValue);
if (this.defaultEnforceGUID != enforceGUID)
{
this.defaultEnforceGUID = enforceGUID;
//Once setting has been changed, upload the change to database
this.queueSettingForUpload(new CPluginVariable(@"Enforce New Bans by GUID", typeof(Boolean), this.defaultEnforceGUID));
}
}
else if (Regex.Match(strVariable, @"Enforce New Bans by IP").Success)
{
Boolean enforceIP = Boolean.Parse(strValue);