apply.sk

Created by Efnilite

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.

#=======================================#
#                       _             	#
#     /\               | |        _   	#
#    /  \   _ __  _ __ | |_   _ _| |_ 	#
#   / /\ \ | '_ \| '_ \| | | | |_   _|	#
#  / ____ \| |_) | |_) | | |_| | |_|  	#
# /_/    \_\ .__/| .__/|_|\__, |     	#	
#          | |   | |       __/ |     	#
#          |_|   |_|      |___/ 		#
#										#
#=======================================#

#------------- By Efnilite -------------#

# All options, messages, etc. are available in the 'plugins/Apply+' folder
# Requirements: skript-yaml 1.2.4, skript-mirror 1.0.0, mundosk 1.8.6

import:
	java.util.Arrays
	java.lang.System
	java.nio.file.Paths
	java.nio.file.Files

local effect create dir[ector(y|ies)] %string%:
	trigger:
		Files.createDirectories(Paths.get(expression-1))

local expression formatted yaml time of yaml value %string% from %string%:
	get:
		set {_e} to yaml value "%expression-1%" from expression-2
		set {_e::*} to {_e} parsed as "%integer%/%integer%/%integer% %integer%:%integer%:%integer%"
		set {_ec} to date({_e::3}, {_e::2}, {_e::1}, {_e::4}, {_e::5}, {_e::6} + 1)
		return {_ec}

local expression %item% with lore %text%:
    get:
        set {_i} to expression-1.clone()
        set {_meta} to {_i}.getItemMeta()
        {_meta}.setLore(Arrays.asList(split expression-2 at "||"))
        {_i}.setItemMeta({_meta})
        return {_i}

local expression nl:
	get:
		return System.lineSeparator()

local effect make %player% apply:
	trigger:
		set {_p} to expression-1
		set {_uuid} to expression-1's uuid

		set {_z} to yaml value "time-between" from "config" parsed as timespan
		if yaml value "user.last-apply" from "%{_uuid}%" is "N/A":
			if yaml value "disable-movement-on-apply" from "config" is true:
				spawn armor stand at {_p}
				(last spawned entity).setVisible(false)
				(last spawned entity).setGravity(false)
				make {_p} ride last spawned entity

			send colored yaml value "introduction" from "questions" to {_p}
			send "%first element of yaml list ""questions"" from ""questions""%" to {_p}

			set yaml value "user.applying" from "%{_uuid}%" to true
			set yaml value "user.can-apply" from "%{_uuid}%" to false
			set yaml value "user.at" from "%{_uuid}%" to 2

			add {_uuid} to yaml list "applications" from "applications" 
			save yaml "applications"
			save yaml "%{_uuid}%"
			stop
		set {_c} to formatted yaml time of yaml value "user.last-apply" from "%{_uuid}%"
		if difference between {_c} and now >= {_z}:
			if yaml value "disable-movement-on-apply" from "config" is true:
				spawn armor stand at {_p}
				(last spawned entity).setVisible(false)
				(last spawned entity).setGravity(false)
				make {_p} ride last spawned entity

			send colored yaml value "introduction" from "questions" to {_p}
			send "%first element of yaml list ""questions"" from ""questions""%" to {_p}

			set yaml value "user.applying" from "%{_uuid}%" to true
			set yaml value "user.can-apply" from "%{_uuid}%" to false
			set yaml value "user.at" from "%{_uuid}%" to 2

			add {_uuid} to yaml list "applications" from "applications" 
			set {_now} to yaml value "user.last-apply" from "%{_uuid}%"
			save yaml "applications"
			save yaml "%{_uuid}%"
		else:
			if {_p} has permission yaml value "permissions.bypass" from "config":
				if yaml value "disable-movement-on-apply" from "config" is true:
					spawn armor stand at {_p}
					(last spawned entity).setVisible(false)
					(last spawned entity).setGravity(false)
					make {_p} ride last spawned entity

				send colored yaml value "introduction" from "questions" to {_p}
				send "%first element of yaml list ""questions"" from ""questions""%" to {_p}

				set yaml value "user.applying" from "%{_uuid}%" to true
				set yaml value "user.can-apply" from "%{_uuid}%" to false
				set yaml value "user.at" from "%{_uuid}%" to 2

				add {_uuid} to yaml list "applications" from "applications" 
				set {_now} to yaml value "user.last-apply" from "%{_uuid}%"
				save yaml "applications"
				save yaml "%{_uuid}%"
			else:
				set {_msg} to yaml value "messages.already-applied" from "messages"
				set {_diff} to difference between {_c} and (yaml value "time-between" from "config" parsed as timespan) ago
				replace all "<time>" with "%{_diff}%" in {_msg}
				send colored {_msg} to {_p}

