Skip to content

Plugin to connect to MongoDB. Uses Jackson to easily work with POJO's

License

Notifications You must be signed in to change notification settings

ItsKev/persistence-framework

Repository files navigation

PersistenceFramework

The plugin sets up a connection to a MongoDB. With the help of Jackson its able to store and work with POJO's directly.

An example can be found in the tests here.

Usage

Gradle

repositories {
    maven(url = "https://jitpack.io")
}

dependencies {
    implementation("com.github.ItsKev.persistence-framework:persistence-framework-proxy:v1.0.0:all")
}

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.github.ItsKev.persistence-framework</groupId>
  <artifactId>persistence-framework-bukkit</artifactId>
  <version>v1.0.0</version>
  <classifier>all</classifier>
</dependency>

Environment variables

Name Description
CONNECTION_STRING The connection string for MongoDB. Examples can be found here.
AUTHENTICATION_DATABASE The database where the user is stored. (e.g. admin)
USERNAME The username which the login is done with
PASSWORD The password to the given username

Bukkit (Spigot, Paper)

Getting an instance of the MongoDbService is done over the ServicesManager from Bukkit itself. This is done to prevent opening multiple connections to the MongoDB.

MongoDbService mongoDbService = getServer().getServicesManager().load(MongoDbService.class);

Proxy (Waterfall, Bungeecord)

To get an instance of the MongoDbService you have to get an instance of the PersistenceFrameworkPlugin first and get the MongoDbService from there.

PersistenceFrameworkPlugin persistenceFrameworkPlugin =
    (PersistenceFrameworkPlugin) getProxy().getPluginManager().getPlugin("PersistenceFramework");
MongoDbService mongoDbService = persistenceFrameworkPlugin.getMongoDbService();