Skip to content

3 Project

HydraheadHunter edited this page Jan 18, 2025 · 6 revisions

Project is the sixth and final mood of The statistics command which itself has six sub-moods. It allows for a player's stats to be tracked during a time-window (or under certain conditions given datapack execute if predicate), descretely from their over-all stats.

The project mood has six submoods: List, start, pause, stop, query, and store.

statistics project [mood] [@p] [? project name | all] [? stat type] [? stat] [? scoreboard objective]

Arguments

Project always takes player target(s) as an argument. Depending on the mood, it can also take a project name, stat type, stat, or scoreboard objective.

Project Name

Project name is a single minecraft word consisting of the characters [a-z], [A-Z], [0-9], and [ .| _ | - | + ]. In all use-cases, the word is sanitized internally by replacing periods (.) with underscores (_). It serves as the name of the project directory.

Reserved strings

The following strings have been reserved for functionality and cannot be project names:

  • all

Function

The function of project depends on which of it's six moods is being executed.

List

statistics project list [@p]

List takes no additional arguments.

For each target, it provides feedback in the form of a list of that player's active and paused projects.

Start

statistics project start [@p] [project name]

Start takes a project name an additional argument.

Starting a project for the first time creates the project directory with the project name. In single-player worlds, the directory will be located at the ./saves/[world name]/stats/[project name]. On servers, it will be located at ./[world name]/stats/[project name].

Once the project directory is created, or if it already exists, it will attempt to add the target players to that project by putting a project ServerStatHandler inside their ServerStatHandler so that the server can save stats while it saves stats.

If the player's was an inactive participant in the project, the ServerStatHandler will be moved from the paused list of ServerStatHandlers to the active list of ServerStatHandlers.

The function returns the total number of players who were not already active participants in the project, or -1 if no players were added or an error (such as using a reserved string as a project name) occurred.

Pause

statistics project pause [@p] [project name | all]

Pause takes a project name as an additional argument. Alternatively, it can also take all in place of a project name.

Pause functions identitically to Start, execept the project's ServerStatHandler is added to a list of inactive StatHandlers where it can be referenced by other commands but doesnot receive updates, pausing the projects stats from incramenting.

All

Pause All is an alternate execution mood for the pause mood, accessed by typing all in place of a project name. Pause All will, for each target player, pause each active project they are participating in.

Pause All returns the sum number of all projects paused across all targets.

Stop

statistics project stop [@p] [project name | all]

Stop takes a project name as an additional argument. Alternatively, it can take all in place of a project name.

Stop attempts to remove an active or inactive project ServerStatHandler from each target player. This stops the project for those player, making it impossible for the project to be referenced by other commands. Notable, this doesnot delete the project's .jsons: it merely makes their data inaccessable via command.

Stop returns the number of players who were active or inactive participants in the projects, which it stopped, or -1 if none.

All

Stop All is an alternate execution mood for the stop mood, accessed by typing all in place of a project name. Stop All will, for each target player, stop each active and inactive project they are participating in.

Query

statistics project query [@p] [stat type] [stat]

Project Query functions identically to Query, providing the requested stat value as feedback, except it reads that value from the player's project stats instead of their overall stats and the unit argument have not yet been implemented.

To successfully query a project, a player must be an active or inactive participant in that project. If the project was stopped for them, or the project doesn't exist, the function will fail to find the stat value. If it fails to find the stat value in this way for all players, the function returns -1.

Store

statistics project store [@p] [stat type] [stat] [scoreboard objective]

Project Store functions identitcally to Store, except it reads and writes from the player's project stats instead of the player's over-all stats, and the unit argument has not yet been implemented.

To successfully store from a project, a player must be an active or inactive participant in that project. If the project was stopped for them, or the project doesn't exist, the function will fail to find the stat value. If it fails to find the stat value in this way for all players, the function returns -1.

Clone this wiki locally