[Download][API] DBManager v1.2_0 | One config, all plugins!

DBManager is a plugin that allows server owners to save their database credentials in a single config file, that can be used by other plugins.

Idea by @The_Doctors_Life


If you're a server owner:

A config would look like this:
 database: <database>
 username: <username>
 password: <password>
 host: <host>
 port: <port>
 # wether it's a mysql database or not
 mysql: <true/false>

If you’d like to have plugin_x use another database, you have to specify that in exceptions.yml:

 plugin_x: plugin_x.yml

Now you’d have to create another file called plugin_x.yml:

 database: <database>
 username: <username>
 password: <password>
 host: <host>
 port: <port>
 # wether it's a mysql database or not
 mysql: <true/false>

…where you enter the data plugin_x needs.


If you're a developer

Let's say you have a plugin that would use my DBManager.jar as library. You would simply use the `DBManager` class to access the database. If your plugin uses a mysql database, you can simply get a connection object by writing this code:
DBManager dbManager = DBManager.getInstance();
Connection connection = dbManager.getConnection(plugin);

However, if your plugin does not use mysql, you have to establish the connection on your own.

DBManager dbManager = DBManager.getInstance();
String database = dbManager.getDatabase(plugin);
String username = dbManager.getUsername(plugin);
String password = dbManager.getPassword(plugin);
String host = dbManager.getHost(plugin);
int port = dbManager.getPort(plugin);

Download v1.2_0: Dropbox - Error
Download v1.2_0 (API): Dropbox - Error
GitHub: GitHub - MrMysteri0us/DBManager: A simple Sponge database-credential/data-manager.

3 Likes

Good one! I have a dream… all the plugins which uses MySQL DBs uses this API… Great!

3 Likes

@Cadiducho thanks for the kind words! Makes me feel warm. :blush:
Well, we just have to get this popular so the other plugin developers would risk a look onto the thread… :slight_smile:

1 Like

Probably i’m going to support this in Sponge.js for database connections: Spongejs · GitHub. Thanks for this!

1 Like

That’s nice, don’t worry about it using SnakeYAML right now, I’ll change it to HOCON/whatever once Sponge comes out, so remember to look at the GitHub regularly! :slight_smile:

1 Like

It was my Idea!

2 Likes

One second, I’ll mention you for this awesome idea. :slight_smile:

2 Likes

Awesome :smiley: Thanks :sunny:

1 Like

Looks good. But what if you want one plugin to have a different database? Maybe make a function that you can disable plugins from using this data.

2 Likes

All I say is… LOL. I’ll still watch your repo.

1 Like

Why laugh? its a brilliant idea.

2 Likes

I know… But it needs some serious fleshing out.

2 Likes

Give him/me some credit, it was created only today see Database manager? (DB Manager)

1 Like

This is nice, but somebody should make a tutorial on how to use MySQL.

1 Like

besides the idea is to make it so everytime you get a plugin that use MySQL or similar @RobiRami you have to put in the MySQL database details every time, this plugin provides a way for you to skip that step completely.

And what if they want to use a different database ?

Update: You can now define different config files for different plugins, if needed.

1 Like

I may will support this, definitely a good idea :smiley:

@Exstar you should use Nashorn, it’s up to 8 times faster than Rhino.

1 Like

If you can have an artifact depot for Maven and Javadoc, it cans be great.

I will look to use your plugin for database side of my plugins (Factoid by example).

Sorry for double post

An other suggestion for you: A central Database cache with usernames and UUID, because the problem in bukkit, every plugins have it own and it makes a lot of duplication.