Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.
#-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x
# ╔═╗╦╔═╦═╗┌─┐┌─┐┬┌─┐┌┐┌┌─┐
# ╚═╗╠╩╗╠╦╝├┤ │ ┬││ ││││└─┐
# ╚═╝╩ ╩╩╚═└─┘└─┘┴└─┘┘└┘└─┘
#! by Aerosmite35
options:
# Logo before messages
skregion: §c[§l&4SKRegions§r§c]§r §6
# Folder path ('/' at the end)
path: plugins/Skript/scripts/SKRegion/
# Current commands permission
perm: bukkit.command.op.give
#-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x
#! Don't modify it unless you know what you're doing
# _____ _ _
# | __|_ _ ___ ___| |_|_|___ ___ ___
# | __| | | | _| _| | . | |_ -|
# |__| |___|_|_|___|_| |_|___|_|_|___|
# Return the region's world (else 'none')
function WorldofRegion(region: text,f: text) :: text:
loop yml nodes "" of file "{@path}%{_f}%":
if yml path "%loop-value%.%{_region}%" in file "{@path}%{_f}%" exists:
return "%loop-value%"
stop
return "none"
# YML to Skript's location
function setlocregion(world: text,path: text,f: text) :: location:
set {_parse} to yml value "%{_world}%.%{_path}%" from file "{@path}%{_f}%"
set {_parsed::*} to {_parse} parsed as "%num% %num% %num%"
return location({_parsed::1},{_parsed::2},{_parsed::3}, world({_world}))
# Add '.yml' to non-extensions files
function skregionfile(file: text) :: text:
if file "%{_file}%"'s extension is not "yml":
return "%{_file}%.yml"
else:
return "%{_file}%"
# Return if the player is in the region
function LocisWithin(loc: location,region: text,file: text="regions.yml") :: boolean:
set {_f} to skregionfile({_file})
set {_loc1} to setlocregion("%world of {_loc}%","%{_region}%.1","%{_f}%")
set {_loc2} to setlocregion("%world of {_loc}%","%{_region}%.2","%{_f}%")
loop "x", "y" and "z":
evaluate "set {_loc1current} to %loop-value%-coord of {_loc1}"
evaluate "set {_loc2current} to %loop-value%-coord of {_loc2}"
if {_loc1current} is greater than {_loc2current}:
if "%{_loc1}%" doesn't contain ".":
set {_loc1current} to {_loc1current} + 1
else:
if "%{_loc2}%" doesn't contain ".":
set {_loc2current} to {_loc2current} + 1
evaluate "set %loop-value%-coord of {_loc1} to {_loc1current}"
evaluate "set %loop-value%-coord of {_loc2} to {_loc2current}"
if {_loc} is within {_loc1} to {_loc2}:
return true
else:
return false
# Add a region (false if an error was encountered)
function skregionadd(region: text, loc1: location, loc2: location, file: text="regions.yml") :: boolean:
set {_f} to skregionfile({_file})
if file "{@path}%{_f}%" doesn't exist:
create file "{@path}%{_f}%"
if WorldofRegion("%{_region}%",{_f}) is "none":
if world of {_loc1} is world of {_loc2}:
set "%world of {_loc1}%.%{_region}%.1" to "%x-coord of {_loc1}% %y-coord of {_loc1}% %z-coord of {_loc1}%" in yaml file "{@path}%{_f}%"
set "%world of {_loc1}%.%{_region}%.2" to "%x-coord of {_loc2}% %y-coord of {_loc2}% %z-coord of {_loc2}%" in yaml file "{@path}%{_f}%"
return true
stop
return false
# Clear a region (false if an error was encountered)
function skregionclear(region: text, file: text="regions.yml") :: boolean:
set {_f} to skregionfile({_file})
set {_world} to WorldofRegion("%{_region}%",{_f})
if {_world} is not "none":
delete yml value "%{_world}%.%{_region}%" from file "{@path}%{_f}%"
return true
stop
else:
if {_region} is "*":
if file "{@path}%{_f}%" exists:
delete file "{@path}%{_f}%"
return true
stop
return false
# Return the player's region of a file (else 'none')
function LocInRegion(loc: location,f: text="regions.yml") :: text:
loop yml nodes "%world of {_loc}%" of file "{@path}%{_f}%":
if LocisWithin({_loc},"%loop-value%","%{_f}%") is true:
return "%loop-value%"
stop
return "none"
# Same with several files
function LocInRegions(loc: location,f: strings) :: text:
loop {_f::*}:
loop yml nodes "%world of {_loc}%" of file "{@path}%loop-value-1%":
if LocisWithin({_loc},"%loop-value-2%","%loop-value-1%") is true:
return "%loop-value-2%"
stop
return "none"
# _____ _
# | |___ _____ _____ ___ ___ _| |___
# | --| . | | | .'| | . |_ -|
# |_____|___|_|_|_|_|_|_|__,|_|_|___|___|
# SKRegion command
command /skregion <text> [<text>] [<text>]:
aliases:/skr
permission: {@perm}
executable by: players and console
usage:/skregion <create|clear|display|list> [region] [file's name]
trigger:
if arg-3 is set:
set {_f} to skregionfile(arg-3)
else:
set {_f} to "regions.yml"
if arg-2 is not set:
if arg-1 is "list":
set {_files::*} to dir "{@path}"'s files
if {_files::*} is set:
send "{@skregion}Recognized regions:"
loop dir "{@path}"'s files:
send "&6&n%file loop-value-1's name%:"
send "%new line%"
loop yml nodes "" of file "%loop-value-1%":
if loop-value-2 is "regions":
send " &cWorldGuard's regions"
else:
send " &a%loop-value-2%&r:"
loop yml nodes "%loop-value-2%" of file "%loop-value-1%":
set {_loc1} to yml value "%loop-value-2%.%loop-value-3%.1" from file "%loop-value-1%"
set {_loc2} to yml value "%loop-value-2%.%loop-value-3%.2" from file "%loop-value-1%"
send " &e%loop-value-3%&r: &b[&3%{_loc1}%&b] [&3%{_loc2}%&b]"
send "%new line%"
else:
send "&cNo regions was found"
else:
send "&cUnknown argument, please use '&blist&c' or specify a region"
else:
set {_world} to WorldofRegion("%arg-2%",{_f})
if arg-1 is "create" or "add":
if file "{@path}%{_f}%" doesn't exist:
create file "{@path}%{_f}%"
send "{@skregion}File &b%{_f}%&6 has been created"
if {_world} is "none":
set "%world of we pos 1 of player%.%arg-2%.1" to "%x-coord of we pos 1 of player% %y-coord of we pos 1 of player% %z-coord of we pos 1 of player%" in yaml file "{@path}%{_f}%"
set "%world of we pos 1 of player%.%arg-2%.2" to "%x-coord of we pos 2 of player% %y-coord of we pos 2 of player% %z-coord of we pos 2 of player%" in yaml file "{@path}%{_f}%"
send "{@skregion}Region &b%arg-2%&6 has been added from &b[&3%x-coord of we pos 1 of player% %y-coord of we pos 1 of player% %z-coord of we pos 1 of player%&b]&6 to &b[&3%x-coord of we pos 2 of player% %y-coord of we pos 2 of player% %z-coord of we pos 2 of player%&b]&6 in &b%{_f}%"
else:
send "&cRegion &b%arg-2%&c already exists"
else if arg-1 is "clear" or "delete":
if {_world} is not "none":
delete yml value "%{_world}%.%arg-2%" from file "{@path}%{_f}%"
send "{@skregion}Region &b%arg-2%&6 has been cleared in &b%{_f}%"
else:
if arg-2 is "*":
if file "{@path}%{_f}%" exists:
delete file "{@path}%{_f}%"
send "{@skregion}File &b%{_f}%&6 has been deleted"
else:
send "&cFile &b%{_f}%&c could not be found"
else:
send "&cRegion &b%arg-2%&c could not be found"
else if arg-1 is "display":
if {_world} is not "none":
set we pos 1 of player to setlocregion("%{_world}%","%arg-2%.1","%{_f}%")
set we pos 2 of player to setlocregion("%{_world}%","%arg-2%.2","%{_f}%")
send "{@skregion}Region &b%arg-2%&6 has been added to your current selection"
else:
send "&cRegion &b%arg-2%&c could not be found"
else:
send "&cUnknown argument, please use '&bcreate&c', '&bclear&c' or '&bdisplay"
# WorldGuard's regions to SKRegions command
command /regionsWGtoSK <text> <text>:
usage:/regionsWGtoSK <file's name> <regions' world>
permission: {@perm}
executable by: players and console
trigger:
set {_f} to skregionfile(arg-1)
if yml path "regions" in file "{@path}%{_f}%" exists:
if file "SKR%{_f}%" exists:
delete file "SKR%{_f}%"
send "{@skregion}Converting..."
loop yml nodes "regions" of file "{@path}%{_f}%":
loop "min" and "max":
loop "x", "y" and "z":
set {_SK%loop-value-1%%loop-value-2%%loop-value-3%} to yml value "regions.%loop-value-1%.%loop-value-2%.%loop-value-3%" from file "{@path}%{_f}%"
set {_SK%loop-value-1%%loop-value-2%%loop-value-3%} to {_SK%loop-value-1%%loop-value-2%%loop-value-3%} parsed as num
set {_loc1} to location({_SK%loop-value-1%minx},{_SK%loop-value-1%miny},{_SK%loop-value-1%minz}, world(arg-2))
set {_loc2} to location({_SK%loop-value-1%maxx},{_SK%loop-value-1%maxy},{_SK%loop-value-1%maxz}, world(arg-2))
skregionadd("%loop-value%",{_loc1},{_loc2},"SKR%{_f}%")
send "{@skregion}Converted regions has been added to &bSKR%{_f}%"
else:
send "&cWorldGuard &b%{_f}%&6 file could not be found or is corrupt"