class LeaderboardManager

Manages all leaderboard instances and their lifecycle.

Responsible for:

  • Storing active leaderboards
  • Loading and saving persistent data
  • Dispatching update events

Properties

protected Leaderboard> $leaderboards
protected Config $leaderboardData

Methods

__construct(TopStats $plugin)

No description

add(Leaderboard $leaderboard)

Add a leaderboard instance.

remove(int $id)

Remove a leaderboard by ID and destroy its model.

get(int $id)

Get a leaderboard by ID.

array
leaderboards()

Get all registered leaderboards.

array
getLeaderboardFromType(string $type)

Get all leaderboards matching a specific type.

bool
dispatchLeaderboardUpdate(string $type, array $data = [])

Dispatches a leaderboard update event for the specified type.

void
loadData()

Load leaderboard data from storage.

Config
getLeaderboardData()

Access the underlying leaderboard storage config.

void
saveData()

Save all leaderboard data to storage.

Details

at line 53
__construct(TopStats $plugin)

No description

Parameters

TopStats $plugin

at line 62
LeaderboardManager add(Leaderboard $leaderboard)

Add a leaderboard instance.

Parameters

Leaderboard $leaderboard

Return Value

LeaderboardManager

at line 70
LeaderboardManager remove(int $id)

Remove a leaderboard by ID and destroy its model.

Parameters

int $id

Return Value

LeaderboardManager

at line 85
Leaderboard|null get(int $id)

Get a leaderboard by ID.

Parameters

int $id

Return Value

Leaderboard|null

at line 94
array leaderboards()

Get all registered leaderboards.

Return Value

array

at line 104
array getLeaderboardFromType(string $type)

Get all leaderboards matching a specific type.

Parameters

string $type

Return Value

array

at line 123
bool dispatchLeaderboardUpdate(string $type, array $data = [])

Dispatches a leaderboard update event for the specified type.

This function retrieves all leaderboards that match the provided type, fires a {\Nicholass003\TopStats\Event\TopStatsUpdateEvent}, and updates each leaderboard unless the event is cancelled.

Parameters

string $type

The leaderboard type identifier (e.g., "block_break", "kills").

array $data

Optional external data used from other plugins.

Return Value

bool

at line 147
void loadData()

Load leaderboard data from storage.

Return Value

void

Exceptions

Exception

at line 173
Config getLeaderboardData()

Access the underlying leaderboard storage config.

Return Value

Config

at line 182
void saveData()

Save all leaderboard data to storage.

Also destroys associated models before saving.

Return Value

void