Skip to content

Managers

This page explains how to use managers provided by the core system.


What is a manager?

A manager is used to encapsulate a specific part of your plugin logic in its own class.

Managers help you:

  • split logic into smaller units
  • avoid bloated main classes
  • keep features easier to maintain
  • structure startup logic cleanly

A manager usually extends PixelManager<YourPlugin> and gets registered through the ManagerHandler.


Examples

Creating a manager

A manager always extends PixelManager<YourPlugin>.

public class CelebrationManager extends PixelManager<CorePlugin> {

  public CelebrationManager(CorePlugin plugin) {
    super(plugin);
  }

  @Override
  public void onEnable() {
    registerPacketListener();
    registerCommand();
  }

}

Registering a manager

When a manager is registered, its onEnable() method is called automatically.

public class CorePlugin extends JavaPlugin {

  @Override
  public void onEnable() {
    ManagerHandler managerHandler = BukkitCoreLibrary.getManagerHandler();
    CelebrationManager celebrationManager = new CelebrationManager(this);
    managerHandler.registerManager(celebrationManager);
  }

}

Best Practices

  • Keep each manager focused on one responsibility.
  • Use managers to separate feature logic from your main plugin class.
  • If a manager grows too large, split parts of its logic into helper classes or additional managers.
  • Only put setup logic into onEnable() that is actually related to that manager.

Common Pitfalls

  • Writing too much logic into a single manager. As a rule of thumb, managers should usually not grow beyond \~500 lines of code. Split logic into smaller classes or additional managers when needed.
  • Relying on onDisable() for mob removal or world cleanup. For whatever reason, this may not work reliably. Instead, create your own removeAll() method and call it manually from your plugin's disable logic.