# ######################################################## # # # # NetherEndStatus - easy management of Nether and End! # # Version: 1.0-BETA # # Please note that, this project is in early beta! # # # # Welcome in code of script! # # Thanks for choosing my project # # # # ######################################################## # # Copyright (C) 2018 Szymoon202 - SzymoonPL # This program 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. # This program 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. # You should have received a copy of the GNU General Public License # along with this program. If not, see https://www.gnu.org/licenses/. function checkNumber(variable: text) :: text: set {_l} to length of {_variable} if {_l} is 1: set {_variable} to "0%{_variable}%" return {_variable} else: return {_variable} function log(mode: text, what: text, sets: text, variable: text, deafult: text): if {_mode} is "info": send "[NetherEndStatus] &6&nManager&r &f>> &r%{_what}%" to console if {_mode} is "update": send "[NetherEndStatus] &2&nUpdater&r &f>> &r%{_what}%" to console if {_mode} is "config-error": add 1 to {nes::errors} send "[NetherEndStatus] &4##!##! &cSomething wrong with your configuration in '%{_what}%'." to console send "[NetherEndStatus] &4##!##! &cYou must set %{_sets}%, not '%{_variable}%'." to console send "[NetherEndStatus] &4##!##! &cWe going back to the default value: '%{_deafult}%'" to console send "[NetherEndStatus] &4##!##! &cChange this value in config now!" to console send "" to console function updater(mode: text, sender: sender): if {_mode} is "check": if {nes::updater::check} is true: set {_script::newest::*} to contents from url "http://teamspeak.zarabiam.com/NetherEndStatus/script.version" set {_config::newest::*} to contents from url "http://teamspeak.zarabiam.com/NetherEndStatus/config.version" loop {_script::newest::*}: add 1 to {_n} if {_n} is 1: set {_script::newest} to loop-value if {_n} is 2: set {_script::newest::configchanged} to loop-value if {_n} is 3: set {_script::newest::msg} to loop-value set {_config::newest} to first element of {_config::newest::*} if "%{_script::newest}%" is "1.0-BETA": log("update", "&fWe didn't find any updates.", "", "", "") log("update", "&fYou using the newest version of the script.", "", "", "") else: log("update", "&fWe found a new version of the script!", "", "", "") log("update", "&fCurrent version: &a1.0-BETA", "", "", "") log("update", "&fNewest: &a%{_script::newest}%", "", "", "") log("update", "&fMessage from server: &a%{_script::newest::msg}%", "", "", "") log("update", "&fPlease update the script as soon as possible using '/netherendstatus download' command.", "", "", "") if {_mode} is "download": set {_script::newest::*} to contents from url "http://teamspeak.zarabiam.com/NetherEndStatus/script.version" set {_config::newest::*} to contents from url "http://teamspeak.zarabiam.com/NetherEndStatus/config.version" loop {_script::newest::*}: add 1 to {_n} if {_n} is 1: set {_script::newest} to loop-value if {_n} is 2: set {_script::newest::configchanged} to loop-value if {_n} is 3: set {_script::newest::msg} to loop-value set {_config::newest} to first element of {_config::newest::*} if "%{_script::newest}%" is "1.0-BETA": send " &8» &cWe didn't find any updates." to {_sender} send " &8» &cYou using the newest version of the script." to {_sender} stop else: if {_script::newest::configchanged} is "true": if {nes::update::informed} is not set: set {nes::update::informed} to true log("update", "&cImportant! &fIn the new version of the script, there is a new config.", "", "", "") loop 3 times: log("update", "&cImportant! &fSave all necessary data from the current config file!", "", "", "") log("update", "&cImportant! &fYou have been warned. Enter again '/netherendstatus download' to continue.", "", "", "") else: delete {nes::update::informed} log("update", "&f------------------------------", "", "", "") log("update", "&fIn the new version of the script, there is a new config.", "", "", "") log("update", "&aStep 1: &fDownloading config file...", "", "", "") delete file "/plugins/Skript/scripts/NetherEndStatus/config.yml" download file from "http://teamspeak.zarabiam.com/NetherEndStatus/configs/%{_config::newest}%" to file "/plugins/Skript/scripts/NetherEndStatus/config.yml" log("update", "&cImportant! &fYou need to refill the new config file using the old saved data.", "", "", "") log("update", "&aStep 2: &fDownloading script file...", "", "", "") delete file "/plugins/Skript/scripts/NetherEndStatus.sk" download file from "http://teamspeak.zarabiam.com/NetherEndStatus/script.code" to file "/plugins/Skript/scripts/NetherEndStatus.sk" log("update", "&aStep 3: &fEnding...", "", "", "") log("update", "&aComplete! Updated to &f%{_script::newest}% &aversion of the script and &f%{_config::newest}% &aversion of config.", "", "", "") log("update", "&f------------------------------", "", "", "") execute console command "sk reload NetherEndStatus" else: log("update", "&f------------------------------", "", "", "") log("update", "&aStep 1: &fDownloading script file...", "", "", "") delete file "/plugins/Skript/scripts/NetherEndStatus.sk" download file from "http://teamspeak.zarabiam.com/NetherEndStatus/script.code" to file "/plugins/Skript/scripts/NetherEndStatus.sk" log("update", "&aStep 2: &fEnding...", "", "", "") log("update", "&aComplete! Updated to &f%{_script::newest}% &aversion of the script.", "", "", "") log("update", "&f------------------------------", "", "", "") execute console command "sk reload NetherEndStatus" function load(mode: text): if {_mode} is "imports": import "org.bukkit.event.player.PlayerPortalEvent" if {_mode} is "files": set {_x} to now if directory "/plugins/Skript/scripts/NetherEndStatus/" doesn't exist: log("info","&cWe couldn't find script directory. Let's do it!", "", "", "") create directory "/plugins/Skript/scripts/NetherEndStatus/" if file "/plugins/Skript/scripts/NetherEndStatus/config.yml" doesn't exist: log("info", "&cWe couldn't find script config file. Let's do it!", "", "", "") download file from "http://teamspeak.zarabiam.com/NetherEndStatus/configs/1.0-BETA" to file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::config::version} to skutil yml value "netherendstatus.config version" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::config::version} to ({nes::config::version} parsed as number) if {nes::config::version} is not a number: log("config-error", "config version", "number value", "%{nes::config::version}%", "The configuration will be reset.") delete file "/plugins/Skript/scripts/NetherEndStatus/config.yml" download file from "http://teamspeak.zarabiam.com/NetherEndStatus/configs/1.0" to file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {_x} to difference between now and {_x} log("info", "&aFiles checked & loaded in %{_x}%!", "", "", "") if {_mode} is "variables": set {_x} to now set {nes::errors} to 0 clear {nes::worlds::*} delete {nes::update::informed} set {nes::updater::check} to skutil yml value "netherendstatus.updater system.check" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" if {nes::updater::check} is not "true" or "false" or true or false: log("config-error", "updater system.check", "boolean value", "%{nes::updater::check}%", "true") set {nes::updater::check} to true set {nes::updater::check} to ({nes::updater::check} parsed as boolean) #set {nes::variablesystem} to skutil yml value "netherendstatus.variable system" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" #if {nes::variablesystem} is not "uuid" or "playername": # log("config-error", "variable system", "'playername' or 'uuid'", "%{nes::variablesystem}%", "uuid") # set {nes::variablesystem} to "uuid" set {nes::vip::enable} to skutil yml value "netherendstatus.vip system.enable" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" if {nes::vip::enable} is not "true" or "false" or true or false: log("config-error", "vip system.enable", "boolean value", "%{nes::vip::enable}%", "true") set {nes::vip::enable} to true set {nes::vip::enable} to ({nes::vip::enable} parsed as boolean) set {nes::vip::permission} to skutil yml value "netherendstatus.vip system.permission" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" add "nether" and "end" to {nes::worlds::*} set {nes::world::worldname} to skutil yml value "netherendstatus.world names.normal" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::msgs::blockedcmd::*} to skutil yml list "netherendstatus.messages.this command is blocked" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::msgs::vip} to skutil yml value "netherendstatus.messages.vip" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::msgs::players} to skutil yml value "netherendstatus.messages.players" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::msgs::bypass} to skutil yml value "netherendstatus.messages.bypass" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" loop {nes::worlds::*}: set {nes::%loop-value%::worldname} to skutil yml value "netherendstatus.world names.%loop-value%" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::%loop-value%::bypass} to skutil yml value "netherendstatus.bypass.%loop-value%" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::%loop-value%::status} to false set {nes::vip::%loop-value%::status} to false set {nes::%loop-value%::open::hour} to skutil yml value "netherendstatus.%loop-value%.open.hour" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::%loop-value%::open::hour} to ({nes::%loop-value%::open::hour} parsed as number) if {nes::%loop-value%::open::hour} is not a number: log("config-error", "%loop-value%.open.hour", "number value", "%{nes::%loop-value%::open::hour}%", "16") set {nes::%loop-value%::open::hour} to 16 set {nes::%loop-value%::open::hour} to checkNumber("%{nes::%loop-value%::open::hour}%") set {nes::%loop-value%::open::minutes} to skutil yml value "netherendstatus.%loop-value%.open.minutes" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::%loop-value%::open::minutes} to ({nes::%loop-value%::open::minutes} parsed as number) if {nes::%loop-value%::open::minutes} is not a number: log("config-error", "%loop-value%.open.minutes", "number value", "%{nes::%loop-value%::open::minutes}%", "00") set {nes::%loop-value%::open::minutes} to 00 set {nes::%loop-value%::open::minutes} to checkNumber("%{nes::%loop-value%::open::minutes}%") set {nes::%loop-value%::close::hour} to skutil yml value "netherendstatus.%loop-value%.close.hour" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::%loop-value%::close::hour} to ({nes::%loop-value%::close::hour} parsed as number) if {nes::%loop-value%::close::hour} is not a number: log("config-error", "%loop-value%.close.hour", "number value", "%{nes::%loop-value%::close::hour}%", "18") set {nes::%loop-value%::close::hour} to 18 set {nes::%loop-value%::close::hour} to checkNumber("%{nes::%loop-value%::close::hour}%") set {nes::%loop-value%::close::minutes} to skutil yml value "netherendstatus.%loop-value%.close.minutes" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::%loop-value%::open::minutes} to ({nes::%loop-value%::close::minutes} parsed as number) if {nes::%loop-value%::close::minutes} is not a number: log("config-error", "%loop-value%.close.minutes", "number value", "%{nes::%loop-value%::close::minutes}%", "30") set {nes::%loop-value%::close::minutes} to 30 set {nes::%loop-value%::close::minutes} to checkNumber("%{nes::%loop-value%::close::minutes}%") set {nes::%loop-value%::commands::*} to skutil yml list "netherendstatus.%loop-value%.commands allowed" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" if {nes::vip::enable} is true: set {nes::vip::%loop-value%::open::hour} to skutil yml value "netherendstatus.%loop-value%.open.vip.hour" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::vip::%loop-value%::open::hour} to ({nes::vip::%loop-value%::open::hour} parsed as number) if {nes::vip::%loop-value%::open::hour} is not a number: log("config-error", "%loop-value%.open.vip.hour", "number value", "%{nes::vip::%loop-value%::open::hour}%", "15") set {nes::vip::%loop-value%::open::hour} to 15 set {nes::vip::%loop-value%::open::hour} to checkNumber("%{nes::vip::%loop-value%::open::hour}%") set {nes::vip::%loop-value%::open::minutes} to skutil yml value "netherendstatus.%loop-value%.open.vip.minutes" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::vip::%loop-value%::open::minutes} to ({nes::vip::%loop-value%::open::minutes} parsed as number) if {nes::vip::%loop-value%::open::minutes} is not a number: log("config-error", "%loop-value%.open.vip.minutes", "number value", "%{nes::vip::%loop-value%::open::minutes}%", "00") set {nes::vip::%loop-value%::open::minutes} to 00 set {nes::vip::%loop-value%::open::minutes} to checkNumber("%{nes::vip::%loop-value%::open::minutes}%") set {nes::vip::%loop-value%::close::hour} to skutil yml value "netherendstatus.%loop-value%.close.vip.hour" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::vip::%loop-value%::close::hour} to ({nes::vip::%loop-value%::close::hour} parsed as number) if {nes::vip::%loop-value%::close::hour} is not a number: log("config-error", "%loop-value%.close.vip.hour", "number value", "%{nes::vip::%loop-value%::close::hour}%", "19") set {nes::vip::%loop-value%::close::hour} to 19 set {nes::vip::%loop-value%::close::hour} to checkNumber("%{nes::vip::%loop-value%::close::hour}%") set {nes::vip::%loop-value%::close::minutes} to skutil yml value "netherendstatus.%loop-value%.close.vip.minutes" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::vip::%loop-value%::close::minutes} to ({nes::vip::%loop-value%::close::minutes} parsed as number) if {nes::vip::%loop-value%::close::minutes} is not a number: log("config-error", "%loop-value%.close.vip.minutes", "number value", "%{nes::vip::%loop-value%::close::minutes}%", "00") set {nes::vip::%loop-value%::close::minutes} to 00 set {nes::vip::%loop-value%::close::minutes} to checkNumber("%{nes::vip::%loop-value%::close::minutes}%") set {nes::msgs::%loop-value%::isclosed::*} to skutil yml list "netherendstatus.messages.%loop-value%.is closed" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::msgs::%loop-value%::opening::*} to skutil yml list "netherendstatus.messages.%loop-value%.opening" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {nes::msgs::%loop-value%::closing::*} to skutil yml list "netherendstatus.messages.%loop-value%.closing" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" replace all "{OPENING-HOURS}" with "%{nes::%loop-value%::open::hour}%:%{nes::%loop-value%::open::minutes}% -> %{nes::%loop-value%::close::hour}%:%{nes::%loop-value%::close::minutes}%" in {nes::msgs::%loop-value%::isclosed::*} replace all "{VIP-OPENING-HOURS}" with "%{nes::vip::%loop-value%::open::hour}%:%{nes::vip::%loop-value%::open::minutes}% -> %{nes::vip::%loop-value%::close::hour}%:%{nes::vip::%loop-value%::close::minutes}%" in {nes::msgs::%loop-value%::isclosed::*} loop {nes::%loop-value%::commands::*}: if {_cmds} is not set: set {_cmds} to "/%loop-value-2%" else: set {_cmds} to "%{_cmds}%, /%loop-value-2%" replace all "{COMMAND-LIST}" with {_cmds} in {nes::msgs::blockedcmd::*} set {nes::msgs::joinclosedworld::*} to skutil yml list "netherendstatus.messages.this world is closed" from file "/plugins/Skript/scripts/NetherEndStatus/config.yml" set {_x} to difference between now and {_x} if {nes::errors} is 0: log("info", "&aVery good, I didn't found any error in configuration.", "", "", "") else: log("info", "&cOh no... I found %{nes::errors}% errors in configuration!", "", "", "") log("info", "&aVariables loaded & parsed in %{_x}%!", "", "", "") on load: load("files") load("variables") load("imports") updater("check", console) on join: set {_p} to event-player loop {nes::worlds::*}: if {nes::%loop-value%::status} is false: if {_p}'s world is "%{nes::%loop-value%::worldname}%": teleport {_p} to spawn point of ({nes::world::worldname} parsed as world) set {_msg::*} to {nes::msgs::joinclosedworld::*} replace all "{PLAYER}" with "%{_p}%" in {_msg::*} loop {_msg::*}: send "%colored loop-value-2%" to {_p} on "org.bukkit.event.player.PlayerPortalEvent": if "%event.getTo().getWorld().getEnvironment()%" is "NETHER": if {nes::nether::status} is false: if event.getPlayer().hasPermission("%{nes::nether::bypass}%"): event.getPlayer().sendMessage("%colored {nes::msgs::bypass}%") else: cancel event loop {nes::msgs::nether::isclosed::*}: event.getPlayer().sendMessage("%colored loop-value%") if "%event.getTo().getWorld().getEnvironment()%" is "THE_END": if {nes::end::status} is false: if event.getPlayer().hasPermission("%{nes::end::bypass}%"): event.getPlayer().sendMessage("%colored {nes::msgs::bypass}%") else: cancel event loop {nes::msgs::end::isclosed::*}: event.getPlayer().sendMessage("%colored loop-value%") on command: set {_p} to event-player loop {nes::worlds::*}: if player's world is "%{nes::%loop-value%::worldname}%": if {nes::%loop-value%::commands::*} contains "/%command%": stop else if {_p} has permission "netherendstatus.admin": send " &8» &7&oYou have permission to execute blocked commands in this world." to {_p} else: cancel event set {_msg::*} to {nes::msgs::blockedcmd::*} replace all "{COMMAND}" with command in {_msg::*} loop {_msg::*}: send "%colored loop-value-2%" to {_p} every second: loop {nes::worlds::*}: set {_hour} to hours from date now set {_minutes} to minutes from date now if {_hour} is {nes::%loop-value%::open::hour}: if {_minutes} is {nes::%loop-value%::open::minutes}: if {nes::%loop-value%::status} is false: set {nes::%loop-value%::status} to true set {_bc::*} to {nes::msgs::%loop-value%::opening::*} replace all "{OPENED-FOR}" with "%{nes::msgs::players}%" in {_bc::*} replace all "{OPENED-TO}" with "%{nes::%loop-value%::close::hour}%:%{nes::%loop-value%::close::minutes}%" in {_bc::*} loop {_bc::*}: broadcast "%colored loop-value-2%" if {_hour} is {nes::%loop-value%::close::hour}: if {_minutes} is {nes::%loop-value%::close::minutes}: if {nes::%loop-value%::status} is true: set {nes::%loop-value%::status} to false set {_bc::*} to {nes::msgs::%loop-value%::closing::*} replace all "{CLOSED-FOR}" with "%{nes::msgs::players}%" in {_bc::*} replace all "{OPENED-FROM}" with "%{nes::%loop-value%::open::hour}%:%{nes::%loop-value%::open::minutes}%" in {_bc::*} loop {_bc::*}: broadcast "%colored loop-value-2%" loop all players: if loop-player's world is "%{nes::%loop-value-1%::worldname}%": teleport loop-player to spawn point of ({nes::world::worldname} parsed as world) if {_hour} is {nes::vip::%loop-value%::open::hour}: if {_minutes} is {nes::vip::%loop-value%::open::minutes}: if {nes::vip::%loop-value%::status} is false: set {nes::vip::%loop-value%::status} to true set {_bc::*} to {nes::msgs::%loop-value%::opening::*} replace all "{OPENED-FOR}" with "%{nes::msgs::vip}%" in {_bc::*} replace all "{OPENED-TO}" with "%{nes::vip::%loop-value%::close::hour}%:%{nes::vip::%loop-value%::close::minutes}%" in {_bc::*} loop {_bc::*}: broadcast "%colored loop-value-2%" if {_hour} is {nes::vip::%loop-value%::close::hour}: if {_minutes} is {nes::vip::%loop-value%::close::minutes}: if {nes::vip::%loop-value%::status} is true: set {nes::vip::%loop-value%::status} to false set {_bc::*} to {nes::msgs::%loop-value%::closing::*} replace all "{CLOSED-FOR}" with "%{nes::msgs::vip}%" in {_bc::*} replace all "{OPENED-FROM}" with "%{nes::vip::%loop-value%::open::hour}%:%{nes::vip::%loop-value%::open::minutes}%" in {_bc::*} loop {_bc::*}: broadcast "%colored loop-value-2%" loop all players: if loop-player's world is "%{nes::%loop-value-1%::worldname}%": teleport loop-player to spawn point of ({nes::world::worldname} parsed as world) command /netherendstatus []: trigger: if arg 1 is not set: send " &8» &aThis server is running &7NetherEndStatus &aversion &71.0-BETA&a." to sender send " &8» &aProject implemented by &7Szymoon202&a." to sender if arg 1 is not "download": send " &8» &cError: &7Invalid argument." to sender if arg 1 is "download": if sender is not console: if sender has permission "netherendstatus.admin": updater("download", sender) else: send " &8» &cYou don't have permission to use this command." to sender else: updater("download", sender)