local effect stop %player% apply:
	trigger:
		set {_p} to expression-1
		set {_uuid} to {_p}'s uuid

		kill {_p}'s vehicle

		send colored yaml value "messages.done" from "messages" to {_p}
		set {_m} to yaml value "messages.applied" from "messages"
		replace all "<player>" with "%{_p}%" in {_m}
		loop all players:
			if loop-player has permission yaml value "permissions.notify" from "permissions":
				send colored {_m} to loop-player

		set yaml value "user.applying" from "%{_uuid}%" to false
		set yaml value "user.last-apply" from "%{_uuid}%" to "%now%"
		delete yaml value "user.at" from "%{_uuid}%"
		save yaml "%{_uuid}%"

on load:
	load yaml "plugins/Apply+/config.yml" as "config"
	load yaml "plugins/Apply+/messages.yml" as "messages"
	load yaml "plugins/Apply+/permissions.yml" as "permissions"
	load yaml "plugins/Apply+/questions.yml" as "questions"
	load yaml "plugins/Apply+/applications.yml" as "applications"
	create dir "plugins/Apply+/users"

	if yaml value "time-between" from "config" is not set:
		set yaml value "time-between" from "config" to "21 days"
		set yaml value "disable-movement-on-apply" from "config" to true
		save yaml "config" 

	if yaml value "messages.prefix" from "messages" is not set:
		set yaml value "messages.done" from "messages" to "&aThanks for applying to this server!"
		set yaml value "messages.accept" from "messages" to "&a&lCongrats! &o&aYou &ahave been chosen as a staff member! Contact staff to get more info."
		set yaml value "messages.denied" from "messages" to "&c&lAwwhh! &cYour application was denied by staff :( Try again in <time>!"
		set yaml value "messages.already-applied" from "messages" to "&aYou already applied! Please wait <time> after applying to apply again!"
		set yaml value "messages.confirm" from "messages" to "&7[Answer] <message>"
		set yaml value "messages.applied" from "messages" to "&a<player> has applied!"
		set yaml value "messages.not-applied" from "messages" to "&cThat player has not applied yet!"
		set yaml value "messages.set-player" from "messages" to "&cYou need to set a player!"
		set yaml value "messages.player-accepted" from "messages" to "&aYou accepted <player>'s request!"
		set yaml value "messages.player-denied" from "messages" to "&cYou denied <player>'s request!"
		save yaml "messages"

	if yaml value "options.need-permission" from "permissions" is not set:
		set yaml value "options.need-permission" from "permissions" to true
		set yaml value "permissions.menu" from "permissions" to "apply.menu"
		set yaml value "permissions.notify" from "permissions" to "apply.notify"
		set yaml value "permissions.bypass" from "permissions" to "apply.bypass"
		set yaml value "permissions.admin" from "permissions" to "apply.admin"
		save yaml "permissions"

	if yaml value "introduction" from "questions" is not set:
		set yaml value "introduction" from "questions" to "&aStarting Apply process. Your chat and movement is now freezed!"
		set {_default::1} to "&c[1] What rank are you applying for?"
		set {_default::2} to "&c[2] Have you had previous leader experiences (irl or in-game)?"
		set {_default::3} to "&c[3] What is your timezone? (for example -8:00 or +6:30)"
		set {_default::4} to "&c[4] What is your age?"
		set {_default::5} to "&c[5] Are you able to record Minecraft?"
		set {_default::6} to "&c[6] Do you have Discord and a working microphone?"
		set {_default::7} to "&c[7] Have you been ever banned on this server? If so, for what reason!"
		set {_default::8} to "&c[8] &oSCENARIO: &cSuppose it's your first week of being a staff member and you mute a well known player. Their fans start spamming your twitter calling you a bad person and telling you to unmute them. What would you do?"
		set {_default::9} to "&c[9] Have you made any previous applications, if so how many and what is the date of your last one?"
		set {_default::10} to "&c[10] Is there anything else we need to know?"
		set yaml list "questions" from "questions" to {_default::*}
		save yaml "questions"

on join:
	load yaml "plugins/Apply+/users/%player's uuid%.yml" as player's uuid
	if yaml value "user.applying" from player's uuid is not set:
		set yaml value "user.applying" from player's uuid to false
		set yaml value "user.last-apply" from player's uuid to "N/A"
		save yaml player's uuid

	if yaml value "user.offline-message" from player's uuid is set:
		send colored yaml value "user.offline-message" from player's uuid to player

on quit:
	unload yaml player's uuid

on packet event play_client_steer_vehicle:
	if yaml value "user.applying" from player's uuid is true:
		cancel event

