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
| Event | Description |
|---|---|
UserPreLoginEvent | Fired before login is processed |
UserPreRegisterEvent | Fired before registration is processed |
UserPrePasswordChangeEvent | Fired before a password change |
UserPreUnregisterEvent | Fired before account deletion |
@EventHandler
public void onPreLogin(UserPreLoginEvent event) {
event.setCancelled(true);
event.setCancelReason("Login is disabled.");
}
Post-Events
| Event | Description |
|---|---|
UserPostLoginEvent | Fired after successful login |
UserPostRegisterEvent | Fired after account creation |
UserPostPasswordChangeEvent | Fired after password change |
UserPostUnregisterEvent | Fired after account deletion |
@EventHandler
public void onPostLogin(UserPostLoginEvent event) {
String username = event.getUsername();
UUID uniqueId = event.getUniqueId();
}
Other Events
| Event | Description |
|---|---|
UserLoginFailedEvent | Fired when login fails (wrong password, etc.) |
UserLoginMaxAttemptsEvent | Fired when max login attempts are reached |
UserChangeAccountTypeEvent | Fired when account type changes (cracked/premium) |
Bridge Events (Spigot)
| Event | Description |
|---|---|
PlayerSuccessLoginEvent | Fired when a player is authenticated on the proxy |
SetLoginLocationEvent | Fired 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") }
)