Knowledge Book has been archived. Knowledge Book will not receive any further updates unless the author decides to unarchive the project.

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.

Knowledge Book quick preview

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.

ko-fi

https://ko-fi.com/apollo30

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 gg.lode.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 gg.lode.example.data.Person;
import to.lodestone.knowledgebook.IKnowledgeBookAPI;
import to.lodestone.knowledgebook.KnowledgeBookAPI;

public class TestPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        JacksonMongoCollection<Person> personCollection = this.kbHook.api().getOrCreateCollection(Person.class);
        personCollection.insertOne(new Person("John Doe", "4355678656"));
    }

    public IKnowledgeBookAPI knowledgeBook() {
        return KnowledgeBookAPI.getApi();
    }
}

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.

Knowledge Book at work

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

Project members

Lodestone

Lodestone

Organization

Details

Licensed CC-BY-NC-ND-4.0
Published a year ago
Updated 3 months ago