command /apply [<text>] [<offline player>]:
	aliases: apply+
	trigger:
		if player does not have permission yaml value "permissions.admin" from "permissions":
			make player apply
		else:
			if arg-1 is "help":
				send "&7&m----------&r &aApply+ &7&m----------"
				send "&a/apply &7- &fMain command"
				send "&a/apply menu &7- &fView the menu"
				send "&a/apply accept <player> &7- &fAccept a player's application"
				send "&a/apply deny <player> &7- &fDeny a player's application"
				send "&a/apply view <player> &7- &fView a player's application"

			else if arg-1 is not set:
				send "&7&m----------&r &aApply+ &7&m----------"
				send "&a/apply &7- &fMain command"
				send "&a/apply menu &7- &fView the menu"
				send "&a/apply accept <player> &7- &fAccept a player's application"
				send "&a/apply deny <player> &7- &fDeny a player's application"
				send "&a/apply view <player> &7- &fView a player's application"

			else if arg-1 is "menu":
				open chest inventory with 5 rows named "&aApplications" to player
				set {_index} to 1
				loop yaml list "applications" from "applications":
					set {_name} to ("%loop-value%" parsed as offlineplayer)
					set slot ({_index} - 1) of player's current inventory to skull of ("%loop-value%" parsed as offlineplayer) named "&6%{_name}%" with lore "&7Click me to view!"
					if {_index} is 5 * 9:
						stop
					set {_index} to {_index} + 1

			else if arg-1 is "view":
				if arg-2 is set:
					if yaml list "applications" from "applications" contains uuid of arg-2:
						open chest inventory with 4 rows named "&aApplication of %arg-2%" to player
						set {_q::*} to yaml list "questions" from "questions"
						set {_a::*} to yaml list "answers" from arg-2's uuid
						loop (size of yaml list "questions" from "questions" - 1) times:
							set slot (loop-value - 1) of player's current inventory to loop-value of skull of ("MHF_Question" parsed as offlineplayer) named "&6%colored {_q::%loop-value%}%" with lore "&7Answer:||||&7%{_a::%loop-value%}%" 
						set slot 29 of player's current inventory to emerald block named "&a&lConfirm"
						set slot 33 of player's current inventory to redstone block named "&c&lDeny"
					else:
						send colored yaml value "messages.not-applied" from "messages"
				else:
					send colored yaml value "messages.set-player" from "messages"

			else if arg-1 is "accept":
				if arg-2 is set:
					if yaml list "applications" from "applications" contains uuid of arg-2:
						set {_msg} to yaml value "messages.player-accepted" from "messages"
						replace all "<player>" with "%player%" in {_msg}
						send colored {_msg}

						remove uuid of arg-2 from yaml list "applications" from "applications"
						if arg-2 is online:
							set {_msg} to yaml value "messages.accepted" from "messages"
							replace all "<time>" with yaml value "time-between" from "config" in {_msg}
							send colored {_msg} to arg-2
						else:
							set {_msg} to yaml value "messages.accepted" from "messages"
							replace all "<time>" with yaml value "time-between" from "config" in {_msg}
							set yaml value "user.offline-message" from arg-2's uuid to {_msg}
					else:
						send colored yaml value "messages.not-applied" from "messages"
				else:
					send colored yaml value "messages.set-player" from "messages"

			else if arg-1 is "deny":
				if arg 2 is set:
					if yaml list "applications" from "applications" contains uuid of arg-2:
						set {_msg} to yaml value "messages.player-denied" from "messages"
						replace all "<player>" with "%player%" in {_msg}
						send colored {_msg}

						delete yaml list "answers" from "applications"
						remove uuid of arg-2 from yaml list "applications" from "applications"
						if arg-2 is online:
							set {_msg} to yaml value "messages.denied" from "messages"
							replace all "<time>" with yaml value "time-between" from "config" in {_msg}
							send colored {_msg} to arg-2
						else:
							set {_msg} to yaml value "messages.accepted" from "messages"
							replace all "<time>" with yaml value "time-between" from "config" in {_msg}
							set yaml value "user.offline-message" from arg-2's uuid to {_msg}
					else:
						send colored yaml value "messages.not-applied" from "messages"
				else:
					send colored yaml value "messages.set-player" from "messages"
			
			else if arg-1 is "apply":
				make player apply

on inventory click:
	if name of player's current inventory is "&aApplications":
		cancel event
		if event-item is not air:
			set {_name} to uncolored name of event-item 
			execute player command "/apply view %{_name}%"
	else if name of player's current inventory contains "&aApplication of":
		cancel event
		set {_name::*} to name of player's current inventory split at " "
		set {_name} to uncolored {_name::3}
		if event-item is redstone block:
			execute player command "/apply deny %{_name}%"
			close player's inventory
		else if event-item is emerald block:
			execute player command "/apply accept %{_name}%"
			close player's inventory

on chat:
	if yaml value "user.applying" from player's uuid is true:
		set {_msg} to yaml value "messages.confirm" from "messages"
		set {_q::*} to yaml list "questions" from "questions"
		set {_o} to yaml value "user.at" from player's uuid
		set yaml value "user.at" from player's uuid to yaml value "user.at" from player's uuid + 1
		save yaml player's uuid

		cancel event

		replace all "<message>" with message in {_msg}
		send colored {_msg}
		wait 10 ticks
		send colored {_q::%{_o}%} to player 

		add uncolored message to yaml list "answers" from player's uuid

		if {_o} is (size of {_q::*} + 1):
			stop player apply