Paste #15815: Diff note for paste #15814

Date: 2015/05/15 21:55:24 UTC-07:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


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


 ################################################################################
 #
 #                             S w e a r G u a r d
 #
 #
 #   Authors: |Anthony|
-#   Version: 0.1
+#   Version: 0.2
 #   dScript Version: 0.9.6-DEV_b171
 #
 #_______________________________________________________________________________
 #
 #--- About SwearGuard
 #
 #    SwearGuard was written upon request for TheDentedShield.
 #
 #    SwearGuard is a flexible, extensible, and light weight system for punishing
 #  players for using prohibited words and phrases. SwearGuard allows users to
 #  configure a list of words or phrases that players will be punished for using.
 #  Continued use of prohibited words will elevate your infraction level
 #  resulting in mutes, kicks, and temporary bans.
 #
 #    The infraction level will decrease over time, but the time increases by a
 #  factor of 10 for each level. At level 1 it will take 10 minutes to decrease
 #  to level 0. At level 2 it will take 20 minutes to decrease to level 1. This
 #  pattern continues through to the highest level (20) where it will take 200
 #  minutes to decrease to level 19.
 #
 #    SwearGuard provides a built in mute and ban system and uses those by
 #  default. You can edit the config settings to use third party plugins if
 #  desired. It is recommended to use your chat plugins mute system if it
 #  provides that feature.
 #
 #--- Installation & Setup
 #
 # - Edit the config options in SwearGuard.config (see script below) as needed.
 #   SwearGuard defaults to using its own mute and ban system.
 #
 # - Place swearguard.dscript in your denizen scripts folder and reload your
 #   scripts. SwearGuard is now active, but it does not have any words in its list.
 #
 # - Assign permissions to players and admins. Admins can manage the filter list
 #   and check/adjust player stats.
 #
 # - Add words/phrases to your swearguard filter list.
 #
 #
 #--- Permissions & Commands
 #
 #  Here's a list of all the permissions and commands with a brief description
 # of each. More verbose usage info can be found in game. /sg help
 #
 #  SwearGuard provides thorough TAB completion! Use this to your benefit!
 #
 #  /sg help [arg/#]              swearguard.basic         Specify a page number or command arg
 #                                swearguard.admin          - Show admin help
 #  /sg about                     swearguard.basic         Show some general info about SwearGuard
 #  /sg filter (list/add/remove)  swearguard.admin         List and edit prohibited words/phrases
 #  /sg stats <player> (set #)    swearguard.admin         Show and edit player infraction level
 #
 #
 #--- Basic Usage Tutorial
 #
 # - See in game help for more details.
 # - Use the TAB completion feature to your benefit!
 #
 # To add a word to the filter list:
 #   /swearguard filter add potato
 #
 # To add a phrase to the filter list:
 #   /swearguard filter add potatoes are tasty
 #
 #--- TODO
 #
 # - Allow players to view the prohibited words/phrases list
 # - Give players a stats command
 #   - They currently get their stats from the root command.
 # - Provide an override permission to bypass chat checking, mutes, and bans.
 # - Provide a config option so users can specify commands for third party
 #   mutes and bans.
 # - Maybe make the sounds configurable via a command and flags?
 #
 #--- BUGS
 #
 # - SwearGuards builtin mute feature can be bypassed!
 #   - If you are using a third party chat plugin that offers players a command
 #     to send messages they will not be blocked since they are commands, not chat
 #
 #
 ################################################################################
 SwearGuard:
   type: world
   debug: false
   speed: 0
 
 # Edit these config options to your liking. DO NOT REMOVE THEM!
   config:
     # Colors used at random for the action_bar notifications
     colors: <&1>|<&2>|<&3>|<&4>|<&5>|<&6>|<&7>|<&8>|<&9>|<&a>|<&b>|<&c>|<&d>|<&e>|<&f>
