Skip to content

Examples: Smart Action Bar

nova ✩ edited this page Aug 12, 2026 · 3 revisions

A smart action bar system that allows you to stack multiple elements

class SmartActionBar:
	public player: player
	public refreshRate: integer = 1

	private isActive: boolean = false
	private values: strings

	public static get(p: player) :: SmartActionBar instance:
		if {-smartActionBar::%{_p}%} is not set:
			set {-smartActionBar::%{_p}%} to new instance of SmartActionBar:
				player: {_p}
				refreshRate: 1

		return {-smartActionBar::%{_p}%}

	public play(value: string, duration: timespan):
		add {_value} to self::values

		if self::isActive is false:
			self::start()

		wait {_duration}
		remove {_value} from self::values

	public start():
		set self::isActive to true

		while self::isActive is true:
			if size of self::values is 0:
				exit loop

			set {_text} to join self::values with "&7 | &r"
			send action bar {_text} ? "" to self::player

			wait self::refreshRate*1 tick

		send action bar "" to self::player
		set self::isActive to false

	public stop():
		set self::isActive to false
		clear self::values
		

command /refreshRate <integer>:
	trigger:
		set SmartActionBar::get(player)::refreshRate to arg-1

command /actionBar <string> <timespan>:
	trigger:
		SmartActionBar::get(player)::play(arg-1, arg-2)

Clone this wiki locally