Skip to content

PlayerStat

youyihj edited this page Nov 22, 2022 · 2 revisions

PlayerStat

A PlayerStat represents a statistic field of players. See ZenUtilsPlayer for how to get or set value of a player's statistic value.

Importing the package

You'd better import the package to avoid errors and write script easier.

Class Name: mods.zenutils.PlayerStat

Getting a PlayerStat

These static methods are available for getting a PlayerStat.

Gets a basic stat (i.e. in general column). Call /ct stats command to get a list of all basic stats. PlayerStat.getBasicStat(String id)

The following methods are for items, blocks and entities.

  • PlayerStat.getBlockStats(IBlockDefinition block)
  • PlayerStat.getCraftStats(IItemDefinition item)
  • PlayerStat.getObjectUseStats(IItemDefinition item)
  • PlayerStat.getObjectBreakStats(IItemDefinition item)
  • PlayerStat.getObjectsPickedUpStats(IItemDefinition item)
  • PlayerStat.getDroppedObjectStats(IItemDefinition item)
  • PlayerStat.getKillEntityStats(IEntityDefinition entity)
  • PlayerStat.getKilledByEntityStats(IEntityDefinition entity)

Creating a PlayerStat

PlayerStat.create(String id, ITextComponent name, @Optional IStatFormatter formatter)

It is required to create a PlayerStat in game initialization. Creating a stat and putting it into a static variable is needed.

Parameters:

  • String id: The id of the PlayerStat
  • ITextComponent name: The name of the PlayerStat, shown in the Statistics menu
  • IStatFormatter formatter: How to display the stat amount, such as adding separator or converting to time format

ZenGetters

Name Type
name ITextComponent
Clone this wiki locally