Developer API

Public API for integrating mineLogin with external plugins.

Overview

mineLogin provides two API modules for external plugin integration:

  • minelogin-api β€” core API for proxy plugins (BungeeCord/Velocity)
  • minelogin-bridge-api β€” API for Spigot/Paper backend plugins

Core API (Proxy)

Accessing the API

LoginPlugin loginPlugin = LoginPluginProvider.getLoginPlugin();
UserFacade<UserApi> userFacade = loginPlugin.getUserFacade();

UserApi

Represents a player’s account:

interface UserApi {
    UUID getUniqueId();
    String getUsername();
    String getHashedPassword();
    String getEmail();
    String getSalt();
    String getRegistrationAddress();
    String getLastAccessedAddress();
    Instant getRegistrationTime();
    Instant getLastAccessedTime();
    boolean isPaid();
}

UserFacade

Handles user lookups:

interface UserFacade<T extends UserApi> {
    Optional<T> findUserByUsername(String username);
    Optional<T> findUserByUniqueId(UUID uniqueId);
    List<T> getUsers();
}

Examples

Find a User by Name

LoginPlugin loginPlugin = LoginPluginProvider.getLoginPlugin();
UserFacade<UserApi> userFacade = loginPlugin.getUserFacade();

Optional<UserApi> user = userFacade.findUserByUsername("Steve");
if (user.isPresent()) {
    boolean isPremium = user.get().isPaid();
    String email = user.get().getEmail();
}

Check if a Player is Premium

Optional<UserApi> user = userFacade.findUserByUniqueId(player.getUniqueId());
if (user.isPresent() && user.get().isPaid()) {
    // Player has a premium account
}

Events (BungeeCord)

mineLogin fires events before and after authentication actions. Pre-events are cancellable.

Pre-Events

EventDescription
UserPreLoginEventFired before login is processed
UserPreRegisterEventFired before registration is processed
UserPrePasswordChangeEventFired before a password change
UserPreUnregisterEventFired before account deletion
@EventHandler
public void onPreLogin(UserPreLoginEvent event) {
    event.setCancelled(true);
    event.setCancelReason("Login is disabled.");
}

Post-Events

EventDescription
UserPostLoginEventFired after successful login
UserPostRegisterEventFired after account creation
UserPostPasswordChangeEventFired after password change
UserPostUnregisterEventFired after account deletion
@EventHandler
public void onPostLogin(UserPostLoginEvent event) {
    String username = event.getUsername();
    UUID uniqueId = event.getUniqueId();
}

Other Events

EventDescription
UserLoginFailedEventFired when login fails (wrong password, etc.)
UserLoginMaxAttemptsEventFired when max login attempts are reached
UserChangeAccountTypeEventFired when account type changes (cracked/premium)

Bridge Events (Spigot)

EventDescription
PlayerSuccessLoginEventFired when a player is authenticated on the proxy
SetLoginLocationEventFired when the login location is changed
@EventHandler
public void onSuccessLogin(PlayerSuccessLoginEvent event) {
    Player player = event.getPlayer();
}

Bridge API

BridgeUserApi

Represents a player on the backend server:

interface BridgeUserApi {
    UUID getUniqueId();
    String getUsername();
    boolean isLogged();
    boolean isPaid();
}

BridgeUserServiceApi

Handles bridge user lookups:

interface BridgeUserServiceApi {
    Optional<BridgeUserApi> findByUniqueId(UUID uniqueId);
}

Plugin Dependencies

BungeeCord plugin.yml

depends:
  - mineLogin

Or as a soft dependency:

softDepends:
  - mineLogin

Velocity

Register your plugin with a dependency on mineLogin in your @Plugin annotation:

@Plugin(
    id = "my-plugin",
    dependencies = { @Dependency(id = "minelogin") }
)