Class StatisticsManager

java.lang.Object
com.minecolonies.core.colony.managers.StatisticsManager
All Implemented Interfaces:
IStatisticsManager

public class StatisticsManager extends Object implements IStatisticsManager
Manager for colony related statistics.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear all the statistics, this will remove all the entries from the map
    void
    deserialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
    Deserialize from bytebuf.
    @NotNull Set<Map.Entry<String,it.unimi.dsi.fastutil.ints.Int2IntLinkedOpenHashMap>>
    Gets all the current stat entries in this manager.
    int
    getStatsInPeriod(@NotNull String id, int startDay, int endDay)
    Get the number of occurrences in a given period.
    int
    getStatTotal(@NotNull String id)
    Get the total for a given stat,
    @NotNull Set<String>
    Getter for the whole stat list.
    void
    increment(@NotNull String id, int day)
    Increment a given statistic.
    void
    incrementBy(@NotNull String id, int qty, int day)
    Increment a given statistic by some quantity.
    void
    readFromNBT(@NotNull net.minecraft.nbt.CompoundTag compound)
    Reads the eventManager nbt and creates events from it
    void
    serialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, boolean fullSync)
    Serialize to bytebuf.
    void
    writeToNBT(@NotNull net.minecraft.nbt.CompoundTag compound)
    Write the eventmanager and all events to NBT

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StatisticsManager

      public StatisticsManager()
  • Method Details

    • increment

      public void increment(@NotNull @NotNull String id, int day)
      Description copied from interface: IStatisticsManager
      Increment a given statistic. Creates a new if it doesn't exist yet. Assigns a timestamp to the entry.
      Specified by:
      increment in interface IStatisticsManager
      Parameters:
      id - the id of the stat.
    • incrementBy

      public void incrementBy(@NotNull @NotNull String id, int qty, int day)
      Description copied from interface: IStatisticsManager
      Increment a given statistic by some quantity. Creates a new if it doesn't exist yet. Assigns a timestamp to the entry.
      Specified by:
      incrementBy in interface IStatisticsManager
      Parameters:
      id - the id of the stat.
      qty - the quantity.
    • getStatTotal

      public int getStatTotal(@NotNull @NotNull String id)
      Description copied from interface: IStatisticsManager
      Get the total for a given stat,
      Specified by:
      getStatTotal in interface IStatisticsManager
      Parameters:
      id - the id of the stat.
      Returns:
      the total since colony creation.
    • getStatsInPeriod

      public int getStatsInPeriod(@NotNull @NotNull String id, int startDay, int endDay)
      Description copied from interface: IStatisticsManager
      Get the number of occurrences in a given period.
      Specified by:
      getStatsInPeriod in interface IStatisticsManager
      Parameters:
      id - the id of the stat.
      startDay - the start day.
      endDay - the end day.
      Returns:
      the count.
    • getStatTypes

      @NotNull public @NotNull Set<String> getStatTypes()
      Description copied from interface: IStatisticsManager
      Getter for the whole stat list.
      Specified by:
      getStatTypes in interface IStatisticsManager
      Returns:
      the map of stats.
    • getStatEntries

      @NotNull public @NotNull Set<Map.Entry<String,it.unimi.dsi.fastutil.ints.Int2IntLinkedOpenHashMap>> getStatEntries()
      Gets all the current stat entries in this manager.
      Specified by:
      getStatEntries in interface IStatisticsManager
      Returns:
      a set of entries with the id and the stats map.
    • clear

      public void clear()
      Clear all the statistics, this will remove all the entries from the map
      Specified by:
      clear in interface IStatisticsManager
    • serialize

      public void serialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, boolean fullSync)
      Description copied from interface: IStatisticsManager
      Serialize to bytebuf.
      Specified by:
      serialize in interface IStatisticsManager
      Parameters:
      buf - the buffer to write to.
      fullSync -
    • deserialize

      public void deserialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
      Description copied from interface: IStatisticsManager
      Deserialize from bytebuf.
      Specified by:
      deserialize in interface IStatisticsManager
      Parameters:
      buf - the buffer to read from.
    • writeToNBT

      public void writeToNBT(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IStatisticsManager
      Write the eventmanager and all events to NBT
      Specified by:
      writeToNBT in interface IStatisticsManager
      Parameters:
      compound - the compound to write to.
    • readFromNBT

      public void readFromNBT(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IStatisticsManager
      Reads the eventManager nbt and creates events from it
      Specified by:
      readFromNBT in interface IStatisticsManager
      Parameters:
      compound - the compound to read from.