[RD] LockLogin | The best authentication plugin ✅ | Fast⚡- Reliable⭐ - Secure⭕ icon

[RD] LockLogin | The best authentication plugin ✅ | Fast⚡- Reliable⭐ - Secure⭕ -----

A plugin that provides security to your Spigot/Bungee server, with some features like 2FA and other



Developers
You may got noticed that LockLogin doesn't allow any plugin to access his API. Even LockLogin bukkit has some restrictions to which part of the API he can access ( that's why LockLoginManager exists and is a required module ).

But even that you need a module to access LockLogin API, there's an official way to create a bridge between LockLogin modules and a plugin, using the own LockLogin API. Say hello to the API Cards ( or as I like them to be called: ABC [ API Bridge Cards ]. These cards allow you to create a virtual bridge betwen your plugin and your module, using events as the vehicle for that communication.


There's an infinite amount of API Cards you can create, let me explain. To use LockLogin ABC API you must create ( or use existing ) card. If you want to create your own you can do it ( in a LockLogin module ) like that:
Code (Java):
public class TeleportCard extends APICard <ModulePlayer > {
 
    private ModulePlayer player ;

    /**
     * Initialize the teleport card
     *
     * @param module the module owning this card
     * @param client the client managed in this card
     */

    public TeleportCard ( final PluginModule module, final ModulePlayer client ) {
        super (module, "teleport" ) ;
        player = client ;
    }

    /**
     * Update the card object
     *
     * @param update the update value
     */

    @Override
    protected final void update ( final ModulePlayer update ) {
        if (CurrentPlatform. getServer ( ). isValid (update ) ) {
            player = update ;
        }
    }

    /**
     * Get the card value
     *
     * @return the card value
     */

    @Override
    public final ModulePlayer get ( ) {
        return player ;
    }
}
To use this card and allow your plugin to read it, you must fire that card through your module;

Code (Java):
public final class Listener implement EventListener {

    private final PluginModule module ;

    public Listener ( final PluginModule owner ) {
        module = owner ;
    }
    public void onAuth (UserAuthenticateEvent e ) {
        ModulePlayer player = e. getPlayer ( ) ;
        TeleportCard card = new TeleportCard (module, player ) ;

        module. queueCard (card ) ;
    }
}
And finally, in your plugin, you must add an ABC listener so you can detect when an API card is queued and/or processed.

Code (Java):
public class Main extends JavaPlugin {
 
    @Override
    public void onEnable ( ) {
        APICard. addCardListener ( new CardAdapter ( ) {
            /**
             * When a card has been completely queued
             *
             * @param event the card queue event wrapper
             */

            @Override
            public void cardPostQueued (CardPostQueueEvent event ) {
                //The APICard owner module
                PluginModule module = event. getModule ( ) ;
                //Where the APICard is stored, it's usually the same as 'getModule'
                PluginModule container = event. getContainer ( ) ;

                //The APICard name identifier
                String identifier = event. getIdentifier ( ) ;
 
                if (container. consumeCard (module, identifier ) ) {
                    //Make the module consume the card and remove it from the queue, so it can
                    //be loaded using the getCard method
 
                    APICard <ModulePlayer > card = container. getCard (module, identifier ) ;
 
                    UUID id = card. get ( ). getUUID ( ) ;
                    Player player = getServer ( ). getPlayer (id ) ;
 
                    player. teleport ( /* somewhere */ ) ;
                }
            }
        } ) ;
    }
}
Please note in the previous example the plugin only listens when a card is queued completely. But the correct way to read cards is using PluginModule#consumeCard(String) method and then using the PluginModule#getCard(String) method. Consuming a card means that the card will be removed from the queue cards and put to a temporal field to be accessed usin getCard method. Not doing that could cause errors and high memory usage.


A correct way of listening plugin ABC cards would be this
Code (Java):
while ( true ) {
    if (module. consumeCard ( "teleport" ) ) {
        APICard <ModulePlayer > card = module. getCard ( "teleport" ) ;

        //Do whatever you want
    }
}
Or this:
Code (Java):
String [ ] identifiers = new String [ ] { "teleport", "another_example" }

//Inside an async task
while ( true ) {
    for ( String str : identifiers ) {
        module. consumeCard (str ) ;
    }
}
//Outside the async task

APICard. addCardListener ( new CardAdapter ( ) {
  /**
   * When a card has been completely queued
   *
   * @param event the card queue event wrapper
   */

  @Override
  public void cardPostQueued (CardConsumedEvent event ) {
    //The APICard owner module
    PluginModule module = event. getModule ( ) ;
    //Where the APICard is stored, it's usually the same as 'getModule'
    PluginModule container = event. getContainer ( ) ;

    //The APICard name identifier
    String identifier = event. getIdentifier ( ) ;

    APICard < ModulePlayer > card = container. getCard (module, identifier ) ;

    UUID id = card. get ( ). getUUID ( ) ;
    Player player = getServer ( ). getPlayer (id ) ;

    player. teleport ( /* somewhere */ ) ;
  }
} ) ;
Resource Information
Author:
----------
Total Downloads: 117,660
First Release: Feb 13, 2020
Last Update: Jan 20, 2024
Category: ---------------
All-Time Rating:
82 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings