[API] Redis/MySQL/MongoDB PAPI Bridge icon

[API] Redis/MySQL/MongoDB PAPI Bridge -----

[API] Get/Send data from your Database and paste them as a Placeholder!



This is an API that I made for the plugin MySQL/MongoDB PAPI Bridge
For use this API requires plugin version +3.6

Alert: This is not a plugin, just add this jar file to your plugin libraries.

Module 0: Calling the API:
Code (Java):

BridgePlugin. getAPI ( ) ;
 
Module 1: Accessing to Identifiers Database
Code (Java):

//Accessing to Identifier Manager using the API
IdentifierManager manager = API. getIdentifierManager ( ) ;

// Getting loaded Identifiers by Configuration
manager. getIdentifiersEnabled ( ) ; //Returns List<Identifier>

// Getting Identifier by their Name
manager. getIdentifierByName ( String name ) ; //Returns Identifier
 
Module 2: Running Connection Tasks for Identifiers
Code (Java):

// Example for Upload Placeholders
@EventHandler
public void join (PlayerJoinEvent event ) {
    if ( !event. getPlayer ( ). hasPlayedBefore ) {
        API API = BridgePlugin. getAPI ( ) ;
        Identifier identifier = API. getIdentifierManager ( ). getIdentifierByName ( "player_first_join_date" ) ;
       identifier. getDatabridge ( ). run (event. getPlayer ( ) ) ;
        //This void will forces to the identifier to upload the recent information
        //to the active connection database of the Identifier. (MySQL or MongoDB or Redis)

        //This void also works for Download Placeholders, if required, to download
        //the information from the connection instead of upload.
    }
}
 
Module 3: Replacing Information for Download Placeholders
Code (Java):

// Getting information that is saved in the RAM
RAMDatabase ram = identifier. getDatabridge ( ). getRAMDatabase ( ) ;
String information = ram. getPlayerInformation (event. getPlayer ( ) ) ;
// Modifying the information
if (information. contains ( "§" ) {
    information = ChatColor. translateAlternateColorCodes ( '§', information ) ) ;
}
// Replacing the information
ram. savePlayerInformation (event. getPlayer ( ), information ) ;
 
Module 4: Plugin Events
Code (Java):

AsyncPreprocessIdentifierCompleteTaskEvent

// Called when the plugin is about to [But not yet] complete the identifier task (Upload or Download Information)
// This event is cancellable.
// It can be called multiple times if player runs "/mpb run <identifier> all"
// It can be called multiple times when identifier reaches the time for do a task.
// The times that can be called in a few seconds may depend in the amount of players connected in the server

AsyncIdentifierCompleteTaskEvent

// Called when the identifier has completed the task (Upload or Download Information)
// This event is NOT cancellable.
// It can be called multiple times if player runs "/mpb run <identifier> all"
// It can be called multiple times when identifier reaches the time for do a task.
// The times that can be called in a few seconds may depend in the amount of players connected in the server
// It may not be called if AsyncPreprocessIdentifierCompleteTaskEvent is cancelled.
 

That's all for now, Thanks for using my projects.
Resource Information
Author:
----------
Total Downloads: 242
First Release: Nov 6, 2021
Last Update: Dec 27, 2021
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings