Code Monkey home page Code Monkey logo

statisticslib's Introduction

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

statisticslib's People

Contributors

dehys avatar nikoci avatar overdodo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

statisticslib's Issues

Implement public API

Description:

Implement a public API that runs on our server. Users can select an option to disable registering their server to the public Database but what the API does is listens to GET and POST and talks to a public database where all servers are stored with all their statistics for each player. The API can be accessed through a class in the lib to get data from the public storage. This means that if you want to use StatisticsLib and display a players statistics on example a website, you can use the public API to get statistics from a Minecraft server. Every server would have a API token assigned to them so developers can use the API and the token to get a specific server. The data of every server on the public storage will not be 100% public.

By implementing this feature we allow projects to use a public registry of minecraft servers using StatisticsLib to get statistics of players. Let's say there is a website called "minecraft-statistics.com", To register your minecraft server to the website you need to use the StatisticsLib plugin on your server as well as provide the API token generated for your server to the website. Then BAM, all player statistics of your server can be accessed on the website. The server administrator would be able to configure what statistics not to show publicly in the configuration of the plugin.

This will also create a new world for developers to create new wrappers/libs to talk to the public API(/Registry)

Example Usage:

StatisticsLib.getPublicRegistry().getServer("API-TOKEN").getUser();

Classes:

  • PublicRegistry
  • RegistryUser
  • RegistryServer

PSA Object

Creating a object for getting the running instance of PlayerStatistics.
This will allow people using the API to utilize its functions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.