Backpack.sk

Created by Runakai

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:
	SuccesfullyCreatedBack: &8[&cBackpack&8] &7You created the backpack &6%arg-2% &7with &6%arg-3% &7rows
	AlreadyNineBacks: &8[&cBackpack&8] &7You already have &69 &7Backpacks
	AlreadyExists: &8[&cBackpack&8] &7That Backpack already exists!
	AlreadyExistsAdminGui: &8[&cBackpack&8] &7That Backpack already exists!
	ErrorRows: &8[&cBackpack&8] &7Your Backpack can not have more than &66 &7rows!
	HelpMessage1: &8[&cBackpack&8] &7/backpack create ""&6Name&7"" ""&6rows&7""
	HelpMessage2: &8[&cBackpack&8] &7/backpack &6remove
	HelpMessage3: &8[&cBackpack&8] &7/backpack &c{&6To open the Backpack-Inventory&c}
	PleaseEnterNameViaChat: &8[&cBackpack&8] &7Please enter a new name for your Backpack
	SuccesfullyRenamed: &8[&cBackpack&8] &7You have renamed your backpack to &6%message%
	SuccesfullyRenamedAdminGui: &8[&cBackpack&8] &7You have renamed the player's backpack to &6%message%
	ALreadyExistsAgainSendChat: &8[&cBackpack&8] &7Please enter the Name of the new Backpack again
	ALreadyExistsAgainSendChatAdminGui: &8[&cBackpack&8] &7Please enter the Name of the new Backpack again
	defaulticon: ("MHF_Chest" parsed as offline player)' skull
	IconChangeGuiName: &cChange Icon #Please enter 2 words! It has to be "Change Icon" or "Backpack Change" or whatever. This option NEEDS to have 2 words
	BackItemName: &cBack
	SuccesfullyChangedIcon: &8[&cBackpack&8] &7You have succesfully changed the Icon
	AdminGuiPermission: sk.Back.Admin
	AdminGuiName: &cAdminPanel
	RenameAdminGuiName: &cRename
	SelectPlayerAdminGuiName: &cSelect a Player!
	SignAdminGuiName: &cChange Rows
	EmeraldAdminGuiName: &cChange Icon
	EnderChestAdminGuiName: &cChange Items
	PlayerEnterChatAdminGUI: &8[&cBackpack&8] &7Please enter a Name in the Chat
	AdminRenamingGui: &cAdminGUI-Rename
	AdminRowChangeGui: &cAdminGUI-Row
	AdminIconChangeGui: &cAdminGui-Icon
	AdminItemChangeGui: &cAdminGui-Items
	PleaseEnterRowViaChat: &8[&cBackpack&8] &7Please enter [1-6] rows 
	SuccesfullyRowChangeAdminGui: &8[&cBackpack&8] &7You have changed the Rows of the player!
	SteveHeadLore: &7Click here to enter a Name of the wished player
	
	
on script load:
	delete {iconlist::*}
	add diamond helmet, diamond chestplate, diamond leggings, diamond boots, diamond sword, bow, arrow, steak, enchanted book, diamond pickaxe, diamond axe, diamond shovel, fishing rod, ender eye, diamond block, redstone dust, potion of healing and ender chest to {iconlist::*}
	
function openBackInv(p: player, i: text, u: text):
	set {_} to uuid of ({_u} parsed as player)
	open chest inventory with 1 row named "%{_i}%" to {_p}
	loop {backpack::%{_}%::*}:
		set slot (loop-index parsed as integer -1) of {_p}' current inventory to {backpack::icon::%{_}%::%loop-value%} named "&cBackpack: &6%loop-value%" with lore "&cRows: &6%{backpack::rows::%{_}%::%loop-value%}%"
		
function openback(p: player, b: text, s: number):
	set {_u} to uuid of {_p}
	open chest inventory with {_s} rows named {_b} to {_p}
	loop {backpack::items::%{_u}%::%{_b}%::*}:
		set slot (loop-index parsed as integer -1) of {_p}' current inventory to loop-value
		
function openbackadmin(p: player, b: text, s: number, u: text):
	set {_} to uuid of ({_u} parsed as player)
	open chest inventory with {_s} rows named {_b} to {_p}
	loop {backpack::items::%{_}%::%{_b}%::*}:
		set slot (loop-index parsed as integer -1) of {_p}' current inventory to loop-value
		
function openIconInv(p: player, i: text):
	open chest inventory with 4 rows named "{@IconChangeGuiName} %{_i}%" to {_p}
	loop 10 times:
		set slot (loop-number-2) of {_p}' current inventory to gray stained glass pane named ""
		set slot (loop-number+27-1) of {_p}' current inventory to gray stained glass pane named ""
	loop {iconlist::*}:
		set slot (loop-index parsed as integer +9-1) of {_p}' current inventory to loop-value
	set slot 27 of {_p}' current inventory to ("MHF_ArrowLeft" parsed as offline player)' skull named "{@BackItemName}"

function openAdminGui(p: player, i: text):
	open chest inventory with 6 rows named "{@AdminGuiName}" to {_p}
	set slot 13 of {_p}' current inventory to ("%{_i}%" parsed as offline player)' skull named "%{_i}%" with lore "{@SteveHeadLore}"
	set slot 28 of {_p}' current inventory to nametag named "{@RenameAdminGuiName}"
	set slot 30 of {_p}' current inventory to ender eye named "{@SignAdminGuiName}"
	set slot 32 of {_p}' current inventory to emerald named "{@EmeraldAdminGuiName}"
	set slot 34 of {_p}' current inventory to ender chest named "{@EnderChestAdminGuiName}"
	set slot 0,4,8,45,49 and 53 of {_p}' current inventory to pink stained glass pane named ""
	set slot 1,3,5,7,9,17,36,44,46,48,52 and 50 of {_p}' current inventory to red stained glass pane named ""
	
function HelpMessage(p: player):
	send "{@HelpMessage1}" to {_p}
	send "{@HelpMessage2}" to {_p}
	send "{@HelpMessage3}" to {_p}
	
function StatsMessage(p: player):
	set {_} to uuid of {_p}
	send "&8[&cBackpack&8] &6%{_p}% &7has &6%size of {backpack::%{_}%::*}% &7Backpacks" to {_p}
	
command bstats [<player>]:
	trigger:
		StatsMessage(arg-1 ? player)
		

command backpack [<text>] [<text>] [<integer>]:
	aliases: bak, bp, backp
	trigger:
		arg-1 is set:
			arg-2 is set:
				arg-3 is set:
					arg-3 <= 6:
						arg-1 is "create":
							{backpack::%uuid of player%::*} does not contain arg-2:
								size of {backpack::%uuid of player%::*} <= 9:
									add arg-2 to {backpack::%uuid of player%::*}
									set {backpack::rows::%uuid of player%::%arg-2%} to arg-3
									set {backpack::icon::%uuid of player%::%arg-2%} to {@defaulticon}
									send "{@SuccesfullyCreatedBack}"
								else:
									send "{@AlreadyNineBacks}"
							else:
								send "{@AlreadyExists}"
					else:
						send "{@ErrorRows}"
			else:		
				if arg-1 is "list":
					openBackInv(player, "&cBackpacks", "%player%")
				else if arg-1 is "remove":
					openBackInv(player, "&cBackpack - removing", "%player%")
				else if arg-1 is "help":
					HelpMessage(player)
				else if arg-1 is "admin":
					if player has permission "{@AdminGuiPermission}":
						openAdminGui(player, "Steve")
				else:
					HelpMessage(player)
		else:
			if arg-2 is not set:
				if arg-3 is not set:
					openBackInv(player, "&cBackpacks", "%player%")
			else:
				HelpMessage(player)
		
inventory close:
	if {AdminGuiItemChange::%uuid of player%::*} is not set:
		{backpack::%uuid of player%::*} contains uncoloured name of event-inventory:
			set {_list::*} to all items in player' current inventory
			if {_list::*} is set:
				set {backpack::items::%uuid of player%::%uncoloured name of event-inventory%::*} to {_list::*}
			else:
				delete {backpack::items::%uuid of player%::%uncoloured name of event-inventory%::*}
	else:
		loop {AdminGuiItemChange::%uuid of player%::*}:
			set {_list::*} to uncoloured loop-value split at " "
			set {_} to uuid of ({_list::1} parsed as player)
			set {_items::*} to all items in player' current inventory
			set {backpack::items::%{_}%::%{_list::2}%::*} to {_items::*}
			delete {AdminGuiItemChange::%uuid of player%::*}
			stop if {_items::*} is set
			delete {backpack::items::%{_}%::%{_list::2}%::*}
		
