################################################################################
#
# S w e a r G u a r d
#
#
# Authors: |Anthony|
# 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>'
- 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 <<>arg<>>'
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 <<>player<>> (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>|"
}
- 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>."
}
- 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>"
}
}
- 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
#--------------------------------------