NeumimTo / NT-Rpg

Plugin which brings RPG features into minecraft.


Using NT-Rpg as a developer

Adding NT-Rpg to your dev workspace is easy when using gradle (or maven, or any other similar system relying on maven). All you need to do is to add as remote maven repository. For example, in gradle, you can add this :

repositories {
    maven {
        url = ""
    // Any other repo you may need

Then use the following artifact reference in your dependencies:

group-id: com.github.Sponge-RPG-dev
artifact-id: NT-RPG
version: $latest-release$

Get the latest release version from github.

For example, this is what a gradle dependency on NT-Rpg on 2.0.0-SNAPSHOT-9 would look like:

dependencies {
    compile "com.github.Sponge-RPG-dev:NT-RPG:2.0.0-SNAPSHOT-9"


If you would like to add custom Skills, Effects, Guis and other stuff into NT-Rpg you have two ways how to achieve this.

  • Create a Sponge plugin with NT-RPG as a dependecy, and load all your stuff manually.
@Plugin( ..., dependency="after:nt-rpg")
public class YourPlugin {
    public oninit(GamePostInitializationEvent e) {
        ResourceLoader rl = NtRpgPlugin.GlobalScope.resourceLoader;
        //load everything from your jar
        rl.loadJarFile(yourjarfile, false)
        //or a single class
  • Let the NT-Rpg classloader load everything automatically.

Simply annotate your Skills, Commands and listeners, with either @ResourceLoader.Skill,@ResourceLoader.Command, @ResourceLoader.ListenerClass annotations and place compiled jar into config/nt-rpg/addons folder.

Using GlobalScope and NT-RPG services

Most interactions with game entities (like applying effects, getting property values, updating mana) should be done through NT-RPG services.

NtRpgPlugin.GlobalScope contains all services you may need in development.

EntityService is intended to manage all living Entities. In most cases you will need it for getting their properties values.

CharacterService is designed to manage data of characters. You could get current active character of player using UUID or Player object from it.

EffectService is there to deal with all effects maniputations.

Use PartyService to create new or invite people in existing parties.

Annotation based Inversion of Control & Dependency Injection

This concept is very similar to for example Spring’s @Component annotation. - code

@Singleton - Each class annotated with this annotation is a Singleton (By default there is exactly one instance of the class present at runtime). Its constructor must be without arguments

@Inject - To each non-static field in a class annotated with the @Singleton annotation will be assigned its coresponding object reference at runtime.

@Command, @ListenerClass, @Skill- You can also use those as a replacement for @Singleton. This tells the classloader what to do with the class after its instance is created.

@PostProcess - Method annotation, which will be executed once the container loads all singletons from the classpath.

What does this mean?

public void Something extends ActiveSkill {

    private SomeService someService

    public SkillResult cast(...) {


    @PostProcess(priority = 900)
    public void somemethod() {


Once the classloader discovers this class its recognized as a singleton, its instance is created. Once it has the instance the IoC container iterates over all fields(even in its subclasses). If the container finds an @Inject it assigns its value. If the required instance is not present in the container (has not been discovered yet) it tris to do the process again but now with another class (Recursive loop). Once the classloader finds all Singletons all methods annotated with PostProcess are called in a order according to its priority.

Creating a persistent content with Hibernate

If you would like to add persistent data its recommended to use hibernate and jpa.

Listen to FindPersistenceContextEvent (requires NT-Core as a dependency) and add the class of your Entity. The entity must follow standart JPA specification

If you would like to manage persistent context extend a generic class GenericDao and annotate the class with @Singleton Annotation. You might want to override its methods. By default there is no cache, no locking, and only DETACHED! entites are returned.

Category: Role Playing

Published on Jul 2, 2017


16 stars

842 total downloads

Licensed under GNU General Public License (GPL)