+    # Allow players to see their SwearGuard infraction level
+    showPlayerStats: true
+    # Whether or not to take action when players reach certain infraction levels
+    takeAction: true
     sound:
     # Additional sounds can be found at https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
       warning: enderman_scream
       finalWarning: donkey_death
       action: explode
     useSwearGuard:
     # Whether to use SwearGuards built in mute and ban system. Set to false to
     # use an external system
       mute: true
       ban: true
 
   events:
     on server start:
     - run locally infraction_cycle delay:1t id:SwearGuard_InfractionCycle
 
     on script reload:
     - if <queue.exists[SwearGuard_InfractionCycle]> {
       - queue q@SwearGuard_InfractionCycle stop
       }
     - run locally infraction_cycle delay:1t id:SwearGuard_InfractionCycle
 
     on player login:
     - if <script.yaml_key[config.useSwearGuard.ban]> {
       - if <player.has_flag[SwearGuard.Ban]> {
         - determine kicked '<&c>You have <&6><player.flag[SwearGuard.Ban].expiration.formatted> left on your ban.'
         }
       }
 
     on player chats:
     - if <player.has_flag[SwearGuard.Mute]> {
       - if !<player.has_flag[SwearGuard.Msg_Cooldown]> {
         - flag <player> SwearGuard.Msg_Cooldown d:3s
         - run s@SwearGuard_Msg 'def:<&c>You are muted for <&6><player.flag[SwearGuard.Mute].expiration.formatted><&c>.'
         }
       - determine cancelled
       }
     - wait 1t
     - ^define wordList '<server.flag[SwearGuard.List].as_list.unescape_contents||li@>'
     - ^if <context.message.contains_any_text[%wordList%]> {
       - flag <player> SwearGuard.Count:++
       - flag <player> SwearGuard.Duration:<player.flag[SwearGuard.Count].mul[600000].add[<server.current_time_millis>].as_int>
       - flag <player> 'SwearGuard.LastInfraction:<context.message.escaped>'
-      - inject locally count_<player.flag[SwearGuard.Count].as_int||null>
+      - if <script.yaml_key[config.takeAction]> {
+        - inject locally count_<player.flag[SwearGuard.Count].as_int||null>
+        }
       - playsound <player> 'sound:<script.yaml_key[config.sound.warning]>' pitch:1.5
       - repeat 20 {
         - adjust <player> 'action_bar:<script.yaml_key[config.colors].as_list.random><&l>Such language is unacceptable!'
         - wait 2t
         }
       - adjust <player> 'action_bar:<&4><&l>Such language is unacceptable!'
       }
 
   count_9:
     - playsound <player> 'sound:<script.yaml_key[config.sound.finalWarning]>' pitch:1.5
     - repeat 20 {
       - adjust <player> 'action_bar:<script.yaml_key[config.colors].as_list.random><&l>You will be muted for 5 minutes if you swear again!'
       - wait 2t
       }
     - adjust <player> 'action_bar:<&4><&l>You will be muted for 5 minutes if you swear again!'
     - queue clear
 
   count_10:
     - if <script.yaml_key[config.useSwearGuard.mute]> {
       - flag <player> SwearGuard.Mute d:5m
       }
       else {
       - execute as_server "mute <player.name> 5m"
       }
     - define lines '<proc[SwearGuard_LineWrap].context[<&6><player.name> <&c>has been muted for 5 minutes!|44]>'
     - foreach <server.list_online_players> {
       - foreach <def[lines]> {
         - run s@SwearGuard_Msg 'def:<&c><def[value]>'
         }
       }
     - playsound <player> 'sound:<script.yaml_key[config.sound.action]>' pitch:1.5
     - repeat 20 {
       - adjust <player> 'action_bar:<script.yaml_key[config.colors].as_list.random><&l>You have sworn too much, you will now be muted for 5 minutes!'
       - wait 2t
       }
     - adjust <player> 'action_bar:<&4><&l>You have sworn too much, you will now be muted for 5 minutes!'
     - wait 3s
     - repeat 5 {
       - adjust <player> 'action_bar:<&4><&l>Continued swearing will result in a longer mute!'
       - wait 1s
       }
     - queue clear
 
   count_14:
     - playsound <player> 'sound:<script.yaml_key[config.sound.finalWarning]>' pitch:1.5
     - repeat 20 {
       - adjust <player> 'action_bar:<script.yaml_key[config.colors].as_list.random><&l>You will be muted for 10 minutes if you swear again!'
       - wait 2t
       }
     - adjust <player> 'action_bar:<&4><&l>You will be muted for 10 minutes if you swear again!'
     - queue clear
 
   count_15:
     - if <script.yaml_key[config.useSwearGuard.mute]> {
       - flag <player> SwearGuard.Mute d:10m
       }
       else {
       - execute as_server "mute <player.name> 10m"
       }
     - define lines '<proc[SwearGuard_LineWrap].context[<&6><player.name> <&c>has been muted for 10 minutes!|44]>'
     - foreach <server.list_online_players> {
       - foreach <def[lines]> {
         - run s@SwearGuard_Msg 'def:<&c><def[value]>'
         }
       }
     - playsound <player> 'sound:<script.yaml_key[config.sound.action]>' pitch:1.5
     - repeat 20 {
       - adjust <player> 'action_bar:<script.yaml_key[config.colors].as_list.random><&l>You have sworn too much, you will now be muted for 10 minutes!'
       - wait 2t
       }
     - adjust <player> 'action_bar:<&4><&l>You have sworn too much, you will now be muted for 10 minutes!'
     - wait 3s
     - repeat 5 {
       - adjust <player> 'action_bar:<&4><&l>Continued swearing will result in a kick!'
       - wait 1s
       }
     - queue clear
 
   count_16:
     - define lines '<proc[SwearGuard_LineWrap].context[<&6><player.name> <&c>has been kicked for excessive swearing!|44]>'
     - foreach <server.list_online_players> {
       - foreach <def[lines]> {
         - run s@SwearGuard_Msg 'def:<&c><def[value]>'
         }
       }
     - playsound <player> 'sound:<script.yaml_key[config.sound.action]>' pitch:1.5
     - adjust <player> 'kick:<&4><&l>Continued swearing will result in a 1 hour ban!'
     - queue clear
 
   count_17:
     - define lines '<proc[SwearGuard_LineWrap].context[<&6><player.name> <&c>has been temp banned for 1 hour!|44]>'
     - foreach <server.list_online_players> {
       - foreach <def[lines]> {
         - run s@SwearGuard_Msg 'def:<&c><def[value]>'
         }
       }
     - playsound <player> 'sound:<script.yaml_key[config.sound.action]>' pitch:1.5
     - adjust <player> 'kick:<&4><&l>You are banned for 1 hour!<&nl>Continued swearing will result in a 6 hour ban!'
     - if <script.yaml_key[config.useSwearGuard.ban]> {
       - flag <player> SwearGuard.Ban d:1h
       }
       else {
       - execute as_server "tempban <player.name> 1h Swearing"
       }
     - queue clear
 
   count_19:
     - define lines '<proc[SwearGuard_LineWrap].context[<&6><player.name> <&c>has been temp banned for 6 hours!|44]>'
     - foreach <server.list_online_players> {
       - foreach <def[lines]> {
         - run s@SwearGuard_Msg 'def:<&c><def[value]>'
         }
       }
     - playsound <player> 'sound:<script.yaml_key[config.sound.action]>' pitch:1.5
     - adjust <player> 'kick:<&4><&l>You are banned for 6 hours!<&nl>Continued swearing will result in a 12 hour ban!'
     - if <script.yaml_key[config.useSwearGuard.ban]> {
       - flag <player> SwearGuard.Ban d:6h
       }
       else {
       - execute as_server "tempban <player.name> 6h Swearing"
       }
     - queue clear
 
   count_20:
     - define lines '<proc[SwearGuard_LineWrap].context[<&6><player.name> <&c>has been temp banned for 12 hours!|44]>'
     - foreach <server.list_online_players> {
       - foreach <def[lines]> {
         - run s@SwearGuard_Msg 'def:<&c><def[value]>'
         }
       }
     - playsound <player> 'sound:<script.yaml_key[config.sound.action]>' pitch:1.5
     - adjust <player> 'kick:<&4><&l>You are banned for 12 hours!<&nl>Continued swearing will result in a 12 hour ban!'
     - if <script.yaml_key[config.useSwearGuard.ban]> {
       - flag <player> SwearGuard.Ban d:12h
       }
       else {
       - execute as_server "tempban <player.name> 12h Swearing"
       }
     - flag player SwearGuard.Count:19
     - queue clear
 
   infraction_cycle:
     - while true {
       - wait 1m
       - define now '<server.current_time_millis>'
       - foreach <server.get_players_flagged[SwearGuard.Count].filter[flag[SwearGuard.Count].is[more].than[0]]> {
         - if <def[value].flag[SwearGuard.Duration]> <= %now% {
           - flag %value% SwearGuard.Count:--
           - flag %value% SwearGuard.Duration:<def[value].flag[SwearGuard.Count].mul[600000].add[%now%].as_int>
           }
         }
       }
 #
 ################################################################################
 #
 #  SwearGuard Command Script Container
 #
 # This script covers all SwearGuard commands
 #
 #
 #--------------------------------------
 #
 #  SwearGuard Command Script Basics
 #
 # The basic stuff required in a command script container
 #
 SwearGuard_Commands:
   type: command
   speed: 0
   debug: false
   name: swearguard
   description: Punish players for swearing
   usage: /swearguard
   aliases:
   - sg
   allowed help:
   - determine true
 
   commandArgs:
     about:
       usage: '/sg about'
       desc: Learn about SwearGuard
       permission: swearguard.basic
     help:
       desc: See help information
       usage: '/sg help <&lt>arg<&gt>'
       permission: swearguard.basic
     filter:
       desc: List and edit filters
       usage: '/sg filter (list/add/remove)'
       permission: swearguard.admin
     stats:
       desc: See and edit player SwearGuard stats
       usage: '/sg stats <&lt>player<&gt> (set <&ns>)'
       permission: swearguard.admin
 
   tab complete:
     - define args '<script.list_keys[commandArgs].alphanumeric.to_lowercase||li@>'
     - define arg '<c.args.get[1]||null>'
     - if <def[arg].is[==].to[null]> || !<def[args].contains[%arg%]> {
       - inject locally tab_arg_1
       }
       else {
       - inject locally tab_%arg%
       }
     - determine '<def[result]||li@>'
 
   script:
     - define command '<c.args.get[1].escaped||help>'
     - define args '<script.list_keys[commandArgs].alphanumeric.to_lowercase||li@>'
     - if !<def[args].contains[%command%]> {
       - inject locally help
       }
       else {
       - inject locally %command%
       }
 #
 #  END SwearGuard Command Script Basics
 #--------------------------------------
 #
 #  SwearGuard Command TAB Completion
 #
 # Each of these subscripts handles TAB completion for the positional argument.
 #
 #
   tab_arg_1:
     - foreach %args% {
       - if !<player.permission[<script.yaml_key[commandArgs.%value%.permission]>]||false> && !<player.is_op> {
         - define args '<def[args].exclude[%value%]||%args%>'
         }
       }
     - if <def[args].is_empty||true> {
       - define result 'li@'
       }
       else {
       - define result '<def[args].filter[starts_with[%arg%]]||li@> '
       - if <def[result].is_empty||true> {
         - define result '%args%'
         }
       }
 
   tab_help:
     - define spaces '<c.raw_args.to_list.count[ ]||0>'
     - if <def[spaces].is[==].to[0]> {
       - define result 'help [command]'
       }
       else if <def[spaces].is[==].to[1]> {
       - define result 'li@'
       - foreach %args% {
         - if <player.permission[<script.yaml_key[commandArgs.%value%.permission]>]||false> || <player.is_op> {
           - define result '<def[result].include[%value%]||%result%>'
           }
           else {
           - foreach next
           }
         }
       - if <c.args.get[2].is[!=].to[null]||false> {
         - define result '<def[args].filter[starts_with[<c.args.get[2]>]]||li@>'
         - if <def[result].is_empty> {
           - foreach %args% {
             - if <player.permission[<script.yaml_key[commandArgs.%value%.permission]>]||false> || <player.is_op> {
               - define result '<def[result].include[%value%]||%result%>'
               }
               else {
               - foreach next
               }
             }
           }
         }
       }
 
   tab_about:
     - define result 'li@'
 
   tab_filter:
   # /sg filter (list/add/remove)
     - define spaces '<c.raw_args.to_list.count[ ]||0>'
     - if <def[spaces].is[==].to[0]> {
       - define result 'filter (list/add/remove)'
       }
       else if <def[spaces].is[==].to[1]> {
       - if <c.args.get[2]||null> == null {
         - define result '(list/add/remove)'
         }
         else {
         - define result '<li@list|add|remove.filter[starts_with[<c.args.get[2]>]]||li@>'
         - if <def[result].is_empty> {
           - define result 'li@list|add|remove'
           }
         }
       }
       else if <c.args.size> >= 2 {
       - if <c.args.get[2]> == list || <c.args.get[2]> == add {
         - define result 'li@'
         }
         else if <c.args.get[2]> == remove {
         - define wordList '<server.flag[SwearGuard.List].as_list.unescape_contents||li@>'
         - if <c.args.size> >= 3 {
           - define entry '<c.args.get[3].to[<c.args.size>].escape_contents.space_separated||null>'
           - define result '<def[wordList].filter[starts_with[%entry%]]||li@>'
           - if <def[result].is_empty> {
             - define result '%wordList%'
             }
           }
           else {
           - define result '%wordList%'
           }
         }
       }
 
   tab_stats:
     - define spaces '<c.raw_args.to_list.count[ ]||0>'
     - if <def[spaces].is[==].to[0]> {
       - define result 'stats [player]'
       }
       else if <def[spaces].is[==].to[1]> {
       - if <c.args.get[2]||null> == null {
         - define result '[player]'
         }
         else {
         - define result '<server.list_players.filter[name.starts_with[<c.args.get[2]>]].parse[name].alphanumeric||li@>'
         - if <def[result].is_empty> {
           - define result '<server.list_players.parse[name].alphanumeric>'
           }
         }
       }
 #
 #  END SwearGuard Command TAB Completion
 #--------------------------------------
 #
 #  SwearGuard Command Arguments
 #
 # Each of these subscripts is an argument for the root command.
 #
   help:
     - define arg '<c.args.get[2].escaped||null>'
     - if <def[args].contains[%arg%]||false> {
       - run s@SwearGuard_Msg 'def:<script.yaml_key[commandArgs.%arg%.usage]||No help for you!>'
       - queue clear
       }
     - if <player.permission[SwearGuard.admin]||false> || <player.is_op> || <context.server> {
       - inject s@SwearGuard_Msg msgsHelpAdmin
       }
       else {
       - inject s@SwearGuard_Msg msgsHelpUser
       }
     - inject s@SwearGuard_Msg msgsFooter
     - queue clear
 
   about:
     - inject s@SwearGuard_Msg msgsAbout
     - inject s@SwearGuard_Msg msgsFooter
     - queue clear
 
   filter:
   # /sg filter (list/add/remove)
     - if !<player.permission[SwearGuard.admin]||false> && !<player.is_op> && !<context.server> {
       - inject s@SwearGuard_Msg msgsHelpUser
       - inject s@SwearGuard_Msg msgsFooter
       - queue clear
       }
     - define arg1 '<c.args.get[2]||null>'
     - define wordList '<server.flag[SwearGuard.List].as_list||li@>'
     # Show a list of all prohibited words/phrases
     - if %arg1% == list {
       - define page '<c.args.get[3].replace[-].escaped||1>'
       - if <def[page].is[MATCHES].to[number].not> {
         - define page '1'
         }
       - define pages '<def[wordList].size.div[10].round_up||1>'
       - if <def[page].is[MORE].than[%pages%]> {
         - define page '%pages%'
         }
       - define highNumber '<def[page].mul[10].as_int>'
       - define lowNumber '<def[highNumber].sub[9].as_int>'
       - define msgsHeaderTitle '<&e>Word List   <el@val[<&7><&o>Page <&f><&o>%page% <&7><&o>of %pages%].pad_left[30]>'
       - inject s@SwearGuard_Msg msgsHeader instantly
       - foreach <def[wordList].get[%lowNumber%].to[%highNumber%]||li@> {
         - define lineNumber '<def[lowNumber].add[%loop_index%].sub[1]>'
         - narrate "<&5>|<tern[<def[lineNumber].is[matches].to[even number]>]:<&e>||<&6>><def[lineNumber].pad_left[5]>.<&sp><&sp><tern[<def[lineNumber].is[matches].to[even number]>]:<&f>||<&7>><def[value].unescaped>"
         }
       - narrate "<&5>|"
       - inject s@SwearGuard_Msg msgsFooter instantly
       - queue clear
       }
 
     - if %arg1% == add {
       - if <c.args.size> < 3 {
         - run s@SwearGuard_Msg 'def:<&e>/sg filter add [phrase to add]'
         - queue clear
         }
       - define entry '<c.args.get[3].to[<c.args.size>].escape_contents.space_separated||null>'
       - if %wordList% contains %entry% {
         - run s@SwearGuard_Msg 'def:<&6>That entry already exists!'
         - queue clear
         }
       - flag server 'SwearGuard.List:->:%entry%'
       - run s@SwearGuard_Msg 'def:<&f>Added <def[entry].unescaped>'
       - queue clear
       }
 
     - if %arg1% == remove {
       - if <c.args.size> < 3 {
         - run s@SwearGuard_Msg 'def:<&e>/sg filter add [phrase to add]'
         - queue clear
         }
       - define entry '<c.args.get[3].to[<c.args.size>].escape_contents.space_separated||null>'
       - if %wordList% !contains %entry% {
         - run s@SwearGuard_Msg 'def:<&6>That entry does not exist!'
         - queue clear
         }
       - flag server 'SwearGuard.List:<-:%entry%'
       - run s@SwearGuard_Msg 'def:<&f>Removed <def[entry].unescaped>'
       - queue clear
       }
     - run s@SwearGuard_Msg 'def:<script.yaml_key[commandArgs.filter.usage]>'
 
   stats:
     - if !<player.permission[SwearGuard.admin]||false> && !<player.is_op> && !<context.server> {
       - inject s@SwearGuard_Msg msgsHelpUser
       - inject s@SwearGuard_Msg msgsFooter
       - queue clear
       }
     - define player '<c.args.get[2].escaped||null>'
     - if %player% == null {
       - define player <player>
       }
       else {
       - define player <server.match_offline_player[%player%]||null>
       }
     - if %player% == null {
       - run s@SwearGuard_Msg 'def:<&c>Invalid player!'
       - queue clear
       }
     - if <c.args.get[3].escaped||null> == set {
       - define amount <c.args.get[4].escaped||null>
       - if %amount% == null || %amount% !matches number || %amount% < 0 || %amount% > 19 {
         - run s@SwearGuard_Msg 'def:<&c>Valid value range 0-19'
         }
         else {
         - flag %player% 'SwearGuard.Count:%amount%'
         - run s@SwearGuard_Msg 'def:<&7><&o>Set <&f><def[player].name><&7><&o> infraction level to <&f><def[player].flag[SwearGuard.Count].as_int||0><&7><&o>.'
         }
       - queue clear
       }
     - run s@SwearGuard_Msg 'def:<&7><&o>Infraction level for <&f><def[player].name><&7><&o> is <&f><def[player].flag[SwearGuard.Count].as_int||0><&7><&o>.'
     - run s@SwearGuard_Msg 'def:<&7>Last Infraction<&co>'
     - define lines '<proc[SwearGuard_LineWrap].context[<def[player].flag[SwearGuard.LastInfraction].unescaped>|44]>'
     - foreach <def[lines]> {
       - run s@SwearGuard_Msg 'def:<&c><def[value]>'
       }
     - if <def[player].flag[SwearGuard.Count].as_int||0> != 0 {
       - define timeLeft '<player.flag[swearguard.duration].sub[<server.current_time_millis>].div[1000].as_duration.formatted>'
       - run s@SwearGuard_Msg 'def:<&7>Time till level decrease<&co> <&a><tern[<def[timeLeft].is[==].to[forever]>]:soon||%timeLeft%><&f>.'
       }
 #
 #  END SwearGuard Command Arguments
 #--------------------------------------
 #
 ################################################################################
 #
 #  SwearGuard Message Formatter
 #
 # A home for any messages
 #
 SwearGuard_Msg:
   type: item
   speed: 0
   debug: false
   material: i@human_skull
   display name: "<&4>[<&6>SwearGuard<&4>]"
   lore:
   - <&5>Click for Help
 
   script:
     - ^define text '<&4>[<&6>SwearGuard<&4>]'
     - ^define hover '<&chr[007B]><i@SwearGuard_Msg.json><&chr[007D]>'
     - ^define click '/SwearGuard help'
     - ^define button "text:'%text%',clickEvent:<&chr[007B]>action:run_command,value:'%click%'<&chr[007D]>,hoverEvent:<&chr[007B]>action:show_item,value:'%hover%'<&chr[007d]>"
     - ^define spacer "text:'  '"
     - ^define msg "text:'%1%'"
     - ^if <player.is_player||false> {
       - execute as_server "tellraw <player.name> <&chr[007B]>text:'',extra:[<&chr[007B]>%button%<&chr[007D]>,<&chr[007B]>%spacer%<&chr[007D]>,<&chr[007B]>%msg%<&chr[007D]>]<&chr[007D]>"
       }
       else {
       - announce to_console "%1%"
       }
 
   msgsHeader:
     - narrate "<&5>|----------------------------------------|"
     - narrate "<&5>|<&sp><&sp><&sp><&6>SwearGuard   <&7><def[msgsHeaderTitle]||>"
     - narrate "<&5>|<&f>"
 
   msgsFooter:
     - define anthony "text<&co>'<&7>|Anthony|',clickEvent<&co><&chr[007B]>action<&co>open_url,value<&co>'http<&co>//mineconomy.org'<&chr[007D]>,hoverEvent<&co><&chr[007B]>action<&co>show_item,value<&co>'<&chr[007B]><i@SwearGuard_Author_Anthony.json><&chr[007D]>'<&chr[007D]>"
     - define spacer "text<&co>'  '"
     - define prefix "text<&co>'<&5>|  <&f>Authors<&co>  '"
     - if <player.is_player||false> {
       - execute as_server "tellraw <player.name> <&chr[007B]>text<&co>'',extra<&co>[<&chr[007B]>%prefix%<&chr[007D]>,<&chr[007B]>%anthony%<&chr[007D]>]<&chr[007D]>"
       }
       else {
       - announce to_console "<&5>|  <&f>Authors<&co>    <&7>|Anthony|"
       }
     - narrate "<&5>|-----------<&d>S<&5>-<&d>c<&5>-<&d>r<&5>-<&d>o<&5>-<&d>l<&5>-<&d>l<&5>---<&d>U<&5>-<&d>p<&5>-------------|"
 
   msgsHelpAdmin:
     # Filter the list of commands this player can use
     - define commands '<s@SwearGuard_Commands.list_keys[commandArgs].alphanumeric||li@>'
     - foreach %commands% {
       - if !<player.permission[SwearGuard.admin]||false> || <player.is_op> || <context.server> {
         - define commands '<def[commands].exclude[%value%]>'
         }
         else {
         - foreach next
         }
       }
     - define page '<def[arg].replace[-].escaped||1>'
     - if <def[page].is[MATCHES].to[number].not> {
       - define page '1'
       }
     - define pages '<def[commands].size.div[5].round_up||1>'
     - if <def[page].is[MORE].than[%pages%]> {
       - define page '%pages%'
       }
     - define highNumber '<def[page].mul[5].as_int>'
     - define lowNumber '<def[highNumber].sub[4].as_int>'
     - define msgsHeaderTitle '<&e>Admin Help   <el@val[<&7><&o>Page <&f><&o>%page% <&7><&o>of %pages%].pad_left[30]>'
     - inject locally msgsHeader instantly
     - foreach <def[commands].get[%lowNumber%].to[%highNumber%]||li@> {
       - narrate "<&5>|<&sp><&sp><&e><def[value].to_titlecase><&co> <&f><s@SwearGuard_Commands.yaml_key[commandArgs.%value%.desc]||>"
       - narrate "<&5>|<&sp><&sp><&sp><&sp><&7><s@SwearGuard_Commands.yaml_key[commandArgs.%value%.usage]||No usage info available!>"
       - narrate "<&5>|"
       }
 
   msgsHelpUser:
     - define msgsHeaderTitle 'User Help'
     - inject locally msgsHeader instantly
     - define par1 "Every time you use a prohibited word or phrase, your SwearGuard infraction level increases. This can lead to punishments ranging from temp mutes, kicks, and temp bans."
     - define par2 "Your infraction level will go down over time, but the higher your infraction level is, the longer it will take for each level."
     - define strings "<el@val[%par1%|%par2%].as_list>"
     - foreach <def[strings]> {
       - define string "<&f><&sp><def[value]>"
       - define lines '<proc[SwearGuard_LineWrap].context[<def[string]>|44]>'
       - foreach <def[lines]> {
         - narrate "<&5>|<&f><&sp><&sp><def[value].unescaped>"
         }
       - narrate "<&5>|"
       }
