options: dir: plugins/Skript/Maruda Chat/ config: plugins/Skript/Maruda Chat/config.yml messages: plugins/Skript/Maruda Chat/messages.yml permissions: plugins/Skript/Maruda Chat/permission.yml players: plugins/Skript/Maruda Chat/players/ function loadVariables(file: string, name: string): delete {marudaChat::%{_name}%::*} set {_list::*} to yaml node keys "" from file {_file} loop {_list::*}: set {_stringCheck} to false loop {marudaChat::yaml::*}: if loop-value-1 is loop-value-2: set {_stringCheck} to true if !{_stringCheck}: set {_index} to (loop-index) parsed as integer add 1 to {_index} if {_list::%{_index}%} does not start with "%loop-value%.": set {_value} to loop-value replace "." with "::" in {_value} if yaml list loop-value from file {_file} is set: set {_colour::*} to yaml list loop-value from file {_file} loop {_colour::*}: set {_colour::%loop-index-2%} to coloured loop-value-2 set {marudaChat::%{_name}%::%{_value}%::*} to {_colour::*} else: set {_colour} to yaml value loop-value from file {_file} add coloured {_colour} to {marudaChat::%{_name}%::%{_value}%::*} if {_name} is "config": loop {marudaChat::yaml::*}: set {_value} to loop-value replace "." with "::" in {_value} set {marudaChat::%{_name}%::%{_value}%} to yaml value loop-value from file {_file} function replaceEmotes(msg: string) :: string: loop {marudaChat::config::emotes::*}: replace all "%loop-value%" with "%{marudaChat::emotes::%loop-value%}%" in {_msg} return {_msg} function checkCommand(cmd: string, p: player) :: boolean: if {marudaChat::config::commands::block}: loop {marudaChat::config::commands::list::*}: if loop-value is {_cmd}: if {_p} has permission "chatmanager.*": return true return false return true else: loop {marudaChat::config::commands::list::*}: if loop-value is {_cmd}: return true if {_p} has permission "chatmanager.*": return true return false loop {marudaChat::config::commands::list::*}: if loop-value is {_cmd}: if {marudaChat::config::commands::block}: if {_p} do not have permission "chatmanager.*": return false return true else: return true if !{marudaChat::config::commands::block}: return false on disconnect: delete {marudaChat::config::automessage::playerTime::%player%} on join: if {marudaChat::config::automessage::status}: if {marudaChat::config::automessage::player}: if {marudaChat::config::automessage::interval} is set: set {_nodes::*} to yaml node keys "automessage.list" from file "{@config}" set {_now} and {marudaChat::config::automessage::playerTime::%player%} to now if {marudaChat::config::automessage::random}: while {_now} is {marudaChat::config::automessage::playerTime::%player%}: set {_random} to random element out of {_nodes::*} wait {marudaChat::config::automessage::interval} send {marudaChat::config::automessage::list::%{_random}%::*} else: while {_now} is {marudaChat::config::automessage::playerTime::%player%}: loop {_nodes::*}: wait {marudaChat::config::automessage::interval} if {_now} is {marudaChat::config::automessage::playerTime::%player%}: send {marudaChat::config::automessage::list::%loop-value%::*} else: stop on load: wait 5 seconds if {marudaChat::config::automessage::status}: if {marudaChat::config::automessage::interval} is set: if !{marudaChat::config::automessage::player}: set {_now} and {marudaChat::config::automessage::serverTime} to now set {_nodes::*} to yaml node keys "automessage.list" from file "{@config}" if {marudaChat::config::automessage::random}: while {_now} is {marudaChat::config::automessage::serverTime}: set {_random} to random element out of {_nodes::*} wait {marudaChat::config::automessage::interval} send {marudaChat::config::automessage::list::%{_random}%::*} to all players else: while {_now} is {marudaChat::config::automessage::serverTime}: loop {_nodes::*}: wait {marudaChat::config::automessage::interval} if {_now} is {marudaChat::config::automessage::serverTime}: send {marudaChat::config::automessage::list::%loop-value%::*} to all players else: stop on command: if sender is not console: if !checkCommand(command, player): send {marudaChat::messages::command-deny::*} cancel event on load: delete {marudaChat::*} add "chat", "automessage.status", "automessage.interval", "automessage.player", "automessage.random" and "commands.block" to {marudaChat::yaml::*} if file "{@config}" does not exist: create dir "{@dir}" download file from "https://code.skript.pl/Q9ZKZhu1/raw" to file "{@messages}" download file from "https://code.skript.pl/jqoNo9Wy/raw" to file "{@config}" wait 2 seconds if file "{@config}" exists: loadVariables("{@config}", "config") loadVariables("{@messages}", "messages") clear {clear::*} loop 100 times: add "" to {clear::*} delete {marudaChat::emotes::*} loop {marudaChat::config::emotes::*}: set {_emote::*} to loop-value split at " -|- " set {marudaChat::emotes::%{_emote::1}%} to {_emote::2} add {_emote::1} to {_lista::*} set {marudaChat::config::emotes::*} to {_lista::*} set {marudaChat::config::automessage::interval} to "%{marudaChat::config::automessage::interval}% seconds" parsed as timespan on chat: if !{marudaChat::config::chat}: if player do not have permission "chatmanager.*": cancel event send {marudaChat::messages::chat-deny::*} set message to coloured replaceEmotes(message) command /chatmanager [] []: aliases: chat, cm permission: chatmanager.* trigger: if arg 1 is not set: send {marudaChat::messages::help::*} else: if arg 1 is "wyczysc" or "clear": if arg 2 is set: send {clear::*} to arg 2 parsed as player send {marudaChat::messages::chat-cleared-player::*} to arg 2 parsed as player else: set {_gracze::*} to all players loop {_gracze::*}: if loop-value is not an op: remove loop-value from {_gracze::*} send {clear::*} to {_gracze::*} send {marudaChat::messages::chat-cleared::*} to {_gracze::*} else if arg 1 is "on" or "wlacz": if {marudaChat::config::chat}: send {marudaChat::messages::chat-currently-on::*} else: set {marudaChat::config::chat} to true send {marudaChat::messages::chat-on::*} else if arg 1 is "off" or "wylacz": if !{marudaChat::config::chat}: send {marudaChat::messages::chat-currently-off::*} else: set {marudaChat::config::chat} to false send {marudaChat::messages::chat-off::*} else if arg 1 is "toggle": if !{marudaChat::config::chat}: set {marudaChat::config::chat} to true send {marudaChat::messages::chat-on::*} else: set {marudaChat::config::chat} to false send {marudaChat::messages::chat-off::*} else if arg 1 is "reload": if arg 2 is "all": reload script script send {marudaChat::messages::chat-loaded-script::*} else if arg 2 is "config": loadVariables("{@config}", "config") send {marudaChat::messages::chat-loaded-config::*} else if arg 2 is "messages": loadVariables("{@messages}", "messages") send {marudaChat::messages::chat-loaded-messages::*}