randomtp.sk

Created by Sombrerian

Other available versions. Ordered by newest to oldest versions:

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.

options:
	#
	# Which world should players randomly teleport in?
	# World you specify here is the world players get randomly teleported in, no matter
	# which world they reside in at the time of command execution (including nether, end...)
	world: world
	#
	# Minimum X & Z coordinates.
	# Do not set this value higher than your world border, it will cause issues.
	# Type "/worldborder get" to see your world border size.
	minimumxz: -1000
	#
	# Maximum X & Z coordinates.
	# Do not set this value higher than your world border, it will cause issues.
	# Type "/worldborder get" to see your world border size.
	maximumxz: 1000
	#
	# Specify blocks to avoid from being dropped on. It is highly recommended to not
	# remove default values, unless you want players drowning in lava.
	# Valid blocks that can be blacklisted: https://github.com/SkriptLang/skript-aliases/blob/master/building.sk
	blockblacklist: lava or water or cactus or bamboo or stone or any leaves
	#
	# How many times should we attempt to randomly teleport a player before giving up?
	# This depends on regioncheck and blacklisted blocks. For example, if first location attempt
	# is lava (assuming lava is under "blockblacklist"), then we increase attempt amount by 1 and try
	# to find a new location for the player. Recommended and probably the most appropriate value is 20.
	maxattempts: 20
	#
	# How long should the delay (in ticks) between teleportation attempts be?
	# Lower value means faster teleportation attempts, but possible lag.
	# It is recommended to keep this set to 5 (meaning max 4 attempts per second)
	# 20 ticks = 1 second
	attemptdelay: 5
	#
	# Should we enabled region check? Having this enabled will prevent players from getting dropped
	# onto regions/claims (supports WorldGuard, GriefPrevention & other land claiming plugins...)
	# Valid switches: true/false
	regioncheck: true
	#
	# Warmup message
	# Let players know that they are getting randomly teleported.
	# -
	# Set to "none" to disable this feature.
	warmupmessage: "&aHang tight... Looking for a safe spot!"
	#
	# Drop-off message
	# Let players know that they were successfully randomly teleported.
	# -
	# Set to "none" to disable this feature.
	dropoffmessage: "&aYou have been dropped off at %location at player%"
	#
	# Console Post-TP command
	# This command gets executed by console 1 second after a player gets randomly teleported.
	# Use %player% if you want to run a command specifically with that player's name. For example,
	# if a player by the name of "Bob" randomly telepots while Post-TP command is set to
	# "/kick %player%", then Bob gets kicked.
	# -
	# Set to "none" to disable this feature.
	posttpcommand: "none"
	#
	# Dedicated command
	# Just in case you don't want players constantly typing /randomtp.
	# This can be set to any non-existent command.
	dedicatedcommand: /play
	#
	# Command cooldown (in seconds)
	# Set this to 0 for no cooldown.
	rtpcooldown: 120
	#
	# Decreased command cooldown (in seconds)
	# Possible donator perk? Players with permission "randomtp.decreasedcooldown" will be
	# cooled down for amount of seconds specified here, instead of regular "rtpcooldown".
	# Set this to 0 for no cooldown.
	rtpdecreasedcooldown: 20
	#
	# Cooldown message.
	# Players will be presented with this message when they try to randomly teleport while on cooldown.
	# Only works if cooldowns are enabled.
	# %{rtpcooldown.%player%}% is the placeholder to show remaining seconds.
	cooldownmessage: "&cYou are on cooldown, %{rtpcooldown.%player%}%&c seconds remain!"
	#
	# Particle mode
	# Particles are summoned at player's location once successfully randomly teleported.
	# Valid switches: none, ball, splash
	# -
	# "none": Disable particles
	# "ball": Particles summoned in a 'ball'-a-like shape
	# "splash": Particles summoned beneath the player
	particlesmode: "ball"
	#
	# Particle effect radius
	# Only applies if you have particles are enabled!
	particleradius: 2
	#
	# Particle type
	# List of valid particles: https://www.digminecraft.com/lists/particle_list_pc.php
	# -
	# Make sure to exclude underscores! For example, if you are setting your particle to
	# enchanted_hit, remove _, having the final value set as: enchanted hit
	particlestype: happy villager
	#
	# Sound effect
	# List of valid sounds: https://www.digminecraft.com/lists/sound_list_pc.php
	# -
	# Set to "none" to disable this feature.
	# -
	# Make sure to reaplce all dots with underscores! For example, if you are setting your sound effect
	# to "BLOCK.BEEHIVE.SHEAR", replace all . with _, having the final value set as: "BLOCK_BEEHIVE_SHEAR"
	soundeffect: "ENTITY_ENDER_DRAGON_SHOOT"
	#
	# Permission to use /randomtp (and alias) command.
	cmdpermission: randomtp.use
	#
	# Should we enable debug mode?
	# This will play unnecessary, but useful chat messages to the player.
	# Valid switches: true/false
	debug: false
	
