-
Notifications
You must be signed in to change notification settings - Fork 0
Beginner Guide
Welcome to the Supervisor Beginner Wiki! This guide will walk you through setting up your first Supervisor project, helping you understand the basics of plugin development using Supervisor's enterprise-grade tools.
Create the main plugin class for your project. This is where you will initialize your plugin and set up any required services.
package com.vertmix.supervisor.core.bukkit;
import com.vertmix.supervisor.loader.SupervisorLoader;
import org.bukkit.plugin.java.JavaPlugin;
import static com.vertmix.supervisor.core.bukkit.BukkitProvider.bukkit;
public class DummyPlugin extends JavaPlugin {
@Override
public void onEnable() {
SupervisorLoader.register(bukkit(this));
}
}Define the data model that represents the information you want to store. In this example, we create a PlayerData class to hold player-specific information.
package com.vertmix.supervisor.core.bukkit.dummy.model;
import java.util.UUID;
public class PlayerData {
private final UUID uuid;
private final String name;
public PlayerData(UUID uuid, String name) {
this.uuid = uuid;
this.name = name;
}
public UUID getUuid() {
return uuid;
}
public String getName() {
return name;
}
}Repositories handle interactions with the data storage layer. In this example, we create a repository interface for PlayerData using the BukkitJsonPlayerRepository.
package com.vertmix.supervisor.core.bukkit.dummy.repository;
import com.vertmix.supervisor.core.annotation.Component;
import com.vertmix.supervisor.core.bukkit.dummy.model.PlayerData;
import com.vertmix.supervisor.repository.json.bukkit.BukkitJsonPlayerRepository;
@Component
public interface PlayerDataRepository extends BukkitJsonPlayerRepository<PlayerData> {
}Services contain business logic and act as a bridge between repositories and controllers. Here, we create a service that listens for player login events and ensures PlayerData is saved.
package com.vertmix.supervisor.core.bukkit.dummy.service;
import com.vertmix.supervisor.core.annotation.Component;
import com.vertmix.supervisor.core.bukkit.dummy.model.PlayerData;
import com.vertmix.supervisor.core.bukkit.dummy.repository.PlayerDataRepository;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
@Component
public class PlayerDataService implements Listener {
private final PlayerDataRepository playerDataRepository;
public PlayerDataService(PlayerDataRepository playerDataRepository) {
this.playerDataRepository = playerDataRepository;
}
@EventHandler
public void onAsyncPlayerJoin(AsyncPlayerPreLoginEvent event) {
PlayerData playerData = playerDataRepository.find(event.getUniqueId());
if (playerData == null) {
playerDataRepository.save(event.getUniqueId(), new PlayerData(event.getUniqueId(), event.getName()));
}
}
}Controllers handle requests and pass them to the appropriate service. In this example, we create a controller to get player data.
package com.vertmix.supervisor.core.bukkit.dummy.controller;
import com.vertmix.supervisor.core.annotation.Component;
import com.vertmix.supervisor.core.bukkit.dummy.model.PlayerData;
import com.vertmix.supervisor.core.bukkit.dummy.service.PlayerDataService;
import java.util.UUID;
@Component
public class PlayerDataController {
private final PlayerDataService playerDataService;
public PlayerDataController(PlayerDataService playerDataService) {
this.playerDataService = playerDataService;
}
public String getPlayerName(UUID uuid) {
PlayerData data = playerDataService.get(uuid);
if (data != null)
return data.getName();
return null;
}
}We recommend using ACF (Aikar Command Framework) for your command framework. It simplifies command handling and provides a clean way to manage command arguments, permissions, and more.
If you're interested in contributing to the Supervisor project, feel free to submit pull requests or raise issues on GitHub. We welcome suggestions and improvements from the community.
The Supervisor project is licensed under the MIT License. See the LICENSE file for more information.
For further questions or suggestions, contact us at support@vertmix.com.
Thank you for being part of the Supervisor community!