MatchIt.sk

Created by LimeGlass

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.


# Matchit by LimeGlass

command /matchit <string = medium>:
	permission: matchit.use
	usage: /matchit <string = easy, medium, hard or highscores to view highscores>
	trigger:
		if argument is "highscores", "highscore" or "hs":
			set {_uuid} to uuid of player
			if {matchit::%{_uuid}%::highscores::*} is not set:
				message "&7[&6MatchIt&7] &cYou have no highscores set."
				stop
			set {_spot} to 1
			# Sorted Difficulty from hardest to easiest.
			loop "easy", "medium" and "hard":
				loop {matchit::%{_uuid}%::highscores::%loop-value%::*}:
					# because Skript toVariableName for timeperiods is dumb.
					set {_date} to loop-index
					replace "object:" with "" in {_date}
					message "&f##&l%{_spot}% - &7Difficulty: &f%loop-value-1%&7, Time: &f%loop-value-2%&7, Date: &f%{_date}%"
			stop
		else if argument is "easy":
			set {_size} to 2
		else if argument is "medium":
			set {_size} to 4
		else if argument is "hard":
			set {_size} to 6
		else:
			message "&7[&6MatchIt&7] &c%argument% is not a difficulty, defaulting to medium."
			set {_size} to 4
		set {_inventory} to a chest inventory with {_size} rows named "             &4&lMatch it"
		set {matchit::temp::%player%::inventory} to {_inventory}
		set {matchit::temp::%player%::start} to now
		add slime ball to {_items::*}
		while size of {_items::*} is not ({_size} * 9) / 2:
			set {_item} to random item out of diamond, gold ingot, iron ingot, any wool, any ore, dirt, any stone, string, bucket, water bucket, gold block, diamond block, redstone block, any sword, any armour or redstone
			{_items::*} doesn't contain {_item}
			add {_item} to {_items::*}
		add {_items::*} to {_items::*}
		loop integers between 0 and inventory size of {_inventory}:
			set slot loop-number of {_inventory} to white stained glass pane named "&7Click to reveal"
			set {_item} to random item out of {_items::*}
			remove {_item} from {_items::*}
			set {matchit::temp::%player%::items::%loop-number%} to {_item}
		open {_inventory} to player
		play sound "ENTITY_EXPERIENCE_ORB_PICKUP" at volume 0.6 and pitch 2 to player
		# Winning checker
		while {matchit::temp::%player%::inventory} is set:
			wait a second
			{matchit::temp::%player%::complete::*} is set
			if size of {matchit::temp::%player%::complete::*} is greater or equal to ({_size} * 9) / 2:
				set {_time} to difference between now and {matchit::temp::%player%::start}
				set {_uuid} to uuid of player
				set {matchit::%{_uuid}%::highscores::%argument%::%now%} to {_time}
				message "&7[&6MatchIt&7] &fYou have finished a game on difficulty %argument% in %{_time}%, Good game!"
				wait a second
				close player's inventory

on inventory click:
	{matchit::temp::%player%::inventory} is set
	event-inventory is {matchit::temp::%player%::inventory}
	cancel event
	{matchit::temp::%player%::noclick} is not set
	clicked item is white stained glass pane
	play sound "ENTITY_EXPERIENCE_ORB_PICKUP" at volume 0.7 and pitch 2 to player
	set {_item} to {matchit::temp::%player%::items::%clicked slot%}
	set clicked item to {_item}
	if {matchit::temp::%player%::other} is set:
		if {_item} is {matchit::temp::%player%::other}:
			message "&7[&6MatchIt&7] &aA match with &f&l%{_item}% &ahas been found."
			play sound "ENTITY_ENDER_DRAGON_FLAP" at volume 0.5 and pitch 2 to player
			delete {matchit::temp::%player%::other} and {matchit::temp::%player%::otherslot}
			add {_item} to {matchit::temp::%player%::complete::*}
		else:
			set {_slot} to {matchit::temp::%player%::otherslot}
			delete {matchit::temp::%player%::other} and {matchit::temp::%player%::otherslot}
			message "&7[&6MatchIt&7] &cNo matching items."
			play sound "ENTITY_VILLAGER_NO" at volume 0.6 and pitch 2 to player
			set {matchit::temp::%player%::noclick} to true
			wait 13 ticks
			clear {matchit::temp::%player%::noclick}
			set slot {_slot} of event-inventory to white stained glass pane named "&7Click to reveal"
			set clicked item to white stained glass pane named "&7Click to reveal"
		stop
	set {matchit::temp::%player%::other} to {_item}
	set {matchit::temp::%player%::otherslot} to clicked slot

on inventory close:
	{matchit::temp::%player%::inventory} is set
	event-inventory is {matchit::temp::%player%::inventory}
	clear {matchit::temp::%player%::*}

on quit:
	clear {matchit::temp::%player%::*}

on script unload:
	delete {matchit::temp::*}