options:
# Version for version checker, do not change.
version: 1.2.0
on load:
set {test::test} to 2 seconds
load yaml "plugins/RandomTP/config.yml" as "config"
if yaml path "Distance" in "config" does not have value:
set yaml value "Distance.min-x" from "config" to "5000"
set yaml value "Distance.min-z" from "config" to "5000"
set the comments of yaml node "Distance" from "config" to "Maximum x and z coords for random teleports, from center of world in either direction (use a positive number)"
if yaml path "Message Options" in "config" does not have value:
set yaml value "Message Options.prefix" from "config" to "&7[&a&lRTP&7]"
set yaml value "Message Options.color" from "config" to "&6"
set yaml value "Message Options.permission message" from "config" to "&cYou do not have permission to use this command"
set the comments of yaml node "Message Options" from "config" to "Prefix and color for chat messages and permission message"
if yaml path "Times" in "config" does not have value:
set yaml value "Times.delay" from "config" to "2 seconds"
set yaml value "Times.cooldown" from "config" to "60 seconds"
set yaml value "Times.safetycheck" from "config" to "false"
set the comments of yaml node "Times" from "config" to "Command cooldown and delay times" and "Safety Check = Will send messages to players, telling them whether" and "or not the chunk is safe with a slight delay"
if yaml path "Cost" in "config" does not have value:
set yaml value "Cost" from "config" to "0"
set the comments of yaml node "Cost" from "config" to "Cost for random teleports"
if yaml path "version" in "config" does not have value:
set the header of "config" to "Config options for RandomTP" and "Created by: ShaneBee" and "" and "Change the following options to suit the needs of your server"
set yaml value "version" from "config" to "{@version}"
set the comments of yaml node "version" from "config" to "Do NOT change the version number"
set yaml value "version" from "config" to "{@version}"
set {rtp::version} to yaml value "version" from "config"
set {rtp::distance::minx} to yaml value "Distance.min-x" from "config"
set {rtp::distance::minz} to yaml value "Distance.min-z" from "config"
set {rtp::msgoptions::prefix} to yaml value "Message Options.prefix" from "config"
set {rtp::msgoptions::color} to yaml value "Message Options.color" from "config"
set {rtp::msgoptions::permmsg} to yaml value "Message Options.permission message" from "config"
set {rtp::times::delay} to yaml value "Times.delay" from "config"
set {rtp::times::cooldown} to yaml value "Times.cooldown" from "config"
set {rtp::times::safetycheck} to yaml value "Times.safetycheck" from "config"
set {rtp::cost} to yaml value "Cost" from "config"
save yaml "config"
unload yaml "config"
delete {rtp::delay::*}
# -- VERSION CHECK --
send a "GET" request to "https://raw.githubusercontent.com/ShaneBeee/RandomTP/master/version"
set {_t} to last http response
set {_j} to {_t}'s body
set {_v::*} to {_j} split at "|"
send "&7[&a&lRTP&7] - &2Loaded successfully" to console
if "{@version}" is not equal to "%{_v::2}%":
send "&7[&a&lRandomTP&7] - &2Running version: {@version}" to console
send "&7[&a&lRandomTP&7] - &cUpdate available, version: %{_v::2}%" to console
else:
send "&7[&a&lRandomTP&7] - &2Running current version: {@version}" to console
on join:
wait 1 second
if player has permission "rtp.admin":
send a "GET" request to "https://raw.githubusercontent.com/ShaneBeee/RandomTP/master/version"
set {_t} to last http response
set {_j} to {_t}'s body
set {_v::*} to {_j} split at "|"
if "{@version}" is not equal to "%{_v::2}%":
send "&7[&a&lRandomTP&7] - &2Running version: {@version}" to player
send "&7[&a&lRandomTP&7] - &cUpdate available, version: %{_v::2}%" to player
function rtp(p: player, s: boolean = false, c: number = 0):
set {_x} to random integer between {rtp::distance::minx} and "-%{rtp::distance::minx}%" parsed as number
set {_z} to random integer between {rtp::distance::minz} and "-%{rtp::distance::minz}%" parsed as number
set {_y} to 60
set {_loc} to location {_x}, {_y}, {_z} in world of {_p}
loop 100 times:
add 1 to {_y}
if {rtp::times::safetycheck} = true:
wait 1 tick
set {_loc} to location {_x}, {_y}, {_z} in world of {_p}
if block at location of {_loc} is air:
if block below block at location of {_loc} is not stationary water or air or lily pad:
if {rtp::times::safetycheck} = true:
send "%{rtp::msgoptions::prefix}% &aSAFE CHUNK &7- %{rtp::msgoptions::color}%Telporting now" to {_p}
wait 1 second
teleport {_p} to {_loc}
if {_s} = false:
if {_c} is 0:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You were teleported to &b%{_loc}%" to {_p}
else:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You were teleported to &b%{_loc}% %{rtp::msgoptions::color}%Cost: &b$%{_c}%" to {_p}
stop
if {rtp::times::safetycheck} = true:
send "%{rtp::msgoptions::prefix}% &cUNSAFE CHUNK &7- %{rtp::msgoptions::color}%Searching for a new chunk" to {_p}
wait 1 second
rtp({_p}, {_s})
command /rtp [<text>]:
aliases: wild, randomtp
trigger:
if arg-1 is not set:
if sender is a player:
if player has permission "rtp.use":
if {rtp::cooldown::%player%} is not set:
if {rtp::delay::%player%} is not set:
if sender does not have permission "rtp.delay.bypass":
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You will be randomly teleported in &b%{rtp::times::delay}%"
set {rtp::delay::%player%} to true
wait 5 ticks
set {_x} to x coord of player
set {_z} to z coord of player
wait {rtp::times::delay} parsed as timespan
delete {rtp::delay::%player%}
if {_x} is not x coord of player:
send "%{rtp::msgoptions::prefix}% - &cYou moved, stand still and try again"
stop
if {_z} is not z coord of player:
send "%{rtp::msgoptions::prefix}% - &cYou moved, stand still and try again"
stop
if {rtp::cost} is not 0:
if balance of player >= {rtp::cost}:
remove {rtp::cost} from balance of player
rtp(player, false, {rtp::cost})
if player does not have permission "rtp.cooldown.bypass":
set {rtp::cooldown::%player%} to now
wait {rtp::times::cooldown} parsed as timespan
delete {rtp::cooldown::%player%}
else:
send "%{rtp::msgoptions::prefix}% - &cYou do not have enough money for this teleport, %{rtp::msgoptions::color}%teleports cost &b$%{rtp::cost}%"
else:
rtp(player, false)
if player does not have permission "rtp.cooldown.bypass":
set {rtp::cooldown::%player%} to now
wait {rtp::times::cooldown} parsed as timespan
delete {rtp::cooldown::%player%}
else:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You are already being teleported"
else:
set {_dif1} to difference between {rtp::cooldown::%player%} and now
set {_dif2} to difference between {_dif1} and {rtp::times::cooldown} parsed as timespan
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You last teleported &b%{_dif1}% %{rtp::msgoptions::color}%ago, please wait &b%{_dif2}%"
else:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::permmsg}%"
else:
execute console command "rtp help"
if arg-1 is set:
if arg-1 is "help":
set {_msg} to {rtp::msgoptions::color}
send " "
send "&7---- &bRandomTP Help &7----"
send ""
send "&dALIASES&7: &b/wild&7, &b/randomtp"
if {rtp::cost} > 0:
send "&dCOST&7: &b$%{rtp::cost}%"
send "&b/rtp &7- %{_msg}%Randomly teleport yourself somewhere" to sender
send "&b/rtp <player>&7- %{_msg}%Randomly teleports another player somewhere" to sender
send "&b/rtp help &7- %{_msg}%Shows this menu" to sender
send "&b/rtp reload &7- %{_msg}%Reloads the config file (Use this after making changes to the config)" to sender
send "&b/rtp version &7- %{_msg}%Shows the current version and update if one is available"
else if arg-1 is "reload":
if sender has permission "rtp.admin":
load yaml "plugins/RandomTP/config.yml" as "config"
set {rtp::msgoptions::color} to yaml value "Message Options.color" from "config"
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%Reloading config" to sender
if yaml path "Distance" in "config" does not have value:
set yaml value "Distance.min-x" from "config" to "5000"
set yaml value "Distance.min-z" from "config" to "5000"
set the comments of yaml node "Distance" from "config" to "Maximum x and z coords for random teleports, from center of world in either direction (use a positive number)"
if yaml path "Message Options" in "config" does not have value:
set yaml value "Message Options.prefix" from "config" to "&7[&a&lRTP&7]"
set yaml value "Message Options.color" from "config" to "&6"
set yaml value "Message Options.permission message" from "config" to "&cYou do not have permission to use this command"
set the comments of yaml node "Message Options" from "config" to "Prefix and color for chat messages and permission message"
if yaml path "Times" in "config" does not have value:
set yaml value "Times.delay" from "config" to "2 seconds"
set yaml value "Times.cooldown" from "config" to "60 seconds"
set yaml value "Times.safetycheck" from "config" to "false"
set the comments of yaml node "Times" from "config" to "Cooldown and Delay times" and "Safety Check = Will send messages to players, telling them whether" and "or not the chunk is safe with a slight delay"
if yaml path "Cost" in "config" does not have value:
set yaml value "Cost" from "config" to "0"
set the comments of yaml node "Cost" from "config" to "Cost for random teleports"
if yaml path "version" in "config" does not have value:
set the header of "config" to "Config options for RandomTP" and "Created by: ShaneBee" and "" and "Change the following options to suit the needs of your server"
set yaml value "version" from "config" to "{@version}"
set the comments of yaml node "version" from "config" to "Do NOT change the version number"
set yaml value "version" from "config" to "{@version}"
set {rtp::version} to yaml value "version" from "config"
set {rtp::distance::minx} to yaml value "Distance.min-x" from "config"
set {rtp::distance::minz} to yaml value "Distance.min-z" from "config"
set {rtp::msgoptions::prefix} to yaml value "Message Options.prefix" from "config"
set {rtp::msgoptions::permmsg} to yaml value "Message Options.permission message" from "config"
set {rtp::times::delay} to yaml value "Times.delay" from "config" parsed as timespan
set {rtp::times::cooldown} to yaml value "Times.cooldown" from "config" parsed as timespan
set {rtp::times::safetycheck} to yaml value "Times.safetycheck" from "config"
set {rtp::cost} to yaml value "Cost" from "config"
save yaml "config"
unload yaml "config"
wait 1 second
send "%{rtp::msgoptions::prefix}% - &aConfig reloaded" to sender
else:
send "%{rtp::msgoptions::prefix}% %{rtp::msgoptions::permmsg}%"
else if arg-1 is "version":
if player has permission "rtp.admin":
send a "GET" request to "https://raw.githubusercontent.com/ShaneBeee/RandomTP/master/version"
set {_t} to last http response
set {_j} to {_t}'s body
set {_v::*} to {_j} split at "|"
if "{@version}" is not equal to "%{_v::2}%":
send "&7[&a&lRandomTP&7] - &cRunning version: {@version}" to player
send "&7[&a&lRandomTP&7] - &2Update available, version: %{_v::2}%" to player
else:
send "&7[&a&lRandomTP&7] - &2Running latest version: {@version}" to player
else:
if sender has permission "rtp.admin":
set {_p} to arg-1 parsed as player
if {_p} is online:
rtp({_p}, true)
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You teleported &b%arg-1% %{rtp::msgoptions::color}%to a random location" to player
if sender is a player:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You are being teleported to a random location by &b%player%" to arg-1 parsed as player
if sender is console:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::color}%You are being teleported to a random location by &bconsole" to arg-1 parsed as player
else:
send "%{rtp::msgoptions::prefix}% - &cInvalid argument ... %{rtp::msgoptions::color}%use &b/rtp <help/version/reload> %{rtp::msgoptions::color}%or &b/rtp <player>" to sender
else:
send "%{rtp::msgoptions::prefix}% - %{rtp::msgoptions::permmsg}%"