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:
	if plugin "skript-reflect" and "skript-yaml" and "Vault" is enabled:
		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} &c&oVisit the Config.yml to edit this!{newline}"
			set yaml value "Content.Footer" of "plugins/TablistManager/Config.yml" to "{nl}&e&lPlayers: &a{OnlinePlayers}/{MaxPlayers}, &7&oHello {player} {nl} &fTps: {Tps} &8| &fReal Time: {realtime} &r"
			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.1":
				send "&c&lUPDATE CHECKER &7You are running an old version of TablistManager %nl% &8(&cCurrent version: &c1.1&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
	else:
		send "&c&lADDON CHECKER &7You need the following Skript addons to run TablistManager: skript-reflect, skript-yaml and Vault" to console

on join:
	while player is online:
		if tps is bigger than 12:
			# TABLIST UPDATER
			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
			TlmHandler(player)

# TABLIST HANDLER
function TlmHandler(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
	load yml "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml" as "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml"
	if yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml" is not set:
		set yaml value "Data.Color" of "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml" to "§7"
		save yml "plugins/TablistManager/PlayerData/%uuid of {_p}%.yml"
	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 "{DisplayName}" or "{PlayerDisplayName}" with {_p}'s displayname 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 "{StaffOnline}" or "{OnlineStaff}" with "%number of all players where [input has permission "tablistmanager.staff"]%" 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}
	parse if plugin "CMI" or "Essentials" is enabled:
		replace all "{Money}" or "{Balance}" with "%{_p}'s balance%" 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:
				send formatted "&f%nl%&c▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ &c&lTablist Help&c ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬%nl%&f%nl%&6COMMAND OVERVIEW%nl%<tooltip:&b&oClick Here To Execute This Command><run command:/tablistmanager> &8➳ &e/Tablist &8, &7Shows this message. <reset>%nl%<sgt: /tablistmanager update> &8➳ &e/Tablist update <tooltip:&bExample: &7%player%>&8<&eplayer&8><reset> &8, &7Update the Tablist manually for a specific player. <reset>%nl%<sgt:/tablistmanager color> &8➳ &e/Tablist color <tooltip:&bExample: &7%player%>&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>&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%&f%nl%<tooltip:&ePlaceholders: &f{NewLine} &8| &f{Player} &8| &f{Displayname} &8| &f{Level} &8| &f{PlayerHealth} &8| &f{MaxPlayerHealth} &8| &f{FoodLevel} &8| &f{Coordinate} &8| &f{Gamemode} &8| &f{LightLevel} &8| &f{IpAddress} &8| &f{Timeplayed} &8| &f{World} &8| &f{WorldTime} &8| &f{OnlinePlayersInWorld} &8| &f{OnlinePlayers} &8| &f{StaffOnline} &8| &f{MaxPlayers} &8| &f{BukkitVersion} &8| &f{MinecraftVersion} &8| &f{Ping} &8| &f{Tps} &8| &f{ServerTime} &8| &f{Date} &8| &f{Motd} &8| &f{Money} &8➳ &cRequire Essentials or CMI >&6PLACEHOLDER HOVER LIST &8(&7Hover your mouse over here&8) <reset>%nl%&f%nl%&c▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ &c&lTablist Help&c ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬%nl%&f"
			if arg 1 is "update":
				set {_player} to arg 2
				if arg 2 is not set:
					set {_player} to player
				TlmHandler({_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 {_player} has permission "%yaml value "Settings.Admin_Permission" of "plugins/TablistManager/Config.yml"%"
				send action bar "&eT&6a&eb&6l&ei&6s&et &6U&ep&6d&ea&6t&ee&6d" to {_player}
			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!"