-    - define par3 "Your current infraction level is <&b><player.flag[SwearGuard.Count].as_int||0><&f>."
-    - if <player.flag[SwearGuard.Count].as_int||0> == 0 {
-      - random {
-        - define par4 "Yay! You are well behaved!"
-        - define par4 "Good clean chat. You should get a cookie!"
-        - define par4 "You are pure of heart."
+    - if <s@SwearGuard.yaml_key[config.showPlayerStats]> {
+      - define par3 "Your current infraction level is <&b><player.flag[SwearGuard.Count].as_int||0><&f>."
+      - if <player.flag[SwearGuard.Count].as_int||0> == 0 {
+        - random {
+          - define par4 "Yay! You are well behaved!"
+          - define par4 "Good clean chat. You should get a cookie!"
+          - define par4 "You are pure of heart."
+          }
+        }
+        else {
+        - define timeLeft '<player.flag[swearguard.duration].sub[<server.current_time_millis>].div[1000].as_duration.formatted>'
+        - define par4 "Your infraction level will decrease <tern[<def[timeLeft].is[==].to[forever]>]:soon||in <&a>%timeLeft%><&f>."
         }
-      }
-      else {
-      - define timeLeft '<player.flag[swearguard.duration].sub[<server.current_time_millis>].div[1000].as_duration.formatted>'
-      - define par4 "Your infraction level will decrease <tern[<def[timeLeft].is[==].to[forever]>]:soon||in <&a>%timeLeft%><&f>."
-      }
-    - define strings "<el@val[%par3%|%par4%].as_list>"
-    - foreach <def[strings]> {
+      - define strings "<el@val[%par3%|%par4%].as_list>"
+      - foreach <def[strings]> {
+        - define string "<&f><def[value]>"
+        - define lines '<proc[SwearGuard_LineWrap].context[<def[string]>|45]>'
+        - foreach <def[lines]> {
+          - narrate "<&5>|<&f><&sp><&sp><def[value].unescaped>"
+          }
-      - define string "<&f><def[value]>"
-      - define lines '<proc[SwearGuard_LineWrap].context[<def[string]>|45]>'
-      - foreach <def[lines]> {
-        - narrate "<&5>|<&f><&sp><&sp><def[value].unescaped>"
         }
+      - narrate "<&5>|"
       }
-    - narrate "<&5>|"
 
   msgsAbout:
     - define msgsHeaderTitle 'About'
     - inject locally msgsHeader instantly
     - define par1 "SwearGuard is a flexible, extensible, and light weight system written with the Denizen Scripting Engine."
     - define par2 "SwearGuard allows users to configure a list of words or phrases that players will be punished for using. Continued use of prohibited words will elevate your infraction level resulting in mutes, kicks, and temporary bans."
     - define par3 "SwearGuard was written upon request for The Dented Shield network by Anthony."
     - define strings "<el@val[%par1%|%par2%|%par3%].as_list>"
     - foreach <def[strings]> {
       - define string "<&f><&sp><def[value]>"
       - define lines '<proc[SwearGuard_LineWrap].context[<def[string]>|44]>'
       - foreach <def[lines]> {
         - narrate "<&5>|<&f><&sp><&sp><def[value].unescaped>"
         }
       - narrate "<&5>|"
       }
 #
 #  END SwearGuard Message Formatter
 #--------------------------------------
 #
 ################################################################################
 #
 #  SwearGuard Line Wrap Utility
 #
 # Turn a long string into a list of smaller strings
 #
 SwearGuard_LineWrap:
   type: procedure
   definitions: string|targetLen
   speed: 0
   debug: false
 
   script:
     - define stringLen '<def[string].length>'
     - if <def[stringLen].is[MORE].than[%targetLen%]> {
       - define lines 'li@'
       - while <def[stringLen].is[MORE].than[0]> {
         - define low '<def[increment].add[1].as_int||1>'
         - define hi '<def[increment].add[<def[targetLen].add[1]>].as_int||%targetLen%>'
         - define pass '<def[string].substring[%low%,%hi%]>'
         - if <def[pass].length.is[==].to[%stringLen%]> {
           - define lines '<def[lines].include[%pass%]||<def[lines]>>'
           - while stop
           }
           else {
           - define brake '<def[pass].last_index_of[ ]>'
           - define increment '<def[increment].add[%brake%]||%brake%>'
           - define passtrim '<def[pass].substring[1,<t[<def[brake].is[MORE].than[0]>]:%brake%||<def[pass].length>>]>'
           - define lines '<def[lines].include[%passtrim%]||<def[lines]>>'
           - define stringLen '<def[stringLen].sub[%brake%]>'
           }
         - if <def[loop_index].is[MORE].than[10]> {
           - while stop
           }
         }
       - determine '<def[lines].as_list>'
       }
       else {
       - determine '<def[string].as_list>'
       }
 #
 #  END SwearGuard Line Wrap Utility
 #--------------------------------------
 #
 ################################################################################
 #
 #  SwearGuard author banner items
 #
 # Banner items representing the authors
 #
 SwearGuard_Author_Anthony:
   type: item
   speed: 0
   debug: false
   material: i@human_skull
   display name: "<&f>             |Anthony|"
   lore:
   - <&7>  Owner<&co> <&e>M<&6>ine<&e>C<&6>onomy <&e>N<&6>etwork
   - <&5>-------------------------
   - <&7>
   - <&7>  I`ve been playing minecraft
   - <&7> and running a server since
   - <&7> 2010. I have fun and share
   - <&7> what I do.
   - <&7>
   - <&9>           Click To Visit
 #
 #  END SwearGuard author banner items
 #--------------------------------------
-