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!
- https://github.com/louis1234567890987654321/dm-api/wiki/Using-DataManagers
- https://github.com/louis1234567890987654321/dm-api/tree/master/DataManager-examples/MyKillCounter
Summary of API
- Create 2 classes that extends Data and DataLoader
- Use to generate a new data manager for your plugin
DataManager<[your data class name]>.generateDataManager("myPluginName",this,myDataLoader);
- Use to remove and save all your data.
DataManager.removeAndSaveDataManagers(this);
- The above functions are mostly used in onEnable and onDisable respectively
- Use to get data of a player.
myDataManager.getData("some_player_name")
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); } }
-
View User Profile
-
Send Message
Posted Apr 18, 2014the config for adding your sql is not that easy
Most configs say Database: and host
-
View User Profile
-
Send Message
Posted Jan 22, 2014@Gopaintman
Thanks!
-
View User Profile
-
Send Message
Posted Jan 20, 2014What an excellent plugin! I'd post this in the developmental resource section on the forums to get this idea out there. Makes Databases so much easier.
-
View User Profile
-
Send Message
Posted Jan 20, 2014Fixed bugs.
-
View User Profile
-
Send Message
Posted Jan 19, 2014@OriginalMadman
Yes I have some.
http://dev.bukkit.org/bukkit-plugins/votifier-count/ http://dev.bukkit.org/bukkit-plugins/first-login-plugin/
-
View User Profile
-
Send Message
Posted Jan 17, 2014This could be quite useful for plugins. Do you have a list of plugins supporting it?
-
View User Profile
-
Send Message
Posted Jan 5, 2014@CeramicTitan
This simplifies MySQL and other stuff. This plugin sorts datas if needed. If there is more than 1 plugin depending on this plugin on a single server and MySQL is enabled, the data could be saved by using only 1 connection, not several connections.
This plugin automatically chooses the saving method (configured by the owner of a server, must either be MySQL or flat files), so plugins don't have to create multiple configurations for that.
Using a HashMap and saving data either to a MySQL server or some files may be hard for new developers, and this plugin does 90% of it.
These are the main features of this plugin, and there are more to come!
-
View User Profile
-
Send Message
Posted Jan 4, 2014I don't understand the point of this? Couldn't you just use a simple hashmap?