forked from ldtteam/minecolonies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to track statistics in a colony Add a few statistics to some jobs Add display to the townhall UI
- Loading branch information
Showing
29 changed files
with
431 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/api/java/com/minecolonies/api/colony/managers/interfaces/IStatisticsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.minecolonies.api.colony.managers.interfaces; | ||
|
||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Interface for the statistics manager | ||
*/ | ||
public interface IStatisticsManager | ||
{ | ||
/** | ||
* Increment a given statistic. | ||
* Creates a new if it doesn't exist yet. | ||
* Assigns a timestamp to the entry. | ||
* @param id the id of the stat. | ||
*/ | ||
void increment(@NotNull final String id); | ||
|
||
/** | ||
* Increment a given statistic by some quantity. | ||
* Creates a new if it doesn't exist yet. | ||
* Assigns a timestamp to the entry. | ||
* @param id the id of the stat. | ||
* @param qty the quantity. | ||
*/ | ||
void incrementBy(@NotNull String id, final int qty); | ||
|
||
/** | ||
* Get the total for a given stat, | ||
* @param id the id of the stat. | ||
* @return the total since colony creation. | ||
*/ | ||
int getStatTotal(@NotNull String id); | ||
|
||
/** | ||
* Get the number of occurrences in a given period. | ||
* @param id the id of the stat. | ||
* @param dayStart the start day. | ||
* @param dayEnd the end day. | ||
* @return the count. | ||
*/ | ||
int getStatsInPeriod(@NotNull String id, final int dayStart, final int dayEnd); | ||
|
||
/** | ||
* Serialize to bytebuf. | ||
* @param buf the buffer to write to. | ||
*/ | ||
void serialize(@NotNull final FriendlyByteBuf buf); | ||
|
||
/** | ||
* Deserialize from bytebuf. | ||
* @param buf the buffer to read from. | ||
*/ | ||
void deserialize(@NotNull final FriendlyByteBuf buf); | ||
|
||
/** | ||
* Reads the eventManager nbt and creates events from it | ||
* | ||
* @param compound the compound to read from. | ||
*/ | ||
void readFromNBT(@NotNull final CompoundTag compound); | ||
|
||
/** | ||
* Write the eventmanager and all events to NBT | ||
* | ||
* @param compound the compound to write to. | ||
*/ | ||
void writeToNBT(@NotNull final CompoundTag compound); | ||
|
||
/** | ||
* Getter for the whole stat list. | ||
* @return the map of stats. | ||
*/ | ||
@NotNull | ||
Set<String> getStatTypes(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/api/java/com/minecolonies/api/util/constant/StatisticsConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.minecolonies.api.util.constant; | ||
|
||
/** | ||
* Constants regarding stats. | ||
*/ | ||
public final class StatisticsConstants | ||
{ | ||
public static final String TREE_CUT = "trees_cut"; | ||
public static final String DEATH = "death"; | ||
public static final String BIRTH = "birth"; | ||
public static final String ORES_MINED = "ores_mined"; | ||
public static final String BLOCKS_MINED = "blocks_mined"; | ||
public static final String BLOCKS_PLACED = "blocks_placed"; | ||
public static final String MOBS_KILLED = "mobs_killed"; | ||
public static final String ITEMS_DELIVERED = "items_delivered"; | ||
public static final String ITEMS_CRAFTED = "items_crafted"; | ||
public static final String FOOD_SERVED = "food_served"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.