Skip to content

Kittscloud/KittsPlayerAnalyticsSystem

Repository files navigation

KittsPlayerAnalyticsSystem

LabAPI Player Analytics Tool

License Downloads GitHub release GitHub stars GitHub issues

KittsPlayerAnalyticsSystem is a tool that tracks when players join, leave, etc for SCP Secret Laboratory using LabAPI.

Consider Supporting?

If you enjoy this project and would like to support future development, I would greatly appreciate it if you considered donating via my Ko-Fi.

NuGet Package

The NuGet Package offers easy intergation of this tool. You can find the NuGet Packages here:

How to use KittsPlayerAnalyticsSystem:

There are two options when it comes to installing KittsPlayerAnalyticsSystem, normal and MongoDB. The difference between the two is that normal stores everything in a .JSON and MongoDB stores everything in a Mongo database.

To install KittsPlayerAnalyticsSystem on your server, you will need:

  • Newtonsoft.Json v13.0.4 or later.
  • KittsPlayerAnalyticsSystem latest verion.

To install KittsPlayerAnalyticsSystem with MonogDB on your server, you will need:

  • DnsClient v1.6.1 or later.
  • Microsoft.Extensions.Logging.Abstractions v2.0.0 or later.
  • MognoDB.Bson v3.6.0 or later.
  • MongoDB.Driver v3.6.0 or later.
  • Newtonsoft.Json v13.0.4 or later.
  • KittsPlayerAnalyticsSystem latest verion.

All of these files can be found in the latest release.

Once you have these:

  • Place DnsClient.dll in the dependencies folder, if applicable.
  • Place Microsoft.Extensions.Logging.Abstractions.dll in the dependencies folder, if applicable.
  • Place MognoDB.Bson.dll in the dependencies folder, if applicable.
  • Place MognoDB.Driver.dll in the dependencies folder, if applicable.
  • Place Newtonsoft.Json.dll in the dependencies folder.
  • Place KittsInfractionSystem.dll in the plugins folder.

Run the server and you're set!

Configurations:

Parameter Type Description Default Value
IsEnabled bool Is plugin enabled. true
Debug bool Sends debug logs to console. false
MongoDBURI string MongoDB URI. "mongodb://username:password@ip:port/"
MongoDBName string MongoDB name. KittsPlayerAnalyticsSystem
MongoDBCollectionName string MongoDB collection name if using database. PlayerAnalyticsData
UseMongoDB bool Should save to MongoDB, saves to JSON if flase, does not migrate data. false
PlayerAnalyticsPermission string Permission for player analytics command. "kts.playeranalytics"

Default YML Config File

# Is plugin enabled
is_enabled: true
# Sends debug logs to console
debug: false
# Permission for player analytics command
player_analytics_permission: kts.playeranalytics

MongoDB YML Config File

# Is plugin enabled
is_enabled: true
# Sends debug logs to console
debug: false
# MongoDB URI
mongo_d_b_u_r_i: mongodb://username:password@ip:port/
# MongoDB name
mongo_d_b_name: KittsPlayerAnalyticsSystem
# MongoDB collection name
mongo_d_b_collection_name: PlayerAnalyticsData
# Permission for player analytics command
player_analytics_permission: kts.playeranalytics

Want to use in your own project?

To install in your project, simply reference the KittsPlayerAnalyticsSystem.dll file, found in the latest release.

KittsPlayerAnalyticsSystem.dll is mainly a tool and does not have much to offer when referencing, the most important part is the PlayerAnalyticAdded action which is called when an infraction is added.

PlayerAnalyticsManager Class

Parameter / Method Type / Return Type Description
PlayerAnalyticAdded Action<PlayerAnalyticData> Action called when an PlayerAnalyticData is added.
AddPlayerAnalytic(Player, PlayerAnalyticsType) void Adds a new PlayerAnalyticData to the database.
GetPlayerAnalytic(string) IReadOnlyList<PlayerAnalyticData> Gets a list of all PlayerAnalyticData.
GetPlayerAnalytics(TimePeriod) IReadOnlyList<PlayerAnalyticData> Gets a list of all PlayerAnalyticData matching the time period.
GetPrettyPlayerAnalytic(PlayerAnalyticData) string Gets a pretty string of target PlayerAnalyticData.
GetPrettyPlayerAnalytic(List<PlayerAnalyticData>) string Gets a pretty string from a list of PlayerAnalyticDatas.
GetPrettyPlayerAnalytic(TimePeriod, PlayerAnalyticsType) string Gets a pretty string of all analytics matching the time period and type.
GetPrettyPlayerAnalytic(TimePeriod) string Gets a pretty string of all analytics matching time period.
GetPrettyColouredPlayerAnalytic(PlayerAnalyticData) string Gets a pretty coloured string of target PlayerAnalyticData.
GetPrettyColouredPlayerAnalytics(List<PlayerAnalyticData>) string Gets a pretty coloured string from a list of PlayerAnalyticDatas.
GetPrettyColouredPlayerAnalytics(TimePeriod, PlayerAnalyticsType) string Gets a pretty coloured string of all PlayerAnalyticDatas matching the time period and type.
GetPrettyColouredPlayerAnalytics(TimePeriod) string Gets a pretty coloured string of all PlayerAnalyticDatas matching time period.

I have decided to not include an exmaple as it's VERY easy to use, just attach you own function to the action as shwon below

public void OnPlayerAnalyticAdded(PlayerAnalyticData data)
{
    // Do something when player analytic added
    // For exmaple you can log the data to the console
}

// Make sure to attach the function to the action somewhere
PlayerAnalyticsManager.PlayerAnalyticAdded += OnPlayerAnalyticAdded;

Found a bug or have feedback?

If you have found a bug please make an issue on GitHub or the quickest way is to message me on discord at kittscloud.

Also message me on discord if you have feedback for me, I'd appreciate it very much. Thank you!