Skip to content

A library that makes storing and retrieving player statistics for players on a minecraft spigot server alot easier.

License

Notifications You must be signed in to change notification settings

nikoci/StatisticsLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StatisticsLib

Discord Releases Discord

Dependencies   |   Implementation   |   Getting Started  

StatisticsLib makes storing and retrieving player statistics for players on a spigot/bukkit server alot easier. At its core, it stores every statistic for every player ever joined on a server onto your desired sql database. It handles all tables, sql functions and queries. You wanted to see how many diamond axes you've broken? We got it. You can either choose to download it as a jar file or use it with maven

NOTE: Maven support is coming soon. We are currently waiting for our project to be accepted to Maven Central.



Dependencies



Implementation

Maven
<repositories>
  <repository>
    <id>StatisticsLib</id>
    <url>https://maven.devfalsk.com/repository/StatisticsLib/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.devfalsk.statisticslib</groupId>
    <artifactId>statisticslib</artifactId>
    <version>${project.version}</version>
  </dependency>
</dependencies>

Raw Jar file
  1. Download the latest jar file from here
  2. Add the jar file to your server's plugins folder
  3. Open your preferred IDE and add a new external jar file to the project structure
  4. Start coding!

Getting Started

Jump right in to using the your freshly added StatisticsLib!
Use this demo class to get started. More demo classes can also be found in demo.me.dehys.myplugin

public class MyPlugin extends JavaPlugin {

  private StatisticsLib lib;

  @Override
  public void onEnable() {
    super.onEnable();
    if (!setupStatisticsLib()) {
      getServer().getPluginManager().disablePlugin(this);
    }
  }

  /**
   * This method is used to fetch the active StatisticsLib instance from Bukkit's RegisteredServiceProvider
   *
   * @return true if an instance could be found, false if no instance could be found. In this case disable your statisticsPlugin.
   * You *need* the instance registered to the Provider, creating your own instance can lead to loss of data
   */
  private boolean setupStatisticsLib() {
    if (getServer().getPluginManager().getPlugin("StatisticsLib") == null) {
      return false;
    }
    RegisteredServiceProvider<StatisticsLib> serviceProvider = getServer().getServicesManager().getRegistration(StatisticsLib.class);
    if (serviceProvider == null) {
      return false;
    }
    lib = serviceProvider.getProvider();
    return true;
  }


  /**
   * Use this getter to access the StatisticsLib instance anywhere in your statisticsPlugin
   *
   * @return the active instance of StatisticsLib
   */
  public StatisticsLib getLib() {
    return lib;
  }


  /**
   * Use this getter to access the StatisticsManager instance.
   * The StatisticsManager provides all methods for handling statistics, most importantly, for retrieving them
   *
   * @return the active instance of StatisticsManager
   */
  public StatisticsManager getStatisticsManager() {
    return lib.getStatisticsManager();
  }
}


License

This project is under license from MIT. For more details, see the LICENSE file.

Made with ❤️ by dodo and dehys