command /randomtp:
	permission: {@cmdpermission}
	permission message: &cNo permission!
	aliases: /rtp, /wild, /wilderness
	trigger:
		if {rtpcooldown.%player%} exists:
			send {@cooldownmessage} to player
			stop
		if {@warmupmessage} is not "none":
			send {@warmupmessage} to player
		if {@debug} is true:
			send "&7&oMaximum location search attempts: {@maxattempts}" to player
		loop {@maxattempts} times:
			if {@debug} is true:
				send "&7&oDelaying location search attempt for: {@attemptdelay}&7&o ticks..." to player
			wait {@attemptdelay} ticks
			set {_x} to random integer from {@minimumxz} to {@maximumxz}
			set {_y} to 50 # In order to avoid most caves
			set {_z} to random integer from {@minimumxz} to {@maximumxz}
			set {_location} to location at ({_x}, {_y}, {_z}) in world "{@world}"
			set {_block} to block at {_location}
			loop all blocks above {_block}:
				if loop-block is air:
					if block under loop-block is {@blockblacklist}:
						if {@debug} is true:
							send "&7&oFailed random teleportation attempt (blacklisted block: %block under loop-block%&7&o). Retrying..." to player
						exit loop
					if {@regioncheck} is true:
						if region at loop-block is set:
							if {@debug} is true:
								send "&7&oFailed random teleportation attempt (region is set). Retrying..." to player
							exit loop
					add 1 to {_i}
					if {_i} >= 2:
						teleport player at loop-block
						if player has permission "randomtp.decreasedcooldown":
							add {@rtpdecreasedcooldown} to {rtpcooldown.%player%}
						else:
							add {@rtpcooldown} to {rtpcooldown.%player%}
						if {@dropoffmessage} is not "none":
							send {@dropoffmessage} to player
						if {@soundeffect} is not "none":
							play sound {@soundeffect} with volume 100 and pitch 1 at player for player
						if {@particlesmode} is not "none":
							wait 10 ticks
							if {@particlesmode} is "ball":
								loop all blocks in radius {@particleradius} around player:
									play 1 ({@particlestype} with speed 0) at block at loop-block-2
							else if {@particlesmode} is "splash":
								set {_y} to loop-block's y coordinate
								remove 1 from {_y}
								loop all blocks in radius {@particleradius} around player:
									if loop-block-2's y coordinate is {_y}:
										play 1 ({@particlestype} with speed 0) at block at loop-block-2
						if {@posttpcommand} is not "none":
							wait 1 second
							execute console command {@posttpcommand}
						stop
							
command {@dedicatedcommand}:
	permission: {@cmdpermission}
	permission message: &cNo permission!
	trigger:
		execute player command "/randomtp"
							
every 1 second:
	loop all players:
		if {rtpcooldown.%loop-player%} exists:
			if {rtpcooldown.%loop-player%} <= 1:
				delete {rtpcooldown.%loop-player%}
			else:
				remove 1 from {rtpcooldown.%loop-player%}
				
on quit:
	delete {rtpcooldown.%player%}