blocksounds.sk

Created by AsuDev

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.


#   	___ _            _      __                       _     
#	  / __\ | ___   ___| | __ / _\ ___  _   _ _ __   __| |___ 
#	 /__\// |/ _ \ / __| |/ / \ \ / _ \| | | | '_ \ / _` / __|
#	/ \/  \ | (_) | (__|   <  _\ \ (_) | |_| | | | | (_| \__ \
#	\_____/_|\___/ \___|_|\_\ \__/\___/ \__,_|_| |_|\__,_|___/
#                                                          

# Made by AsuDev (Revelationage)
# Date: 5/21/19

# Dependencies
	# Skript 2.3.6 (Not tested on 1.14.1)
	# Skript-Mirror

# Notes
	# There are no configurations for this script.
	# Feel free to edit this as you please.

# ########################################################################################################

function playSoundLocation(loc: text, sound: text):
	set {_soundplay} to {soundlocations.%{_sound}%.Sound}
	set {_volume} to {soundlocations.%{_sound}%.Volume}	
	set {_pitch} to {soundlocations.%{_sound}%.Pitch}	
	set {_seconds} to {soundlocations.%{_sound}%.Seconds}
	replace all " " with "" in {_loc}
	set {_coords::*} to {_loc} split by ","
	set {_x} to {_coords::1}
	replace all "x:" with "" in {_x}
	set {_x} to {_x} parsed as number
	set {_y} to {_coords::2}
	replace all "y:" with "" in {_y}
	set {_y} to {_y} parsed as number	
	set {_z} to {_coords::3}
	replace all "z:" with "" in {_z}
	set {_z} to {_z} parsed as number	
	set {_world} to {_coords::4}
	set {_loc} to location at {_x}, {_y}, and {_z} in world "%{_world}%"
	while {_infiniteloop} is not set:
		if {haltsounds} is set:
			exit 1 loop
		loop all players:
			loop-player.playSound({_loc}, "%{_soundplay}%", {_volume}, {_pitch})
		loop {_seconds} times:
			if {haltsounds} is set:
				exit 2 loops
			wait 1 second

function refreshSounds():
	set {haltsounds} to true
	loop all players:
		if "%world of loop-player%" does not contain "Instance_":
			execute command "stopsound %loop-player%"
	wait 1.5 seconds
	delete {haltsounds}
	loop {soundlocations.locations::*}:
		set {_sounds::*} to {%loop-value%.Sounds::*}
		loop {_sounds::*}:
			playSoundLocation(loop-value-1, loop-value-2)	

on script load:
	refreshSounds()

command /addsound [<text>] [<text>] [<number>] [<number>] [<integer>]:
	usage: /addsound <name> <sound> <volume> <pitch> <seconds>
	permission: sounds
	permission message: &cYou do not have permission to use this command.
	trigger:
		if arg 1 is not set:
			message "&cCorrect usage: &7/addsound <name> <sound> <volume> <pitch> <seconds>"
			stop
		if arg 2 and arg 3 and arg 4 and arg 5 is set:
			loop {soundlocations::*}:
				if "%loop-value%" is arg 1:
					message "&cA sound with that name already exists."
					stop
			add arg 1 to {soundlocations::*}
			set {soundlocations.%arg 1%.Sound} to arg 2
			set {soundlocations.%arg 1%.Volume} to arg 3
			set {soundlocations.%arg 1%.Pitch} to arg 4
			set {soundlocations.%arg 1%.Seconds} to arg 5
			message "&7You created a new sound with ID &a%arg 1%&7."
		else:
			message "&cCorrect usage: &7/addsound <name> <sound> <volume> <pitch> <seconds>"

command /removesound [<text>]:
	usage: /removesound <name>
	permission: sounds
	permission message: &cYou do not have permission to use this command.
	trigger:
		if arg 1 is not set:
			message "&cCorrect usage: &7/removesound <name>"
			stop
		loop {soundlocations::*}:
			if "%loop-value%" is arg 1:
				remove loop-value from {soundlocations::*}
				message "&7You deleted the &c%loop-value% &7sound."
				loop {soundlocations.locations::*}:
					loop {%loop-value-2%.Sounds::*}:
						if "%loop-value-3%" is arg 1:
							remove loop-value-3 from {%loop-value-2%.Sounds::*}
							if size of {%loop-value-2%.Sounds::*} is 0:
								remove loop-value-2 from {soundlocations.locations::*}
								delete {%loop-value-2%.Sounds::*}
				refreshSounds()
				stop
		message "&cThere is no sound ID with that name."

command /sounds:
	permission: sounds
	permission message: &cYou do not have permission to use this command.
	trigger:
		if size of {soundlocations::*} is 0:
			message "&aSounds: &7None."
		else:
			set {_final} to ""
			loop {soundlocations::*}:
				if loop-index is not "%size of {soundlocations::*}%":
					set {_final} to "%{_final}%<tooltip:&6%loop-value%%nl%&7Sound: &e%{soundlocations.%loop-value%.Sound}%%nl%&7Volume: &e%{soundlocations.%loop-value%.Volume}%%nl%&7Pitch: &e%{soundlocations.%loop-value%.Pitch}%%nl%&7Seconds: &e%{soundlocations.%loop-value%.Seconds}%>&7%loop-value%&7,&r "
				else:
					set {_final} to "%{_final}%<tooltip:&6%loop-value%%nl%&7Sound: &e%{soundlocations.%loop-value%.Sound}%%nl%&7Volume: &e%{soundlocations.%loop-value%.Volume}%%nl%&7Pitch: &e%{soundlocations.%loop-value%.Pitch}%%nl%&7Seconds: &e%{soundlocations.%loop-value%.Seconds}%>&7%loop-value%"
			message "&aSounds: &7%{_final}%"

