ModsJava
[API] Redis/MySQL/MongoDB PAPI Bridge
[API] Get/Send data from your Database and paste them as a Placeholder!. Free Minecraft Java mod for 1.8, 1.9, 1.10.
⬇ Download on SpigotThis 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:
BridgePlugin. getAPI ( ) ;
Module 1: Accessing to Identifiers Database
//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
// 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
// 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
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.
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 ( ) ;
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
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.
}
}
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 ) ;
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.
[API] Redis/MySQL/MongoDB PAPI Bridge is a free Minecraft Java mod. Compatible with Minecraft 1.8, 1.9, 1.10, 1.11 and newer. Downloaded 262 times (via Spigot). Download it and open it directly in the game.