CommandSpy.sk

Created by Sitieno14

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.

#      ____                                          _ ____
#     / ___|___  _ __ ___  _ __ ___   __ _ _ __   __| / ___| _ __  _   _
#    | |   / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` \___ \| '_ \| | | |
#    | |__| (_) | | | | | | | | | | | (_| | | | | (_| |___) | |_) | |_| |
#     \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|____/| .__/ \__, |
#                                                           |_|    |___/
#CommandSpy (https://forums.skunity.com/resources/commandspy.1078/)
#============================================================================
#        Description: Be notified in-game of commands used by users
#             Author: Sitieno14
#            License: http://creativecommons.org/licenses/by-nc-sa/4.0/
#            Version: 2.0
#
#  SkUnity - Profile: https://tinyurl.com/skunity-sitieno14
#SkUnity - Resources: https://tinyurl.com/skunity-bysitieno14
#  SkUnity - Support: https://tinyurl.com/skunity-tositieno14
#
# Telegram - Channel: https://telegram.me/Sitieno14
# Telegram - Contact: https://telegram.me/Sitieno14_bot
#============================================================================
options:
	#-----------------------------------------------------------General Settings-----------------------------------------------------------#

	#Prefix for almost all messages sent by this skript
	prefix: &3Command&bSpy &9»
	
	#Format of notification about the commands executed by users for players with CommandSpy enabled
	format: &f%player% &7- &a%world% &7- /&6%full command%
	
	onquit-disablecommandspy: true #If this option is "true", CommandSpy will be disabled on quit
	#Leave it to true if you have an Auth Plugin, otherwise not logged players will be able to see other players' commands before logging in
	
	#Message to be sent to players who try to execute CommandSpy commands without having the required permissions [No {@prefix} by default]
	nopermission-error: Unknown command. Type ""/help"" for help.

	#------------------------------------------------Other Skripts Compatibility-------------------------------------------------#

	spyMSG: true #If this option is set to "false", it will not be granted to spy on private messages exchanged by users
	#You can use https://www.spigotmc.org/resources/msg.52824/ as MSG skript, it is compatible with this option

	hideVanishedPlayers: true #If this option isn't set to "true", this skript will not hide in-vanish players in his functions
	#You should use https://www.spigotmc.org/resources/vanish.52005/ to make sure this option works properly

	#----------------------------------------/commandspy & /commandspy <playername>-------------------------------------------------------#
	
	#Change this option if you don't want players to be able to toggle CommandSpy with the /commandspy command
	commandspy: true 
	
	#Error message to be sent to the console when trying to execute the /commandspy command (because it must be executable only by players)
	commandspy-error-console: &cYou can use this command only in-game, &8use &7/&fforcecommandspy &7instead 

	#---------------------------------------------/commandspy-----------------------------------------------#
	
	#Message to be sent to players who enable CommandSpy for themselves by executing the /commandspy command
	commandspy-self-enable: &7You &acan now &7see the commands other players will execute!
	
	#Message to be sent to players who disable CommandSpy for themselves by executing the /commandspy command
	commandspy-self-disable: &7You &ccan no longer &7see the commands other players will execute!
	
	#-------------------------------------------------/commandspy <playername>-------------------------------------------------#
	
	#Change this option if you don't want players to be able to toggle CommandSpy for others by using the /commandspy command
	commandspy-others: true

	#Message sent to players who enable Command Spy for another player with /commandspy command
	commandspy-others-enable: &f%arg 1% &acan now &7see the commands other players will execute!

	#Message sent to players who disable Command Spy for another player with /commandspy command
	commandspy-others-disable: &f%arg 1% &ccan no longer &7see the commands other players will execute!

	#Message sent to players who get Command Spy enabled from /commandspy commands
	commandspy-others-enabled: &7Thanks of &f%player%&7, you &acan now &7see the commands other players will execute!
	
	#Message sent to players who get Command Spy disabled from /commandspy commands
	commandspy-others-disabled: &7You &ccan no longer &7see the commands other players will execute! 
	
	#Message to send when players try to enable/disable Command Spy with /commandspy commands for a non online/inexistent player
	commandspy-error-404: &cNo online players called '&n%arg 1%&c'

	#---------------------------------------------------------------------/forcecommandspy---------------------------------------------------------------------#

	#Change this option if you want to disable the console's /forcecommandspy command
	forcecommandspy: true

	#The confirm message the console receives from enabling CommandSpy for a player with /forcecommandspy commands
	forcecommandspy-console-enable: &f%arg 1% &acan now &7see the commands other players will execute!

	#The confirm message the console receives from disabling CommandSpy for a player with /forcecommandspy commands
	forcecommandspy-console-disable: &f%arg 1% &ccan no longer &7see the commands other players will execute!

	#Message to be sent to players who get CommandSpy enabled by console through the /forcecommandspy command
	forcecommandspy-player-enabled: &7Thanks of &8console&7, you &acan now &7see the commands other players will execute!
	
	#Message to be sent to players who get CommandSpy disabled by console through the /forcecommandspy command
	forcecommandspy-player-disabled: &7You &ccan no longer &7see the commands other players will execute!
	
	#Error message to be sent to players who try to run the /forcecommandspy command because it must be executable only by console)
	forcecommandspy-error-player: Unknown command. Type ""/help"" for help.

	#Usage message to be sent to the console when a player is not specified as an argument for the /forcecomandspy command
	forcecommandspy-error-usage: &8Usage: &7/&fforcecommandspy &c<player>

	#Error message to be sent to console when specifying an offline or non-existent player for the /forcecommandspy command
	forcecommandspy-error-404: &cNo online players called '&n%arg 1%&c'

	#------------------------------/commandspylist-------------------------------#

	#Change this option if you want to disable the /commandspylist command
	commandspylist: true
	
	#First line that will be sent after the /commmandspylist command execution
	commandspylist-format-1:&7Players with &3Command&bSpy &aenabled &8↓

	#One line for each player (Placeholder: %loop-player%) with CommandSpy enabled
	commandspylist-format-2: &8- &f%loop-player%

           #__________________________________#
           #||        Skript - Code         ||#
           #\/ ---------------------------- \/#       
    #\!/ Edit only if you know what you are doing \!/#

