promotional bannermobile promotional banner

DataManagerAPI

DataManagerAPI

DataManagerAPI

Overview

DataManagerAPI is a library for plugins that needs to save data that is associated with players (such as kills, deaths, wins of games and much more)! This plugin supports MySQL.

Installation , Commands and Permissions

API

The API is for developers who want to use features of this library. Read the following for more info!

Summary of API

  • Create 2 classes that extends Data and DataLoader
  • Use
    DataManager<[your data class name]>.generateDataManager("myPluginName",this,myDataLoader);
    
    to generate a new data manager for your plugin
  • Use
    DataManager.removeAndSaveDataManagers(this);
    
    to remove and save all your data.
  • The above functions are mostly used in onEnable and onDisable respectively
  • Use
    myDataManager.getData("some_player_name")
    
    to get data of a player.

Here is an example of an implementation of DataManagerAPI. For a better example please read this.

public class MyPointsPlugin extends JavaPlugin{
    DataManager<XX> dm;
    public void onEnable(){
        XXLoader myLoader = new XXLoader();
        dm = DataManager<XX>.generateNewDataManager("MyPointsPlugin", this, myLoader);
    }

    public void onDisable(){
        DataManager.removeAndSaveDataManagers(this);
    }

    public boolean onCommand(CommandSender s,Command c,String lbl,String[]args){
        if(c.equalsIgnoreCase("points")){
            s.sendMessage("Points:"+dm.getData(s.getName()).points);
        }else if(c.equalsIgnoreCase("givepoints")){
            if(s.isOp()){
                XX data = DataManager.getData(args[0]);
                data.points=Integer.parseInt(args[1]);
                dm.forceSave(data);
            }
        }
    }
}

class XX extends Data{
    int points;
    XX(DataManager<XX>manager,Player p,JavaPlugin plug){super(manager,p,plug);
        points=0;
    }
    public void onSave(){
        set("points",points);
    }
}
class XXLoader extends DataLoader<XX>{
    @Override
    protected XX loadData(Player p, JavaPlugin plugin) {
        int points=getInt("points",0);
        XX data=new XX(getDataManager(),p,plugin);
        XX.points=points;
        return data;
    }

    @Override
    protected XX getNewData(Player p, JavaPlugin plugin) {
        return new XX(getDataManager(),p,plugin);
    }
}

The DataManagerAPI Team

profile avatar
  • 8
    Projects
  • 135.1K
    Downloads

More from _ForgeUser10335832View all

  • TeamPlugin project image

    TeamPlugin

    • 61.4K
    • Bukkit Plugins

    This plugin allows users in kitpvp servers to create teams.

    • 61.4K
    • July 7, 2014
    • Bukkit Plugins
    • +1
  • Kits Preview project image

    Kits Preview

    • 48.3K
    • Bukkit Plugins

    Want to preview donor kits or in-game kits before purchasing ranks or buying kits? This is the plugin for your server!

    • 48.3K
    • February 20, 2014
    • Bukkit Plugins
    • +1
  • Votifier Count project image

    Votifier Count

    • 8.3K
    • Bukkit Plugins

    This plugin logs user's votes and displays them.

    • 8.3K
    • January 20, 2014
    • Bukkit Plugins
  • CoolLoginRewards project image

    CoolLoginRewards

    • 2.0K
    • Bukkit Plugins

    give rewards to the first player who logins after a server reboot

    • 2.0K
    • January 6, 2014
    • Bukkit Plugins
  • TeamPlugin project image

    TeamPlugin

    • 61.4K
    • Bukkit Plugins

    This plugin allows users in kitpvp servers to create teams.

    • 61.4K
    • July 7, 2014
    • Bukkit Plugins
    • +1
  • Kits Preview project image

    Kits Preview

    • 48.3K
    • Bukkit Plugins

    Want to preview donor kits or in-game kits before purchasing ranks or buying kits? This is the plugin for your server!

    • 48.3K
    • February 20, 2014
    • Bukkit Plugins
    • +1
  • Votifier Count project image

    Votifier Count

    • 8.3K
    • Bukkit Plugins

    This plugin logs user's votes and displays them.

    • 8.3K
    • January 20, 2014
    • Bukkit Plugins
  • CoolLoginRewards project image

    CoolLoginRewards

    • 2.0K
    • Bukkit Plugins

    give rewards to the first player who logins after a server reboot

    • 2.0K
    • January 6, 2014
    • Bukkit Plugins