endstone.metrics

Modules

NameDescription
base
charts
config

Classes

classAdvancedBarChart

Bases: CustomChart

AdvancedBarChart(chart_id: str, get_values: Callable[[], Dict[str, List[int]] | None])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valuesCallable[[], Dict[str, List[int]] | None]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the advanced bar chart.

Attributes

NameTypeDescription
get_values

attrget_values

get_values

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the advanced bar chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

classAdvancedPie

Bases: CustomChart

AdvancedPie(chart_id: str, get_values: Callable[[], dict[str, int] | None])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valuesCallable[[], dict[str, int] | None]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the advanced pie chart.

Attributes

NameTypeDescription
get_values

attrget_values

get_values

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the advanced pie chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

classCustomChart

Bases: ABC

CustomChart(chart_id: str)

Represents a custom chart.

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required

Raises

TypeDescription
ValueError

If chart_id is None or empty.

Methods

NameDescription
get_chart_data

Gets the data for the chart.

Attributes

NameTypeDescription
chart_id

attrchart_id

chart_id

methget_chart_dataabstractmethod

get_chart_data() -> dict | None

Gets the data for the chart.

Returns

NameTypeDescription
dictdict | None

A dictionary with the chart data.

Raises

TypeDescription
Exception

If there is an error getting the chart data.

classDrilldownPie

Bases: CustomChart

DrilldownPie(chart_id: str, get_values: Callable[[], Dict[str, Dict[str, int]] | None])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valuesCallable[[], Dict[str, Dict[str, int]] | None]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the advanced pie chart.

Attributes

NameTypeDescription
get_values

attrget_values

get_values

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the advanced pie chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

classMetrics

Bases: MetricsBase

Metrics(plugin: Plugin, service_id: int)

Parameters

NameTypeDescriptionDefault
pluginPlugin

Your plugin instance.

required
service_idint

The id of the service. It can be found at https://bstats.org/what-is-my-plugin-id

required

Methods

NameDescription
append_platform_data

Appends platform-specific data to the provided dict.

append_service_data

Appends service-specific data to the provided dict.

log_error
log_info
submit_task

Attributes

attrenabledproperty

enabled: bool

attrservice_enabledproperty

service_enabled: bool

methappend_platform_data

append_platform_data(platform_data: Dict[str, Any]) -> None

Appends platform-specific data to the provided dict.

Parameters

NameTypeDescriptionDefault
platform_dataDict[str, Any]

The dict to append data to.

required

methappend_service_data

append_service_data(service_data: Dict[str, Any])

Appends service-specific data to the provided dict.

Parameters

NameTypeDescriptionDefault
service_dataDict[str, Any]

The dict to append data to.

required

methlog_error

log_error(message: str, exception: Exception) -> None

methlog_info

log_info(message: str) -> None

methsubmit_task

submit_task(task: Callable[[], None]) -> None

classMultiLineChart

Bases: CustomChart

MultiLineChart(chart_id: str, get_values: Callable[[], Dict[str, int] | None])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valuesCallable[[], Dict[str, int] | None]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the multi-line chart.

Attributes

NameTypeDescription
get_values

attrget_values

get_values

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the multi-line chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

classSimpleBarChart

Bases: CustomChart

SimpleBarChart(chart_id: str, get_values: Callable[[], Dict[str, int] | None])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valuesCallable[[], Dict[str, int] | None]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the simple bar chart.

Attributes

NameTypeDescription
get_values

attrget_values

get_values

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the simple bar chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

classSimplePie

Bases: CustomChart

SimplePie(chart_id: str, get_value: Callable[[], str | None])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valueCallable[[], str | None]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the simple pie chart.

Attributes

NameTypeDescription
get_value

attrget_value

get_value

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the simple pie chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

classSingleLineChart

Bases: CustomChart

SingleLineChart(chart_id: str, get_value: Callable[[], int])

Parameters

NameTypeDescriptionDefault
chart_idstr

The id of the chart.

required
get_valueCallable[[], int]

The callable which is used to request the chart data.

required

Methods

NameDescription
get_chart_data

Gets the data for the simple pie chart.

Attributes

NameTypeDescription
get_value

attrget_value

get_value

methget_chart_data

get_chart_data() -> dict | None

Gets the data for the simple pie chart.

Returns

TypeDescription
dict | None

dict | None: A dictionary with the chart data.

On this page