API

Jul 19, 2019
API

  • Providing statistics(top)

    If you have a plugin that you want to use to provide statistics for the only thing you have to do is register a placeholder that shows the thing you want to create a statistic for.

    For performance reasons it is better to register it directly in MVdWPlaceholderAPI. This immediately also opens those placeholders for other plugins such as FeatherBoad, AnimatedNames and many more. However, if you desire you can add the placeholders to PlaceholderAPI.

    Users will then be able to use your placeholder to provide statistics.

    Adding statistics(top)

    Manually adding statistics is possible but should not be done without the users consent (config).

    Getting statistics(top)


    Getting a statistic based on its name(top)

    If you know the name of the statistic (e.g. "kills") you can use the following method to get the instance of the statistic. This is the statistic with the configured settings. It contains all information that you would find in the YML file where it was configured.

    Code (Java):
    import be.maximvdw.leaders.api.LeadersAPI;
    import be.maximvdw.leaders.api.Statistic;
    ...
    LeadersAPI leadersAPI = (LeadersAPI) Bukkit.getPluginManager().getPlugin("Leaders");
    Statistic statistic = leadersAPI.getStatisticByName("kills");

    Getting all registered statistics(top)

    If you do not know the name of the statistic or you want to know all registered/used statistics you can use the following method to get all instances.

    Code (Java):
    import be.maximvdw.leaders.api.LeadersAPI;
    import be.maximvdw.leaders.api.Statistic;
    ...
    LeadersAPI leadersAPI = (LeadersAPI) Bukkit.getPluginManager().getPlugin("Leaders");
    List<Statistic> statistics = leadersAPI.getRegisteredStatistics();

    Getting the top players for a statistic(top)

    Once you have an instance of the statistic that you want information for, you can use it to get the top players.
    The API will return a Future. This thread-safe callable

    Creating modules(top)

    Modules are small non-plugin pieces of code that are loaded by the Leaders plugin. They have the same interaction with the API as your own plugins so you don't need to make it a separated module.

    However, modules can be useful if you want to access the API of Leaders without making it a separate plugin.
  • Loading...
  • Loading...