hex-color-picker.sk

Created by ShaneBee

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.

## HEX COLOR PICKER
## By: ShaneBee
## Requires Skript 2.5+, skript-mirror (or skript-reflect) and Tuske (pikachu-patch-3)

import:
	java.awt.Color
	net.md_5.bungee.api.ChatColor
	org.bukkit.inventory.ItemFlag

function leg(r: number, g: number, b: number) :: item type:
	set {_a} to leather leggings with all flags hidden
	dye {_a} ({_r}, {_g}, {_b})
	return {_a}

function getChatColor(r: number, g: number, b: number) :: text:
	set {_c} to new Color((rgb({_r}, {_g} and {_b})).asBukkitColor().asRGB())
	return ChatColor.of({_c}).toString()

function getHex(r: number, g: number, b: number) :: text:
	set {_c} to new Color((rgb({_r}, {_g} and {_b})).asBukkitColor().asRGB())
	return ChatColor.of({_c}).getName()

function fit(min: number, num: number, max: number) :: number:
	if {_num} > {_max}:
		return {_max}
	else if {_num} < {_min}:
		return {_min}
	else:
		return {_num}

function reRunR(n: number, p: player, r: number, g: number, b: number):
	add {_n} to {_r}
	color({_p}, {_r}, {_g}, {_b})

function reRunG(n: number, p: player, r: number, g: number, b: number):
	add {_n} to {_g}
	color({_p}, {_r}, {_g}, {_b})

function reRunB(n: number, p: player, r: number, g: number, b: number):
	add {_n} to {_b}
	color({_p}, {_r}, {_g}, {_b})

function color(p: player, r: number, g: number, b: number):
	set {_r} to fit(0, {_r}, 255)
	set {_g} to fit(0, {_g}, 255)
	set {_b} to fit(0, {_b}, 255)
	set {_u} to uuid of {_p}

	set {_bung} to getChatColor({_r}, {_g} and {_b})
	set {_name} to coloured "%{_bung}%&lCOLOR (%{_r}%:%{_g}%:%{_b}%)"
	set name of current inventory of {_p} to {_name}

	format gui slot 23 of {_p} with leg({_r}, 0, 0) named "&cRESET" to run:
		reRunR(0 - {_r}, {_p}, {_r}, {_g} and {_b})
	format gui slot 24 of {_p} with leg(0, {_g}, 0) named "&aRESET" to run:
		reRunG(0 - {_g}, {_p}, {_r}, {_g} and {_b})
	format gui slot 25 of {_p} with leg(0, 0, {_b}) named "&bRESET" to run:
		reRunB(0 - {_b}, {_p}, {_r}, {_g} and {_b})

	format gui slot 5 of {_p} with red stained glass pane named "&cCLICK TO ADD 1" to run:
		reRunR(1, {_p}, {_r}, {_g} and {_b})
	format gui slot 6 of {_p} with green stained glass pane named "&aCLICK TO ADD 1" to run:
		reRunG(1, {_p}, {_r}, {_g} and {_b})
	format gui slot 7 of {_p} with blue stained glass pane named "&bCLICK TO ADD 1" to run:
		reRunB(1, {_p}, {_r}, {_g} and {_b})

	format gui slot 14 of {_p} with red stained glass pane named "&cCLICK TO ADD 10" to run:
		reRunR(10, {_p}, {_r}, {_g} and {_b})
	format gui slot 15 of {_p} with green stained glass pane named "&aCLICK TO ADD 10" to run:
		reRunG(10, {_p}, {_r}, {_g} and {_b})
	format gui slot 16 of {_p} with blue stained glass pane named "&bCLICK TO ADD 10" to run:
		reRunB(10, {_p}, {_r}, {_g} and {_b})

	format gui slot 32 of {_p} with red stained glass pane named "&cCLICK TO SUBTRACT 10" to run:
		reRunR(-10, {_p}, {_r}, {_g} and {_b})
	format gui slot 33 of {_p} with green stained glass pane named "&aCLICK TO SUBTRACT 10" to run:
		reRunG(-10, {_p}, {_r}, {_g} and {_b})
	format gui slot 34 of {_p} with blue stained glass pane named "&bCLICK TO SUBTRACT 10" to run:
		reRunB(-10, {_p}, {_r}, {_g} and {_b})

	format gui slot 41 of {_p} with red stained glass pane named "&cCLICK TO SUBTRACT 1" to run:
		reRunR(-1, {_p}, {_r}, {_g} and {_b})
	format gui slot 42 of {_p} with green stained glass pane named "&aCLICK TO SUBTRACT 1" to run:
		reRunG(-1, {_p}, {_r}, {_g} and {_b})
	format gui slot 43 of {_p} with blue stained glass pane named "&bCLICK TO SUBTRACT 1" to run:
		reRunB(-1, {_p}, {_r}, {_g} and {_b})

	set {_i} to leather chestplate named {_name}
	set {_meta} to {_i}.getItemMeta()
	{_meta}.addItemFlags(ItemFlag.HIDE_ATTRIBUTES)
	{_i}.setItemMeta({_meta})
	dye {_i} ({_r}, {_g}, {_b})
	format gui slot 19 of {_p} with {_i}
	format gui slot 10 of {_p} with a chest named "&aSAVE" to close:
		set {savedColor::%{_u}%} to {_bung}
		send formatted "<ttp:&bRGB: &7[&c%{_r}%&7:&a%{_g}%&7:&b%{_b}%&7]%nl%&aHEX: &7[&r%getHex({_r}, {_g} and {_b})%&7]><command:/color %{_r}% %{_g}% %{_b}%>&aSaved color as: %{_bung}%EXAMPLE!!!"
	format gui slot 28 of {_p} with barrier named "&cEXIT" to close

command /color [<number=0>] [<number=0>] [<number=0>]:
	trigger:
		open virtual chest inventory with size 5 named "&0COLOR (0:0:0)" to player
		color(player, arg-1, arg-2 and arg-3)