Compatibility
Minecraft: Java Edition
1.21–1.21.1
1.20.x
Platforms
Paper
Supported environments
75% of ad revenue goes to creators
Support creators and Modrinth ad-free with Modrinth+Creators
Details
Licensed CC-BY-NC-ND-4.0
Published 4 months ago
Updated 3 months ago
Knowledge Book - Your go-to database plugin.
An extremely lightweight plugin that allows developers to seamlessly convert java classes into mongo documents.
This plugin is made for Java Developers who are looking to use MongoDB as their database storage rather than local yml files.
Donations
Lead among other various plugins I have worked on are free to use! Please consider donating to my ko-fi! It helps fund other projects that I am passionate about.
How it works
Knowledge Book uses https://mongojack.org/ as its main api to help convert java classes to mongo documents. All Knowledge Book does is allow developers to seamlessly integrate this into your plugins.
As an example, you can convert a Java Class into a MongoDB document.
package to.lodestone.example.data;
import com.fasterxml.jackson.annotation.JsonProperty;
import to.lodestone.knowledgebook.annotation.Collection;
@Collection(name = "person_collection")
public class Person {
@JsonProperty("fullName")
private String fullName;
@JsonProperty("socialSecurityNumber")
private String socialSecurityNumber;
// For Knowledge Book to initialize an empty object to use getters and setters.
public Person() {
}
public Person(String fullName, String socialSecurityNumber) {
this.fullName = fullName;
this.socialSecurityNumber = socialSecurityNumber;
}
@JsonProperty("fullName")
public void setFullName(String fullName) {
this.fullName = fullName;
}
@JsonProperty("fullName")
public String getFullName() {
return fullName;
}
@JsonProperty("socialSecurityNumber")
public void setSocialSecurityNumber(String socialSecurityNumber) {
this.socialSecurityNumber = socialSecurityNumber;
}
@JsonProperty("socialSecurityNumber")
public String getSocialSecurityNumber() {
return socialSecurityNumber;
}
}
How to use Knowledge Book in your plugin:
package to.lodestone.example;
import org.bukkit.plugin.java.JavaPlugin;
import org.mongojack.JacksonMongoCollection;
import to.lodestone.conquest.data.Person;
import to.lodestone.knowledgebook.IKnowledgeBookAPI;
import to.lodestone.knowledgebook.KBHook;
public class TestPlugin extends JavaPlugin {
private KBHook kbHook;
@Override
public void onEnable() {
this.kbHook = new KBHook(this);
JacksonMongoCollection<Person> personCollection = this.kbHook.api().getOrCreateCollection(Person.class);
personCollection.insertOne(new Person("John Doe", "4355678656"));
}
public IKnowledgeBookAPI db() {
return kbHook.api();
}
}
Once you've started up your server, it will create a collection called person_collection
with a new Person document with all of the data you've provided.
Remember to set your variables with the correct values in order for Knowledge Book to properly function within the "config.yml" file!
database: null
connectionString: null