inventory click:
	event-inventory != player's inventory:
		uncoloured name of event-inventory contains "Backpack" or "Admin":
			cancel event
		event-click type = left mouse button:
			name of player's current inventory = "&cBackpacks":
				event-slot != air:
					cancel event
					set {_a} to uncoloured event-slot' name
					set {_s} to uncoloured line 1 of lore of event-slot
					replace every "Backpack: " with "" in {_a}
					replace every "Rows: " with "" in {_s}
					set {_s} to {_s} parsed as number
					openback(player, {_a}, {_s})
			else if name of player's current inventory = "&cBackpack - removing":
				event-slot != air:
					cancel event
					set {_a} to uncoloured event-slot' name
					replace every "Backpack: " with "" in {_a}
					remove  {_a} from {backpack::%uuid of player%::*}
					delete {backpack::items::%player' uuid%::%{_a}%::*}
					openBackInv(player, "&cBackpack - removing", "%player%")
			else if name of player' current inventory contains "{@IconChangeGuiName}":
				cancel event
				event-slot != gray stained glass pane:
					index of event-slot != 27:
						set {_list::*} to uncoloured name of player' current inventory split at " "
						set {_} to uuid of ({_list::3} parsed as player)
						set {backpack::icon::%{_}%::%{_list::4}%} to event-slot
						send "{@SuccesfullyChangedIcon}"
						close player' inventory
			else if name of player' current inventory = "{@AdminGuiName}":
				cancel event
				event-slot = skull item:
					set {TypeInChatGui::%uuid of player%} to true
					send "{@PlayerEnterChatAdminGUI}"
					close player' inventory
				else if event-slot = nametag:
					set {_k} to uncoloured name of slot 13 of player' current inventory
					openBackInv(player, "{@AdminRenamingGui} &6%{_k}%", {_k})
				else if event-slot = ender eye:
					set {_k} to uncoloured name of slot 13 of player' current inventory
					openBackInv(player, "{@AdminRowChangeGui} &6%{_k}%", {_k})
				else if event-slot = emerald:
					set {_k} to uncoloured name of slot 13 of player' current inventory
					openBackInv(player, "{@AdminIconChangeGui} &6%{_k}%", {_k})
				else if event-slot = ender chest:
					set {_k} to uncoloured name of slot 13 of player' current inventory
					openBackInv(player, "{@AdminItemChangeGui} &6%{_k}%", {_k})					
			else if name of player' current inventory contains "{@AdminRenamingGui}":
				event-slot != air:
					cancel event
					set {_i::*} to name of player' current inventory split at " "
					set {_a} to uncoloured name of event-slot
					replace every "Backpack: " with "" in {_a}
					add "%{_i::2}% %{_a}%" to {AdminGuiRename::%uuid of player%::*}
					send "{@PleaseEnterNameViaChat}"
					close player' inventory
			else if name of player' current inventory contains "{@AdminRowChangeGui}":
				event-slot != air:
					set {_i::*} to name of player' current inventory split at " "
					set {_a} to uncoloured name of event-slot
					replace every "Backpack: " with "" in {_a}
					add "%{_i::2}% %{_a}%" to {AdminRowChange::%uuid of player%::*}
					send "{@PleaseEnterRowViaChat}"
					close player' inventory
			else if name of player' current inventory contains "{@AdminIconChangeGui}":
				event-slot != air:
					set {_a} to uncoloured name of event-slot
					replace every "Backpack: " with "" in {_a}
					set {_i::*} to uncoloured name of player' current inventory split at " "
					add "%{_i::2}% %{_a}%" to {_list::*}
					broadcast "%{_list::*}%"
					openIconInv(player, {_list::*})
			else if name of player' current inventory contains "{@AdminItemChangeGui}":
				event-slot != air:
					set {_a} to uncoloured event-slot' name
					set {_s} to uncoloured line 1 of lore of event-slot
					replace every "Backpack: " with "" in {_a}
					replace every "Rows: " with "" in {_s}
					set {_s} to {_s} parsed as number
					set {_i::*} to uncoloured name of player' current inventory split at " "
					openbackadmin(player, {_a}, {_s}, "%{_i::2}%")
					wait a tick
					add "%{_i::2}% %{_a}% %{_s}%" to {AdminGuiItemChange::%uuid of player%::*}
		else if event-click type = right mouse button:
			name of player's current inventory = "&cBackpacks":
				set {_a} to uncoloured event-slot' name
				replace every "Backpack: " with "" in {_a}
				add {_a} to {RenameViaChat::%uuid of player%::*}
				send "{@PleaseEnterNameViaChat}"
				close player' inventory
		else if event-click type = middle mouse button:
			name of player's current inventory = "&cBackpacks":
				cancel event
				set {_d::*} to uncoloured event-slot' name split at " "
				openIconInv(player, "%player% %{_d::2}%")
	index of event-slot = 27:
		name of event-slot = "{@BackItemName}":
			openBackInv(player, "&cBackpacks", "%player%")
			
on chat:
	if {RenameViaChat::%uuid of player%::*} is set:
		cancel event
		loop {RenameViaChat::%uuid of player%::*}:
			{backpack::%uuid of player%::*} does not contain message:
				send "{@SuccesfullyRenamed}"
				replace every "%loop-value%" with message in {backpack::%uuid of player%::*}
				set {backpack::rows::%uuid of player%::%message%} to {backpack::rows::%uuid of player%::%loop-value%}
				set {backpack::items::%uuid of player%::%message%::*} to {backpack::items::%uuid of player%::%loop-value%::*}
				set {backpack::icon::%uuid of player%::%message%} to {backpack::icon::%uuid of player%::%loop-value%}
				delete {backpack::icon::%uuid of player%::%loop-value%}
				delete {backpack::rows::%uuid of player%::%loop-value%}
				delete {RenameViaChat::%uuid of player%::*}
			else:
				send "{@AlreadyExists}"
				send "{@ALreadyExistsAgainSendChat}"
	else if {AdminGuiRename::%uuid of player%::*} is set:
		cancel event
		loop {AdminGuiRename::%uuid of player%::*}:
			set {_A::*} to loop-value split at " "
			set {_A::1} to uncoloured {_A::1}
			set {_i} to uuid of ({_A::1} parsed as player)
			{backpack::%{_i}%::*} does not contain message:
				send "{@SuccesfullyRenamedAdminGui}"
				replace every "%{_A::2}%" with message in {backpack::%{_i}%::*}
				set {backpack::rows::%{_i}%::%message%} to {backpack::rows::%{_i}%::%{_A::2}%}
				set {backpack::items::%{_i}%::%message%::*} to {backpack::items::%{_i}%::%{_A::2}%::*}
				set {backpack::icon::%{_i}%::%message%} to {backpack::icon::%{_i}%::%{_A::2}%}
				delete {backpack::icon::%{_i}%::%{_A::2}%}
				delete {backpack::rows::%{_i}%::%{_A::2}%}
				delete {AdminGuiRename::%uuid of player%::*}
			else:
				send "{@AlreadyExistsAdminGui}"
				send "{@ALreadyExistsAgainSendChatAdminGui}"
	else if {AdminRowChange::%uuid of player%::*} is set:
		cancel event
		loop {AdminRowChange::%uuid of player%::*}:
			set {_A::*} to loop-value split at " "
			set {_A::1} to uncoloured {_A::1}
			set {_i} to uuid of ({_A::1} parsed as player)
			send "{@SuccesfullyRowChangeAdminGui}"
			set {backpack::rows::%{_i}%::%{_A::2}%} to message
			delete {AdminRowChange::%uuid of player%::*}
	else if {TypeInChatGui::%uuid of player%} is set:
		cancel event
		openAdminGui(player, message)
		delete {TypeInChatGui::%uuid of player%}