TablistManager.sk

Created by jacob

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.

# GENERATION
import:
	java.net.URL
	java.io.BufferedReader
	java.io.InputStreamReader

plural expression [get] (version) [(url)] %string%:
	return type: strings
	get:
		set {_link} to try new BufferedReader(try new InputStreamReader(try new URL(expr-1).openStream()))
		set {_q::*} to ...try {_link}.lines()
		try {_link}.close()
		return {_q::*}

on load:
	loop "skript-reflect", "skript-yaml" and "Vault":
		if server.getServer().getPluginManager().getPlugin(loop-value) is not set:
			send "&c&lADDON CHECKER &7You need the following Skript addons to run TablistManager, Missing Addons: &c&n%loop-value%" to console
			stop
	load yml "plugins/TablistManager/Config.yml" as "plugins/TablistManager/Config.yml"
	if yaml "plugins/TablistManager/Config.yml" is empty:
		set yaml value "Settings.Server_Prefix" of "plugins/TablistManager/Config.yml" to "&6&lSERVER"
		set yaml value "Settings.Update_Checker" of "plugins/TablistManager/Config.yml" to true
		set yaml value "Settings.Admin_Permission" of "plugins/TablistManager/Config.yml" to "tablistmanager.admin"
		set yaml value "Settings.Prefix" of "plugins/TablistManager/Config.yml" to false
		set yaml value "Settings.Suffix" of "plugins/TablistManager/Config.yml" to false
		set yaml value "Settings.Update_Time" of "plugins/TablistManager/Config.yml" to 5
		set yaml value "Content.Header" of "plugins/TablistManager/Config.yml" to "&d&lWelcome To My Server {NewLine} &7&oVisit the Config.yml to edit this!"
		set yaml value "Content.Footer" of "plugins/TablistManager/Config.yml" to "&aHello {player} {nl}&e&n Support the server today!"
		save yml "plugins/TablistManager/Config.yml"
		send "&6&lTABLISTMANAGER &eA new Config.yml was created!" to console
	if yaml value "Settings.Update_Checker" of "plugins/TablistManager/Config.yml" is true:
		if "%get version "https://raw.githubusercontent.com/JacobJoergensen/TablistManager/main/version.txt"%" is not "1.0.2":
			send "&c&lUPDATE CHECKER &7You are running an old version of TablistManager %nl% &8(&cCurrent version: &c1.0.2&8) - (&aLatest version: &a%get version "https://raw.githubusercontent.com/JacobJoergensen/TablistManager/main/version.txt"%&8) %nl% &fDownload the newest version at &7https://github.com/JacobJoergensen/TablistManager/releases/latest" to console
			stop
	send "&6&lTABLISTMANAGER &eWas loaded correctly &8(&cNO ERRORS&8).%nl%&6&lTABLISTMANAGER WIKI: &ehttps://jacobjoergensen2.gitbook.io/tablistmanager/%nl%&6&lTABLISTMANAGER REPORT BUGS & IDEAS: &ehttps://github.com/JacobJoergensen/TablistManager/issues" to console

on join:
	wait 1 second
	load yml "plugins/TablistManager/PlayerData/%uuid of player%.yml" as "plugins/TablistManager/PlayerData/%uuid of player%.yml"
	if yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of player%.yml" is not set:
		set yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of player%.yml" to "§7"
		save yml "plugins/TablistManager/PlayerData/%uuid of player%.yml"
	# TABLIST UPDATER
	while player is online:
		if tps is bigger than 12:
			load yml "plugins/TablistManager/Config.yml" as "plugins/TablistManager/Config.yml"
			wait "%yaml value "Settings.Update_Time" of "plugins/TablistManager/Config.yml"% seconds" parsed as timespan
			TlmApi(player)

# TABLIST HANDLER
function TlmApi(p: player):
	load yml "plugins/TablistManager/Config.yml" as "plugins/TablistManager/Config.yml"
	set all players' tab list header to TlmPlaceholders("%yaml value "Content.Header" of "plugins/TablistManager/Config.yml"%", {_p})
	set all players' tab list footer to TlmPlaceholders("%yaml value "Content.Footer" of "plugins/TablistManager/Config.yml"%", {_p})
	set {_prefix} to {_p}'s prefix if yaml value "Settings.Prefix" of "plugins/TablistManager/Config.yml" is true
	set {_prefix} to "" if yaml value "Settings.Prefix" of "plugins/TablistManager/Config.yml" is false
	set {_suffix} to {_p}'s suffix if yaml value "Settings.Suffix" of "plugins/TablistManager/Config.yml" is true
	set {_suffix} to "" if yaml value "Settings.Suffix" of "plugins/TablistManager/Config.yml" is false
	if yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml" is set:
		set {_playerColor} to yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml"
	set {_p}'s tab list name to "%{_prefix}% %{_playerColor}%%{_p}'s displayname% %{_suffix}%"

