commandbinder.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:
	#
	# Permission to use pressure plate or block-binded commands.
	# Give yourself or staff "commandbinder.superuser" permission to use Administrative commands.
	cmdpermission: commandbinder.use
	#
	# Indication beam
	# Which particles should we display when using /listbinds?
	# Particles help you visualise exactly where binded commands reside.
	indicationbeam: dust
	
command /tpcmd [<text>]:
	permission: {@cmdpermission}
	permission message: &cNo permission!
	trigger:
		if player has permission "commandbinder.superuser":
			if arg-1 is set:
				set {_int} to arg-1 parsed as integer
				loop {cmdbind-exactlocation::*}:
					add 1 to {_amount}
				if {_int} > {_amount}:
					send "&cYou only have %{_amount}%&c commands registered!" to player
				else:
					loop {cmdbind-exactlocation::*}:
						add 1 to {_i}
						if {_int} = {_i}:
							teleport player at block above loop-value
							exit loop
			else:
				send "&c&lCorrect usage: &c/tpcmd <command number>" to player
				send "&r" to player
				send "&cType /listbinds to list available commands." to player
		else:
			send "&cNo permission!" to player
	
command /listbinds:
	permission: {@cmdpermission}
	permission message: &cNo permission!
	aliases: /listbind, /bindslist, /bindlist, /commandbinder, /cmdbinder, /binder
	trigger:
		if player has permission "commandbinder.superuser":
			loop {cmdbind-location::*}:
				add 1 to {_i}
				set {_cmdbind.location.%{_i}%} to loop-value
			set {_i} to 0
			loop {cmdbind-command::*}:
				add 1 to {_i}
				set {_cmdbind.command.%{_i}%} to loop-value
			if {_i} >= 1:
				send "&d &m                            &r" to player
				send "&dList of binded commands" to player
				send "&d &m                            &r" to player
				send "&eUse /tpcmd <number> to teleport to command's location" to player
				loop {_i} times:
					add 1 to {_order}
					if {_cmdbind.command.%{_order}%} contains "**":
						replace all "**" in {_cmdbind.command.%{_order}%} with ""
						send "&8(%{_order}%&8) &f%{_cmdbind.location.%{_order}%}% &a%{_cmdbind.command.%{_order}%}% &e(Console command)" to player
					else:
						send "&8(%{_order}%&8) &f%{_cmdbind.location.%{_order}%}% &a%{_cmdbind.command.%{_order}%}%" to player
				loop 20 times:
					loop {cmdbind-exactlocation::*}:
						set {_i} to 0
						loop all blocks above block at loop-value-2:
							add 1 to {_i}
							if {_i} <= 10:
								play 1 ({@indicationbeam} with speed 0) at loop-block
					wait 5 ticks
			else:
				send "&cNo commands exist yet! Bind some using /bind [command]" to player
		else:
			send "&cNo permission!" to player

command /bind [<text>]:
	permission: {@cmdpermission}
	permission message: &cNo permission!
	trigger:
		if player has permission "commandbinder.superuser":
			if arg-1 is set:
				if targeted block is set:
					if {cmdbind-exactlocation::*} does not contain targeted block:
						add targeted block's location to {cmdbind-location::*}
						add targeted block to {cmdbind-exactlocation::*}
						add arg-1 to {cmdbind-command::*}
						if targeted block is any pressure plate:
							send "&aBinded %arg-1%&a to block at %targeted block's location%&a! &l(pressure plate trigger)" to player
							if arg-1 contains "**":
								send "&aThis command will be ran through console." to player
						else:
							send "&aBinded %arg-1%&a to block at %targeted block's location%&a! &l(right click trigger)" to player
							if arg-1 contains "**":
								send "&aThis command will be ran through console." to player
					else:
						loop {cmdbind-exactlocation::*}:
							add 1 to {_i}
							if targeted block is loop-value:
								remove loop-value from {cmdbind-exactlocation::*}
								exit loop
						add targeted block to {cmdbind-exactlocation::*}
						loop {cmdbind-location::*}:
							add 1 to {_count}
							if {_count} = {_i}:
								remove loop-value from {cmdbind-location::*}
								exit loop
						add targeted block's location to {cmdbind-location::*}
						set {_count} to 0
						loop {cmdbind-command::*}:
							add 1 to {_count}
							if {_count} = {_i}:
								remove loop-value from {cmdbind-command::*}
								send "&aA command is already registered to this block which was now replaced (%loop-value%&a -> %arg-1%&a)" to player
								if arg-1 contains "**":
									send "&aThis command will be ran through console." to player
								exit loop
						add arg-1 to {cmdbind-command::*}
					loop 20 times:
						play 1 ({@indicationbeam} with speed 0) above targeted block
						wait 1 tick
			else:
				send "&c&lPlease specify a command to bind." to player
				send "&r" to player
				send "&c&lExample: &c/bind /wilderness" to player
		else:
			send "&cNo permission!" to player
					
