PluginBase is a lightweight framework for Minecraft (Spigot/Paper) plugins.
It helps to manage the plugin lifecycle, player lifecycle, and communication between plugin systems.
This project was created while developing large plugins where maintenance became difficult.
Core Problems:
- Services depend on each other
- Excessive boilerplate code in
onEnable/onDisable - Plugin reload (e.g., Plugman) corrupting player data state
Additional Problems: 4. Saving and loading plugin data 5. Creating Interaction Items 6. A central place to store common utility classes
-
Download the project, build it, publish to maven local and add it as a dependency to your project:
implementation("ru.logonik:PluginBase:X.X.X-SNAPSHOT"). -
Create your main plugin class, extending
BootstrapPlugin:
public final class NewMainExamplePlugin extends BootstrapPlugin {
@Override
public void onEnable() {
saveDefaultConfig();
initTranslation();
serviceLocator.registerService(Scheduler.class, new BukkitScheduler(this));
serviceLocator.registerService(IBuildPrivilegeGameHandler.class, new BuildPrivilegeGameHandler());
serviceLocator.registerService(CommandManager.class); // empty constructor
serviceLocator.registerService(ExampleService .class);
// ...
serviceLocator.registerService(DoorGui.class);
super.onEnable();
}
}- When the plugin starts, any service can obtain any other registered class via the
ServiceLocator:
public class ExampleService implements PluginStartListener {
@Override
public void start(ServicesLocator servicesLocator) throws Exception {
Plugin plugin = servicesLocator.getServiceOrThrow(Plugin.class);
}
}Each service is registered via BukkitServiceLocator
(serviceLocator.registerService(ExampleService.class, new ExampleService());)
and, depending on the interfaces it implements, is processed as follows:
Listener— Bukkit event listeners will be automatically registered through the Bukkit API.PluginStartListener— Called when the plugin starts.PluginDisableListener— Called when the plugin stops.PlayerAvailableListener(Async/Sync)— Called when a player joins the server or becomes available*. (*If the plugin is reloaded, this will be called for every player already on the server).PlayerQuitListener(Async/Sync)— Called when a player leaves the server.
check a wiki for others features
MIT