Package com.nickuc.login.api
Interface nLoginAPI
public interface nLoginAPI
nLogin API interface.
Please have a look at the ImplementationType
enum to understand the limitations of the API depending on the implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Interface used for internal nLogin calls. -
Method Summary
Modifier and TypeMethodDescriptionboolean
changePassword
(Identity identity, String newPassword) Changes a player's password.default boolean
changePassword
(String playerName, String newPassword) Deprecated.boolean
comparePassword
(AccountData account, String plainPassword) Checks that the password you provided is valid.default boolean
comparePassword
(String playerName, String plainPassword) Deprecated.UsecomparePassword(AccountData, String)
instead.default boolean
forceLogin
(Identity identity) Forces a player's login.boolean
forceLogin
(Identity identity, boolean showMessages) Forces a player's login.default boolean
forceLogin
(String playerName) Deprecated.UseforceLogin(Identity)
instead.default boolean
forceLogin
(String playerName, boolean showMessages) Deprecated.UseforceLogin(Identity, boolean)
instead.getAccount
(Identity identity) Returns a player's account.Returns all accounts from nLogin.Returns all nLogin accounts by IP.default String
getAddress
(String playerName) Deprecated.UsegetAccount(Identity)
instead.static nLoginAPI
getApi()
Returns the nLogin api.int
Returns the version of the api.Returns the type of database being used.default String
getDiscord
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default String
Deprecated.UsegetAccount(Identity)
instead.default String
getHashedPassword
(String playerName) Deprecated.UsegetAccount(Identity)
instead.Returns the type of implementation used.default String
getLanguage
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default Instant
getLastLogin
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default long
getLastLoginUnix
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default String
getRealName
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default Instant
getRegisterDate
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default long
getRegisterDateUnix
(String playerName) Deprecated.UsegetAccount(Identity)
instead.int
getRemainingSeconds
(Identity identity) Returns the remaining seconds to authenticate.default int
getRemainingSeconds
(String playerName) Deprecated.UsegetRemainingSeconds(Identity)
instead.getSpawnLocation
(SpawnType type) Returns the location of a spawn.Returns the version of the plugin.default boolean
hasDiscord
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default boolean
Deprecated.UsegetAccount(Identity)
instead.internal()
Returns the nLogin internal api.boolean
isAuthenticated
(Identity identity) Checks if a player is logged in.boolean
isAuthenticated
(String knownName) Checks if a player is logged in.boolean
It checks if the api is ready to be used.default boolean
Deprecated.UsegetAccount(Identity)
instead.default boolean
Deprecated.UsegetAccount(Identity)
instead.default boolean
isRegistered
(String playerName) Deprecated.UsegetAccount(Identity)
instead.default boolean
performRegister
(Identity identity, String plainPassword) Register a player.boolean
performRegister
(Identity identity, String plainPassword, String ip) Register a player.default boolean
performRegister
(String playerName, String plainPassword) Deprecated.UseperformRegister(Identity, String)
instead.default boolean
performRegister
(String playerName, String plainPassword, String ip) Deprecated.UseperformRegister(Identity, String, String)
instead.boolean
performUnregister
(Identity identity) Unregister a player.default boolean
performUnregister
(String playerName) Deprecated.UseperformUnregister(Identity)
instead.void
requestLogin
(Identity identity, Object plugin) Sends a login request.default void
requestLogin
(String playerName, Object plugin) Deprecated.UserequestLogin(Identity, Object)
instead.boolean
setDiscord
(Identity identity, long newAccountId) Set a discord account for a certain player.default boolean
setDiscord
(String playerName, long newAccountId) Deprecated.UsesetDiscord(Identity, long)
instead.boolean
Set an email account for a certain player.default boolean
Deprecated.UsesetEmail(Identity, String)
instead.boolean
setLanguage
(Identity identity, String languageCode) Sets the language for a player.
-
Method Details
-
getApi
Returns the nLogin api.- Throws:
nLoginNotLoadedException
- if the api has not yet been instantiated
-
isAvailable
boolean isAvailable()It checks if the api is ready to be used.- Since:
- API v1
-
getVersion
Returns the version of the plugin.- Since:
- API v1
-
getApiVersion
int getApiVersion()Returns the version of the api.- Since:
- API v1
-
getImplementationType
Returns the type of implementation used.- Since:
- API v1
-
getDatabaseType
Returns the type of database being used.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
getSpawnLocation
Returns the location of a spawn.- Parameters:
type
- Spawn type.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v3
-
getAccount
Returns a player's account. READ ONLY.- Parameters:
identity
- Player identity.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v3
-
getAccounts
Returns all accounts from nLogin.This method IS NOT AVAILABLE for
PROXY
implementations.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnsupportedException
- if the implementation type does not support this method.- Since:
- API v1
- See Also:
-
getAccountsByIp
Returns all nLogin accounts by IP.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
isAuthenticated
Checks if a player is logged in.- Parameters:
identity
- Player identity.- Returns:
- true if the player is authenticated.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.- Since:
- API v1
-
isAuthenticated
Checks if a player is logged in.- Parameters:
knownName
- Player name in server.- Returns:
- true if the player is authenticated.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.- Since:
- API v1
-
getRemainingSeconds
Returns the remaining seconds to authenticate.- Parameters:
identity
- Player identity.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v3
-
getRemainingSeconds
Deprecated.UsegetRemainingSeconds(Identity)
instead. -
getRealName
Deprecated.UsegetAccount(Identity)
instead. -
getHashedPassword
Deprecated.UsegetAccount(Identity)
instead. -
getAddress
Deprecated.UsegetAccount(Identity)
instead. -
getLastLogin
Deprecated.UsegetAccount(Identity)
instead. -
getLastLoginUnix
Deprecated.UsegetAccount(Identity)
instead. -
getRegisterDate
Deprecated.UsegetAccount(Identity)
instead. -
getRegisterDateUnix
Deprecated.UsegetAccount(Identity)
instead. -
getEmail
Deprecated.UsegetAccount(Identity)
instead. -
getDiscord
Deprecated.UsegetAccount(Identity)
instead. -
hasEmail
Deprecated.UsegetAccount(Identity)
instead. -
hasDiscord
Deprecated.UsegetAccount(Identity)
instead. -
getLanguage
Deprecated.UsegetAccount(Identity)
instead. -
comparePassword
Checks that the password you provided is valid.- Parameters:
account
- Account data.plainPassword
- Plain password to be compared (not hashed).- Returns:
- true if the password is valid.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v3
-
comparePassword
Deprecated.UsecomparePassword(AccountData, String)
instead. -
isRegistered
Deprecated.UsegetAccount(Identity)
instead. -
isPremium
Deprecated.UsegetAccount(Identity)
instead. -
isBedrock
Deprecated.UsegetAccount(Identity)
instead. -
requestLogin
Sends a login request. Note: It is not sent if a login request is already in progress.This method IS NOT AVAILABLE for
PROXY
implementations.- Parameters:
identity
- Player identity.plugin
- Plugin instance.- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnsupportedException
- if the implementation type does not support this method.- Since:
- API v1
- See Also:
-
requestLogin
Deprecated.UserequestLogin(Identity, Object)
instead. -
performRegister
@ProxyUnsafe default boolean performRegister(@Nonnull Identity identity, @Nonnull String plainPassword) Register a player.- Parameters:
identity
- Player identity.plainPassword
- Plain password to be used (not hashed).- Returns:
- true if the registration was successful. If the user is already registered or during a database failure, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
performRegister
@ProxyUnsafe boolean performRegister(@Nonnull Identity identity, @Nonnull String plainPassword, @Nullable String ip) Register a player.- Parameters:
identity
- Player identity.plainPassword
- Plain password to be used (not hashed).ip
- IP address. Can be null.- Returns:
- true if the registration was successful. If the user is already registered or during a database failure, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
performRegister
@ProxyUnsafe default boolean performRegister(@Nonnull String playerName, @Nonnull String plainPassword) Deprecated.UseperformRegister(Identity, String)
instead. -
performRegister
@ProxyUnsafe default boolean performRegister(@Nonnull String playerName, @Nonnull String plainPassword, @Nullable String ip) Deprecated.UseperformRegister(Identity, String, String)
instead. -
performUnregister
Unregister a player.- Parameters:
identity
- Player identity.- Returns:
- true if the operation was successful. If the user is not registered or during a database failure, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
performUnregister
Deprecated.UseperformUnregister(Identity)
instead. -
changePassword
Changes a player's password.- Parameters:
identity
- Player identity.newPassword
- New password (not hashed).- Returns:
- true if the operation was successful. If the user is not registered or during a database failure, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
changePassword
@ProxyUnsafe default boolean changePassword(@Nonnull String playerName, @Nonnull String newPassword) Deprecated.UsechangePassword(Identity, String)
instead. -
setEmail
Set an email account for a certain player.- Parameters:
identity
- Player identity.newEmail
- Full email.- Returns:
- true if the operation was successful. If the user is not registered, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v2
-
setEmail
Deprecated.UsesetEmail(Identity, String)
instead. -
setDiscord
Set a discord account for a certain player.- Parameters:
identity
- Player identity.newAccountId
- Account id.- Returns:
- true if the operation was successful. If the user is not registered, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v2
-
setDiscord
Deprecated.UsesetDiscord(Identity, long)
instead. -
setLanguage
Sets the language for a player.- Parameters:
identity
- Player identity.languageCode
- The language code (2 letters).- Returns:
- true if the operation was successful. If the user is not registered, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v9
-
forceLogin
Forces a player's login.- Parameters:
identity
- Player identity.- Returns:
- true if the operation was successful. If the user is not registered, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
forceLogin
Forces a player's login.- Parameters:
identity
- Player identity.showMessages
- Sends login messages if the supplied value is true.- Returns:
- true if the operation was successful. If the user is not registered, returns false.
- Throws:
nLoginNotReadyException
- if the plugin is not yet fully loaded.nLoginRequestUnavailableException
- if the implementation type does not support this method at invocation time. @seeImplementationType
- Since:
- API v1
-
forceLogin
Deprecated.UseforceLogin(Identity)
instead. -
forceLogin
Deprecated.UseforceLogin(Identity, boolean)
instead. -
internal
Returns the nLogin internal api.
-
changePassword(Identity, String)
instead.