# PLACEHOLDERS
function TlmPlaceholders(s: string, p: player) :: text:
	replace all "{NewLine}" or "{NL}" or "||" or "&&" with newline in {_s}
	replace all "{Player}" or "{PlayerName}" with "%{_p}%" in {_s}
	replace all "{Level}" with "%{_p}'s level%" in {_s}
	replace all "{PlayerHealth}" with "%{_p}'s health%" in {_s}
	replace all "{MaxPlayerHealth}" with "%{_p}'s max health%" in {_s}
	replace all "{FoodLevel}" with "%{_p}'s food level%" in {_s}
	replace all "{Coordinate}" or "{Location}" with "%{_p}'s location%" in {_s}
	replace all "{Gamemode}" with "%{_p}'s gamemode%" in {_s}
	replace all "{LightLevel}" with "%light level at {_p}%" in {_s}
	replace all "{IpAddress}" with ip of {_p} in {_s}
	replace all "{TimePlayed}" with "%time played of {_p}%" in {_s}
	replace all "{World}" with "%{_p}'s world%" in {_s}
	replace all "{WorldTime}" with "%time in world ""%{_p}'s world%""%" in {_s}
	replace all "{OnlinePlayersInWorld}" or "{Opiw}" with "%amount of all players in world ""%{_p}'s world%""%" in {_s}
	replace all "{Online}" or "{OnlinePlayers}" with "%number of all players%" in {_s}
	replace all "{MaxPlayers}" with "%max player count%" in {_s}
	replace all "{BukkitVersion}" with bukkit version in {_s}
	replace all "{MinecraftVesion}" or "{McVersion}" with minecraft version in {_s}
	replace all "{Ping}" with "%{_p}'s ping%" in {_s}
	replace all "{Tps}" with "%tps%" in {_s}
	replace all "{ServerTime}" or "{RealTime}" with now formatted as "HH:mm:ss" in {_s}
	replace all "{Date}" with now formatted as "d/M/yyyy" in {_s}
	replace all "{Motd}" with motd in {_s}
	return {_s}

# COMMANDS
command /tablistmanager:tablistmanager [<text>] [<offline player>] [<text>]:
	aliases: tablist, tl, tm, tb, tbl, tablistmanager, tablist-manager, tlm, tblm, tab
	trigger:
		if player has permission "%yaml value "Settings.Admin_Permission" of "plugins/TablistManager/Config.yml"%":
			if arg 1 is not set:
				TlmApi(player)
				send action bar "&eT&6a&eb&6l&ei&6s&et &6U&ep&6d&ea&6t&ee&6d" to player
				play sound "ENTITY_PLAYER_LEVELUP" with volume 2 to player
				send title "&4&lTABLIST HELP" with subtitle "&8/&ctablist help" to player for 2 seconds
			if arg 1 is "help" or "info":
				send formatted "&c▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ &c&lTablist Help&c ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬%nl%&f%nl%<tooltip:&b&oClick Here To Execute This Command><run command:/tablistmanager> &8➳ &e/Tablist &8, &7Update the Tablist manually.%nl% &8➳ &e/Tablist help &8, &7Shows this message.%nl%<tooltip:&9Minecraft Color Codes: &00&8, &11&8, &22&8, &33&8, &44&8, &55&8, &66&8, &77&8, &88&8, &99&8, &aa&8, &bb&8, &cc&8, &dd&8, &ee&8, &ff > &8➳ &e/Tablist color &8<&eplayer&8> <&ecolor-code&8> , &7Change a players tab color in the Tablist.<reset>%nl%<tooltip:&b&oClick Here To Execute This Command><run command:/tablistmanager reload> &8➳ &e/Tablist reload &8, &7Reload TablistManager.<reset>%nl%&f%nl%&c▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ &c&lTablist Help&c ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
			if arg 1 is "reload":
				make player execute command "/sk reload TablistManager.sk"
				send formatted "&f%nl%&c&lTLM RELOAD &8➳ &aTablistManager was reloaded!%nl%&f%nl%<tooltip:&fClick Here To Visit Wiki><link:https://jacobjoergensen2.gitbook.io/tablistmanager/>&bVisit WIKI <reset>&8| <tooltip:&fClick Here To Report Bugs And Suggest Ideas><link:https://github.com/JacobJoergensen/TablistManager/issues>&bVisit REPORT BUGS & IDEAS<reset>"
			if arg 1 is "setcolor" or "changecolor" or "color":
				if arg 2 is offline player:
					if arg 3 is "0", "1", "2" or "3" or "4" or "5" or "6" or "7" or "8" or "9" or "a" or "b" or "c" or "d" or "e" or "f":
						set yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of arg 2%.yml" to "§%arg-3%"
						save yml "plugins/TablistManager/PlayerData/%uuid of arg 2%.yml"
						send action bar "&aYou have changed the tablist color for &%arg-3%%arg 2%" to player
					else:
						send formatted "<tooltip:&cEXAMPLE: &8/&6Tablist color &e%player% &ee>&c&lTry Again.. &8/&6Tablist color &8<&eplayer&8><reset> <tooltip:&9Minecraft Color Codes: &00&8, &11&8, &22&8, &33&8, &44&8, &55&8, &66&8, &77&8, &88&8, &99&8, &aa&8, &bb&8, &cc&8, &dd&8, &ee&8, &ff>&8<&ecolor-code&8><reset>"
				else:
					send formatted "<tooltip:&cEXAMPLE: &8/&6Tablist color &e%player% &ee>&c&lTry Again.. &8/&6Tablist color &8<&eplayer&8><reset> <tooltip:&9Minecraft Color Codes: &00&8, &11&8, &22&8, &33&8, &44&8, &55&8, &66&8, &77&8, &88&8, &99&8, &aa&8, &bb&8, &cc&8, &dd&8, &ee&8, &ff>&8<&ecolor-code&8><reset>"
		else:
			send "%yaml value "Settings.Server_Prefix" of "plugins/TablistManager/Config.yml"% &cSorry you do not have access to this!"