#this command can be disabled by changing the "commandspy" option
command /commandspy <offline player=%player%>:
	description: Toggle CommandSpy
	executable by: players and console
	trigger:
		if {@commandspy} is true:
			if executor isn't a player:
				if {@forcecommandspy} is true:
					send "{@prefix} {@commandspy-error-console}"
					stop

			if arg 1 is player:
				if player has the permission "commandspy.*" or "commandspy.toggle.*" or "commandspy.toggle" or "commandspy.toggle.others":
					if {commandspy::%player%} is true:
						send "{@prefix} {@commandspy-self-disable}" to player
						delete {commandspy::%player%}

					else:
						send "{@prefix} {@commandspy-self-enable}" to player
						set {commandspy::%player%} to true
					stop

			else if player has the permission "commandspy.*" or "commandspy.toggle.*" or "commandspy.toggle.others":
				if {@hideVanishedPlayers} is true:
					if {vanish::%arg 1%} is true:
						send "{@prefix} {@commandspy-error-404}" to player
						stop

				if arg 1 is online:
					if {commandspy::%arg 1%} is true:
						send "{@prefix} {@commandspy-others-disabled}" to arg 1
						send "{@prefix} {@commandspy-others-disable}" to player
						delete {commandspy::%arg 1%}

					else:
						send "{@prefix} {@commandspy-others-enabled}" to arg 1
						send "{@prefix} {@commandspy-others-enable}" to player
						set {commandspy::%arg 1%} to true
					stop
	
				send "{@prefix} {@commandspy-error-404}" to player
				stop

			send "{@nopermission-error}"

#this command can be disabled by changing the "forcecommandspy" option
command /forcecommandspy [<offline player>]:
	description: Toggle CommandSpy to players from console
	trigger:
		if {@forcecommandspy} is true:
			if executor is a player:
				send "{@forcecommandspy-error-player}"
				stop

			if arg 1 isn't set:
				send "{@forcecommandspy-error-usage}"
				stop

			if arg 1 is online:
				if {commandspy::%arg 1%} is true:
					send "{@prefix} {@forcecommandspy-player-disabled}" to arg 1
					send "{@prefix} {@forcecommandspy-console-disable}"
					delete {commandspy::%arg 1%}

				else:
					send "{@prefix} {@forcecommandspy-player-enabled}" to arg 1
					send "{@prefix} {@forcecommandspy-console-enable}"
					set {commandspy::%arg 1%} to true

				stop

			send "{@prefix} {@forcecommandspy-error-404}"

#this command can be disabled by changing the "commandspylist" option
command /commandspylist:
	description: Prints a list of players with CommandSpy enabled
	trigger:
		if {@commandspylist} is true:
			if player has the permission "commandspy.list" or "commandspy.*":
				send "{@prefix} {@commandspylist-format-1}"
				loop all players:
					if {commandspy::%loop-player%} is true:
						send "{@commandspylist-format-2}" to player
				stop
			
			send "{@nopermission-error}"

#command listener to notify players with CommandSpy enabled of commands executed by players
on command:
	executor is a player
	player doesn't have the permission "commandspy.*" or "commandspy.bypass"
	command is not "login", "register", "l", "log", "changepw" or "changepassword"

	if {@spyMSG} is false:
		if command is "msg", "tell", "reply", "r", "whisper", "pm" or "answer":
			stop
	if {@hideVanishedPlayers} is true:
		if {vanish::%player%} is true:
			stop

	loop all players:
		if {commandspy::%loop-player%} is true:
			if loop-player isn't player:
				send "{@prefix} {@format}" to loop-player

#these two events can be disabled by changing the "onquit-disablecommandspy" option
on join:
	if {@onquit-disablecommandspy} is true:
		if {commandspy::%player%} is true:
			delete {commandspy::%player%}
on quit:
	if {@onquit-disablecommandspy} is true:
		if {commandspy::%player%} is true:
			delete {commandspy::%player%}