command /setsound [<text>]:
	usage: /setsound <name>
	permission: sounds
	permission message: &cYou do not have permission to use this command.
	trigger:
		if arg 1 is not set:
			message "&cCorrect usage: &7/setsound <name>"
			stop
		if player's targeted block is not set:
			message "&cYou must be looking at a block to use this command."
			stop
		loop {soundlocations::*}:
			if "%loop-value%" is arg 1:
				loop {soundlocations.locations::*}:	
					if "%location of player's targeted block%, %world of location of player's targeted block%" is "%loop-value-2%":
						set {_s} to "%location of player's targeted block%, %world of location of player's targeted block%"
						add arg 1 to {%{_s}%.Sounds::*}
						message "&aSound set successfully at targeted block."
						refreshSounds()
						stop
				add "%location of player's targeted block%, %world of location of player's targeted block%" to {soundlocations.locations::*}
				set {_s} to "%location of player's targeted block%, %world of location of player's targeted block%"
				add arg 1 to {%{_s}%.Sounds::*} 
				message "&aSound set successfully at targeted block."
				refreshSounds()
				stop
		message "&cThat sound does not exist."

command /getblocksounds:
	permission: sounds
	permission message: &cYou do not have permission to use this command.	
	trigger:
		set {_s} to "%location of player's targeted block%, %world of location of player's targeted block%"
		loop {soundlocations.locations::*}:
			if "%{_s}%" is "%loop-value%":
				message "&aSounds at Block: &7%{%{_s}%.Sounds::*}%"
				stop
		message "&cThere are no sounds playing at that block."

command /soundtp <text>:
	permission: sounds
	permission message: &cYou do not have permission to use this command.
	trigger:
		set {_loc} to arg 1
		replace all " " with "" in {_loc}
		set {_details::*} to {_loc} split by ","
		set {_x} to {_details::1}
		set {_y} to {_details::2}
		set {_z} to {_details::3}
		replace all "x:" with "" in {_x}
		replace all "y:" with "" in {_y}
		replace all "z:" with "" in {_z}
		set {_x} to {_x} parsed as number
		set {_y} to {_y} parsed as number
		add 1 to {_y}
		set {_z} to {_z} parsed as number
		set {_location} to location at {_x}, {_y}, {_z} in world "%{_details::4}%"
		teleport player to {_location}
		message "&7Sound block should be the block under you (unless you were teleported on air)."

command /blocksounds:
	permission: sounds
	permission message: &cYou do not have permission to use this command.	
	trigger:
		if size of {soundlocations.locations::*} is 0:
			message "&aBlock Sounds: &7None."
		else:
			set {_final} to ""
			loop {soundlocations.locations::*}:
				set {_loc} to "%loop-value%"
				if loop-index is not "%size of {soundlocations.locations::*}%":
					set {_final} to "%{_final}%<cmd:/soundtp %loop-value%><tooltip:&6%loop-value%%nl%&7Sounds: &e%{%{_loc}%.Sounds::*}%%nl%&7Click to teleport to this location.>&7%loop-value%&7,&r "
				else:
					set {_final} to "%{_final}%<cmd:/soundtp %loop-value%><tooltip:&6%loop-value%%nl%&7Sounds: &e%{%{_loc}%.Sounds::*}%%nl%&7Click to teleport to this location.>&7%loop-value%"
			message "&aSounds: &7%{_final}%"		

command /removeblocksound [<text>]:
	permission: sounds
	permission message: &cYou do not have permission to use this command.	
	trigger:
		if arg 1 is not set:
			message "&cCorrect usage: &7/removeblocksound <name>"
			stop
		if player's targeted block is not set:
			message "&cYou must be looking at a block to use this command."
			stop		
		set {_s} to "%location of player's targeted block%, %world of location of player's targeted block%"
		loop {soundlocations.locations::*}:
			if "%{_s}%" is "%loop-value%":
				loop {%{_s}%.Sounds::*}:
					if arg 1 is "%loop-value-2%":
						remove loop-value-2 from {%{_s}%.Sounds::*}
						message "&aSound successfully removed."
						refreshSounds()
						if size of {%{_s}%.Sounds::*} is 0:
							remove loop-value-1 from {soundlocations.locations::*}
							delete {%{_s}%.Sounds::*}
						stop
				message "&cThat sound is not playing at that block."
				stop
		message "&cThat block has no sounds playing at it."	

command /clearblocksounds:
	permission: sounds
	permission message: &cYou do not have permission to use this command.		
	trigger:
		if player's targeted block is not set:
			message "&cYou must be looking at a block to use this command."
			stop
		set {_s} to "%location of player's targeted block%, %world of location of player's targeted block%"
		loop {soundlocations.locations::*}:
			if "%{_s}%" is "%loop-value%":
				delete {%{_s}%.Sounds::*}
				refreshSounds()
				remove loop-value from {soundlocations.locations::*}
				message "&aSounds at targeted block have been cleared."
				stop
		message "&cThat block has no sounds playing at it."	

# ########################################################################################################