Custom Regex Chat Tools

Custom Regex Chat Tools

306 Downloads

Custom Regex, Tested for: 1.8-1.12.2

This doesn't mean it won't work for other versions!

Permissions

zerodasho.customregex.generic - Allows use of /cregex (help/info)

zerodasho.customregex.reload   - Allows use of /cregex reload

Basics

Custom Regex allows you to use regular expressions on your server. If you have no idea what regular expressions are, and how to use them, I highly suggest reading up on them. If you don't feel like reading up on them, you can still use this plugin.

To censor a word, plug this into the config.yml

replace:
    censor_crap:
        regex: crap
        replacement: goodness
        must_match: false
        silent_replace: true

This will replace any chat message that contains the regex in it - in this case, crap - with the replacement: goodness. "silent_replace: true" makes it so that the player that sent the message with "crap" in it doesn't notice that his message has been censored!

Config

replace:
    #Name of regular expression
    howdy2hello:
        #Regular expression - if a chat message matches the regex, it will be replaced by the replacement message
        regex: (?i)([Hh])owdy (.*)!
        #Replacement message
        replacement: $1ello $2!
        #Player must have this permission for message to be replaced
        permission: zerodasho.customregex.generic
        #If true, the message changes for everyone except the sender. Useful for censor.
        silent_replace: true
        #Entire message must match the regex, not just a segment
        must_match: false
        # EXAMPLE:    
        #[Donator] Guy: Howdy Guy2!
        # Becomes:
        #[Donator] Guy: Hello Guy2!
    
commands:
    #Name of regular expression
    broadcast: 
        #Regular expression - if a chat message matches this regex, the following commands are run
        regex: (?i)bc (.*)
        #Player must have this permission for commands to execute
        permission: zerodasho.customregex.reload
        #If true, the chat message is canceled.
        cancel_chat: true
        commands:
            #Command to run
          - command: say $1
            is_player: false
        # EXAMPLE:
        #[Donator] Guy: bc Hello everyone!
        # Runs command:
        #[Server] Hello everyone!