command /unbind [<text>]:
	permission: {@cmdpermission}
	permission message: &cNo permission!
	trigger:
		if player has permission "commandbinder.superuser":
			if arg-1 is set:
				set {_int} to arg-1 parsed as integer
				loop {cmdbind-exactlocation::*}:
					add 1 to {_amount}
				if {_amount} exists:
					if {_int} > {_amount}:
						send "&cYou only have %{_amount}%&c commands registered!"
					else:
						set {_i} to 0
						loop {cmdbind-exactlocation::*}:
							add 1 to {_i}
							if {_int} = {_i}:
								remove loop-value from {cmdbind-exactlocation::*}
								exit loop
						set {_i} to 0
						loop {cmdbind-location::*}:
							add 1 to {_i}
							if {_int} = {_i}:
								set {_oldlocation} to loop-value
								remove loop-value from {cmdbind-location::*}
								exit loop
						set {_i} to 0
						loop {cmdbind-command::*}:
							add 1 to {_i}
							if {_int} = {_i}:
								set {_oldcommand} to loop-value
								remove loop-value from {cmdbind-command::*}
								exit loop
						send "&aCommand number %arg-1%&a removed (%{_oldcommand}%&a) at location %{_oldlocation}%&a." to player
				else:
					send "&cNo commands exist yet! Bind some using /bind [command]" to player
			else:
				loop {cmdbind-exactlocation::*}:
					add 1 to {_i}
					if loop-value is targeted block:
						execute player command "/unbind %{_i}%"
						exit loop
				send "&cNo commands to unbind at target block. You can use /unbind <number> to unbind a specific command from the list (/listbinds)" to player
		else:
			send "&cNo permission!" to player
				
on right click:
	if targeted block is set:
		loop {cmdbind-exactlocation::*}:
			add 1 to {_i}
			if targeted block is loop-value:
				if targeted block is not any pressure plate:
					if player has permission "{@cmdpermission}":
						cancel event
						loop {cmdbind-command::*}:
							add 1 to {_count}
							if {_count} = {_i}:
								if loop-value-2 contains "**":
									set {_console} to loop-value-2
									replace all "**" in {_console} with ""
									execute console command "%{_console}%"
								else:
									execute player command "%loop-value-2%"
					else:
						send "&cYou don't have permission ({@cmdpermission}) to use binded commands."
						
on step on pressure plate:
	loop {cmdbind-exactlocation::*}:
		add 1 to {_i}
		if event-block is loop-value:
			if {pressureplate-cooldown.%player%} doesn't exist:
				if player has permission "{@cmdpermission}":
					cancel event
					add 10 to {pressureplate-cooldown.%player%}
					loop {cmdbind-command::*}:
						add 1 to {_count}
						if {_count} = {_i}:
							if loop-value-2 contains "**":
								set {_console} to loop-value-2
								replace all "**" in {_console} with ""
								execute console command "%{_console}%"
							else:
								execute player command "%loop-value-2%"
							set {pressureplate-cooldown.%player%} to true
							wait 1 second
							delete {pressureplate-cooldown.%player%}
				else:
					send "&cYou don't have permission ({@cmdpermission}) to use binded commands."