Skip to content

NotMarra/NotLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

179 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NotLib

A batteries-included developer library for Paper & Folia Minecraft plugins.

License: GPL-3.0 Paper Folia Java

📖 Documentation · 🐛 Report a bug · 💡 Request a feature


Overview

NotLib eliminates the boilerplate that every Paper plugin repeats — database connections, config management, GUI building, command registration and more — so you can focus on your plugin's actual logic.

public class MyPlugin extends NotPlugin {
    private DatabaseManager db;
    private LanguageManager lang;

    @Override
    public void initPlugin() {
        db   = sqliteDatabase(getDataFolder(), "data").build();
        lang = languageManager().defaultLocale("en_US").build();

        db.registerCached(PlayerProfile.class);
        addListener(new PlayerListener(this));
    }
}

Features

Module What it does
NotPlugin Base plugin class — wires up everything automatically
Database HikariCP ORM with SQLite & MariaDB, annotation-based entities, fluent QueryBuilder
Cache In-memory cache with TTL, LRU/FIFO eviction and three write strategies
DatabaseManager Single entry point combining database + cache with auto lifecycle management
Language YAML-based localisation with MiniMessage support, prefix injection and hot-reload
GUI Fluent inventory builder with pattern layouts, containers and animations
Commands Brigadier command system with typed arguments and built-in help generation
Config Managed YAML configs with auto-update, comment preservation and directory watching
Scheduler Unified Folia/Paper scheduling API

Requirements

  • Java 21+
  • Paper or Folia 1.21+

Installation

Maven

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

<dependencies>
<dependency>
    <groupId>com.github.NotMarra</groupId>
    <artifactId>NotLib</artifactId>
    <version>Tag</version>
</dependency>
</dependencies>

Gradle (Kotlin DSL)

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

dependencies {
    compileOnly("com.github.NotMarra:NotLib:Tag")
}

plugin.yml

depend:
  - NotLib

Quick examples

Database + Cache

// Define entity
@Table(name = "players")
public class PlayerProfile {
    @Column(name = "id", primaryKey = true)
    private UUID uuid;

    @Column(name = "name")
    private String name;

    @Column(name = "level")
    private int level;
}

// In initPlugin()
db = sqliteDatabase(getDataFolder(), "data")
        .defaultWriteStrategy(WriteStrategy.WRITE_BEHIND)
        .build();
db.registerCached(PlayerProfile.class);

// Usage
CachedRepository<UUID, PlayerProfile> repo = db.cached(PlayerProfile.class);
repo.findByIdAsync(uuid).thenAccept(opt -> opt.ifPresent(this::handle));
repo.upsert(updatedProfile);

Language

# languages/en_US.yml
prefix: "<gray>[<aqua>MyPlugin</aqua>]</gray> "
player:
  join: "%prefix%<green>%player% joined!"
lang.get("player.join")
    .withPlayer(player)
    .sendTo(player);

GUI

GUI gui = GUI.create("Shop")
        .rows(3)
        .pattern("""
                #########
                #A#B#C###
                #########
                """)
        .emptySlotChars(List.of('#'))
        .onPatternMatch(info -> switch (info.ch) {
            case 'A' -> gui.createItem(Material.APPLE).name("Apple");
            case 'B' -> gui.createItem(Material.BREAD).name("Bread");
            default  -> null;
        });
gui.open(player);

Commands

Command.of("give", "Give items to a player")
        .permission("myplugin.give")
        .arg(new PlayerArg("target")
                .arg(new IntArg("amount")
                        .onExecute(c -> {
                            Player target = c.getPlayerV("target");
                            int amount    = c.getIntegerV("target.amount");
                            // …
                        })));

Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a pull request.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'feat: add my feature')
  4. Push and open a Pull Request

License

Distributed under the GPL-3.0 License. See LICENSE for details.

About

Library for NotPlugins

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages