Class CustomStat
java.lang.Object
com.thecsdev.commonmc.api.stats.util.SubjectStats<net.minecraft.resources.Identifier>
com.thecsdev.commonmc.api.stats.util.CustomStat
SubjectStats utility implementation for reading statistics
about a given "General" (also known as "Custom") stat.-
Constructor Summary
ConstructorsConstructorDescriptionCustomStat(@NotNull net.minecraft.resources.Identifier subject, @NotNull IStatsProvider statsProvider) -
Method Summary
Modifier and TypeMethodDescriptionstatic final Collection<CustomStat> getCustomStats(@NotNull IStatsProvider statsProvider, @Nullable Predicate<CustomStat> predicate, @Nullable Comparator<CustomStat> comparator) Obtains a list of allCustomStat.final @NotNull net.minecraft.network.chat.ComponentReturns the in-game display name of theSubjectStats.getSubject().final intgetValue()Returns the raw (unformatted) numeric value of the "General" stat.final @NotNull StringReturnsgetValue()formatted usingStat.format(int).final @NotNull StringgetValueF(@Nullable StatFormatterOverride formatter) ReturnsgetValue()formatted using a custom formatter.final @NotNull LinkedHashMap<net.minecraft.stats.Stat<net.minecraft.resources.Identifier>, Integer> Returns all the statistics about theSubjectStats.getSubject().final booleanfinal booleanfinal booleanisEmpty()final booleanisTime()Methods inherited from class SubjectStats
equals, getStatsProvider, getSubject, getSubjectID, getValuesF, getValuesF, hashCode, isSearchMatch
-
Constructor Details
-
CustomStat
public CustomStat(@NotNull @NotNull net.minecraft.resources.Identifier subject, @NotNull @NotNull IStatsProvider statsProvider) throws NullPointerException, IllegalStateException - Throws:
NullPointerException- If an argument isnull.IllegalStateException- If the subject is not properly registered in the game's registries.
-
-
Method Details
-
getSubjectDisplayName
@NotNull public final @NotNull net.minecraft.network.chat.Component getSubjectDisplayName()Description copied from class:SubjectStatsReturns the in-game display name of theSubjectStats.getSubject().- Specified by:
getSubjectDisplayNamein classSubjectStats<net.minecraft.resources.Identifier>
-
getValues
@NotNull public final @NotNull LinkedHashMap<net.minecraft.stats.Stat<net.minecraft.resources.Identifier>, Integer> getValues()Description copied from class:SubjectStatsReturns all the statistics about theSubjectStats.getSubject().- Specified by:
getValuesin classSubjectStats<net.minecraft.resources.Identifier>
-
isEmpty
public final boolean isEmpty()Description copied from class:SubjectStats- Overrides:
isEmptyin classSubjectStats<net.minecraft.resources.Identifier>
-
getValue
public final int getValue()Returns the raw (unformatted) numeric value of the "General" stat. -
getValueF
ReturnsgetValue()formatted usingStat.format(int). -
getValueF
@NotNull public final @NotNull String getValueF(@Nullable @Nullable StatFormatterOverride formatter) ReturnsgetValue()formatted using a custom formatter.- Parameters:
formatter- TheStatFormatterOverrideto use. Ifnull, the default one is used.
-
isDistance
public final boolean isDistance() -
isTime
public final boolean isTime() -
isDivideBy10
public final boolean isDivideBy10() -
getCustomStats
public static final Collection<CustomStat> getCustomStats(@NotNull @NotNull IStatsProvider statsProvider, @Nullable @Nullable Predicate<CustomStat> predicate, @Nullable @Nullable Comparator<CustomStat> comparator) throws NullPointerException Obtains a list of allCustomStat.- Parameters:
statsProvider- TheIStatsProviderinstance.predicate- An optionalPredicatefor filtering the stats.comparator- An optionalComparatorfor sorting the list.- Throws:
NullPointerException- If aNotNullargument isnull.
-