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.

on load:
	if plugin "skript-reflect" and "skript-yaml" and "Vault" is enabled:
		TlmConfigGenerator()
		send "&e&lTABLISTMANAGER &eWas loaded correctly &8(&cNO ERRORS&8).%nl%&a&lTABLISTMANAGER WIKI: &ehttps://jacobjoergensen.gitbook.io/tablistmanager/%nl%&a&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

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

on join:
	if player is operator:
		if yaml value "Settings.Server.Update_Checker" of "config" is true:
			if "%get version "https://raw.githubusercontent.com/JacobJoergensen/TablistManager/main/version.txt"%" is not "2.1":
				send "&c&lUPDATE CHECKER &7You are running an old version of TablistManager &8(&cCurrent version: &c2.1&8) - (&aLatest version: &a%get version "https://raw.githubusercontent.com/JacobJoergensen/TablistManager/main/version.txt"%&8) %nl% <link:https://github.com/JacobJoergensen/TablistManager/releases/latest><tooltip:Click here to download the latest version>&f&nDownload latest version<reset>%nl%"
	TlmReset(player)

on gamemode change:
	if yaml value "Settings.Player.Spectator_Hide" of "config" is true:
		hide player from all players if player's gamemode is spectator
		reveal player to all players if player's gamemode is not spectator

# CONFIG GENERATOR
function TlmConfigGenerator():
	load yaml "plugins/TablistManager/Config.yml" as "config"
	if yaml path "Content.Header" in "config" exists:
		set yaml value "Settings.Server.Server_Prefix" of "config" to yaml value "Settings.Server_Prefix" of "config"
		set yaml value "Settings.Server.Update_Checker" of "config" to yaml value "Settings.Update_Checker" of "config"
		set yaml value "Settings.Server.Admin_Permission" of "config" to yaml value "Settings.Admin_Permission" of "config"
		set yaml value "Settings.Server.Tps_Performance_Value" of "config" to 12
		set yaml value "Settings.Server.Update_Time" of "config" to yaml value "Settings.Update_Time" of "config"
		set yaml value "Settings.Player.Prefix" of "config" to yaml value "Settings.Prefix" of "config"
		set yaml value "Settings.Player.Suffix" of "config" to yaml value "Settings.Suffix" of "config"
		set yaml value "Settings.Player.Default_Tabname_Color" of "config" to "&7"
		set yaml value "Settings.Player.Spectator_Hide" of "config" to true
		set yaml value "Blacklisted.Enabled" of "config" to false
		set yaml list "Blacklisted.Worlds" of "config" to "test-world" and "blacklisted-world"
		set yaml value "Tablist.Header" of "config" to yaml value "Content.Header" of "config"
		set yaml value "Tablist.Footer" of "config" to yaml value "Content.Footer" of "config"

		delete yaml value "Settings.Server_Prefix" of "config"
		delete yaml value "Settings.Update_Checker" of "config"
		delete yaml value "Settings.Admin_Permission" of "config"
		delete yaml value "Settings.Prefix" of "config"
		delete yaml value "Settings.Suffix" of "config"
		delete yaml value "Settings.Update_Time" of "config"
		delete yaml value "Content.Header" of "config"
		delete yaml value "Content.Footer" of "config"
		delete yaml value "Content" of "config"
		save yaml "config"
		send "&4&lTABLISTMANAGER &eConverted old Config.yml to the new Config.yml format!" to console
	if yaml path "Tablist.Enabled" in "config" does not exist:
		set yaml value "Tablist.Enabled" of "config" to true
		save yaml "config"
		send "&4&lTABLISTMANAGER &eUpdated your config to match the latest change!" to console
	if yaml "config" is empty:
		set yaml value "Settings.Server.Server_Prefix" of "config" to "&6&lSERVER"
		set yaml value "Settings.Server.Update_Checker" of "config" to true
		set yaml value "Settings.Server.Admin_Permission" of "config" to "tablistmanager.admin"
		set yaml value "Settings.Server.Tps_Performance_Value" of "config" to 12
		set yaml value "Settings.Server.Update_Time" of "config" to 5
		set yaml value "Settings.Player.Prefix" of "config" to false
		set yaml value "Settings.Player.Suffix" of "config" to false
		set yaml value "Settings.Player.Default_Tabname_Color" of "config" to "&7"
		set yaml value "Settings.Player.Spectator_Hide" of "config" to true
		set yaml value "Blacklisted.Enabled" of "config" to false
		set yaml list "Blacklisted.Worlds" of "config" to "test-world" and "blacklisted-world"
		set yaml value "Tablist.Enabled" of "config" to true
		set yaml value "Tablist.Header" of "config" to "&d&lWelcome To My Server {newline} &c&oVisit the Config.yml to edit this!{newline}"
		set yaml value "Tablist.Footer" of "config" to "{nl}&e&lPlayers: &a{OnlinePlayers}/{MaxPlayers}, &7&oHello {player} {nl} &fTps: {Tps} &8| &fReal Time: {realtime} &r"
		save yaml "config"
		send "&4&lTABLISTMANAGER &eA new Config.yml was created!" to console

# TABLIST HANDLER
function TlmHandler(p: player, w: world):
	if {_p} does not have metadata value "tablist":
		while {_p} is online:
			set metadata value "tablist" of {_p} to true
			TlmConfigGenerator()

			if tps is bigger than "%yaml value "Settings.Server.Tps_Performance_Value" of "config"%" parsed as number:
				wait "%yaml value "Settings.Server.Update_Time" of "config"% seconds" parsed as timespan

				if yaml value "Tablist.Enabled" of "config" is false:
					set {_access} to false
					TlmReset({_p})

				if yaml value "Blacklisted.Enabled" of "config" is true:
					loop yaml list "Blacklisted.Worlds" of "config":
						if "%loop-val%" parsed as world = {_w}:
							set {_access} to false
							TlmReset({_p})

				if {_access} is not false:
					set all players' tab list header to TlmPlaceholders("%yaml value "Tablist.Header" of "config"%", {_p})
					set all players' tab list footer to TlmPlaceholders("%yaml value "Tablist.Footer" of "config"%", {_p})
					load yaml "plugins/TablistManager/Players.yml" as "players"
					if yaml value "%uuid of {_p}%.tabname" of "players" is not set:
						set yaml value "%uuid of {_p}%.tabname" of "players" to "%yaml value "Settings.Player.Default_Tabname_Color" of "config"%%{_p}%"
						save yaml "players"

					set {_prefix} to "%{_p}'s prefix% " if yaml value "Settings.Player.Prefix" of "config" is true
					set {_prefix} to "" if yaml value "Settings.Player.Prefix" of "config" is false
					set {_suffix} to " %{_p}'s suffix%" if yaml value "Settings.Player.Suffix" of "config" is true
					set {_suffix} to "" if yaml value "Settings.Player.Suffix" of "config" is false

					set {_tabName} to yaml value "%uuid of {_p}%.tabname" of "players"
					set {_p}'s tab list name to "%{_prefix}%%{_tabName}%%{_suffix}%"

# TABLIST RESETTER
function TlmReset(p: player):
	delete metadata value "tablist" of {_p}
	reset players' tab list header
	reset players' tab list footer
	set {_p}'s tab list name to "&7%{_p}'s displayname%"
	TlmHandler({_p}, world of {_p})

# PLACEHOLDERS
function TlmPlaceholders(s: string, p: player) returns 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 "{ActiveItem}" or "{CurrentItem}" with "%{_p}'s tool%" 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}
	set {_worldTime} to time in world "%{_p}'s world%"
	replace all "{WorldTime}" or "{WTime}" with "%{_worldTime}%" in {_s}
	set {_onlinePlayersWorld} to amount of all players in world "%{_p}'s world%"
	replace all "{OnlinePlayersInWorld}" or "{WorldOnline}" or "{Opiw}" with "%{_onlinePlayersWorld}%" in {_s}
	replace all "{Online}" or "{OnlinePlayers}" with "%number of all players%" in {_s}
	replace all "{NonStaffOnline}" with "%number of all players - number of all players where [input has permission "tablistmanager.staff"]%" 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}
	replace all "{FreeMemory}" or "{FreeRam}" with "%free memory%" in {_s}
	replace all "{MaxMemory}" or "{MaxRam}" with "%max memory%" in {_s}
	replace all "{TotalMemory}" or "{TotalRam}" with "%total memory%" in {_s}
	parse if plugin "GroupManager" or "LuckPerms" or "PermissionsEx" or "UltraPermissions" is enabled:
		replace all "{Group}" or "{Rank}" with group of {_p} 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, tablistmanager, tablist-manager, tab, tabm, tlm
	trigger:
		if player has permission "%yaml value "Settings.Server.Admin_Permission" of "config"%":
			execute player command "/tablist" if arg 1 is "help"
			if arg 1 is not set:
				send formatted "&f%nl%&c▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ &c&lTablistManager&c ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬%nl%&f%nl%&6COMMAND OVERVIEW%nl%<tooltip:&b&oClick Here To Execute This Command><run command:/tablist> &8➳ &e/Tablist &8, &7Shows this message. <reset>%nl%<sgt:/tablist update> &8➳ &e/Tablist update <tooltip:&bExample: &7%name of player%%nl%&cPriority: optional>&8<&eplayer&8><reset> &8, &7Update the Tablist manually for a specific player. <reset>%nl%<tooltip:&b&oClick Here To Execute This Command><run command:/tablist> &8➳ &e/Tablist toggle &8, &7Toggle the Tablist on and off.<reset>%nl%<sgt:/tablist tabname %name of player% &&7%name of player%> &8➳ &e/Tablist tabname <tooltip:&bExample: &7%name of player%>&8<&eplayer&8> <tooltip:&bExample: &c&&cc%name of player%>&8<&etabname&8> <reset>&8, &7Change the tabname of a specific player.<reset>%nl%<tooltip:&b&oClick Here To Execute This Command><run command:/tablist 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{ActiveItem} &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{NonStaffOnline} &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{FreeMemory} &8| &f{MaxMemory} &8| &f{TotalMemory} %nl%&f%nl%&f{Group} &8➳ &cRequire GroupManager, Luckperms, PermissionEx or UltraPermissions %nl%&f{Money} &8➳ &cRequire CMI or Essentials >&6PLACEHOLDER HOVER LIST &8(&7Hover your mouse over here&8) <reset>%nl%&f%nl%&c▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ &c&lTablistManager&c ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬%nl%&f"
			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://jacobjoergensen.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 "toggle":
				if yaml value "Tablist.Enabled" of "config" is true:
					set yaml value "Tablist.Enabled" of "config" to false
					send action bar "&cTablist was disabled!"
				else if yaml value "Tablist.Enabled" of "config" is false:
					set yaml value "Tablist.Enabled" of "config" to true
					send action bar "&aTablist was enabled!"
				save yaml "config"

			set {_player} to arg 2 if arg 2 is set
			set {_player} to player if arg 2 is not set

			if arg 1 is "update":
				TlmReset({_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 "config"%"
				send action bar "&eT&6a&eb&6l&ei&6s&et &6U&ep&6d&ea&6t&ee&6d" to {_player}
			if arg 1 is "tabname" or "name":
				if arg 3 is set:
					set {_value} to arg 3
					set {_value} to "%yaml value "Settings.Player.Default_Tabname_Color" of "config"%%{_player}%" if {_value} is "reset" or "default"
					set yaml value "%uuid of {_player}%.tabname" of "players" to "%{_value}%"
					save yaml "players"
					send formatted "&f%nl%&2&lEDIT: &aYou have changed &2%{_player}%'s&a TabName design,%nl% <tooltip:&b&oClick here to edit TabName for %{_player}%><sgt:/tablist tabname %{_player}%>&8(&c&lPREVIEW: %{_value}%&8)<reset>%nl%&f" to player
					play sound "block.anvil.use" with volume 2 to {_player}
				else:
					send formatted "%yaml value "Settings.Server.Server_Prefix" of "config"% <tooltip:&b&oClick here to try again><sgt:/tablist tabname %{_player}%>&cYou must enter your new tab name!<reset>"
		else:
			send "%yaml value "Settings.Server.Server_Prefix" of "config"% &cSorry you do not have access to this!"