[API] Redis/MySQL/MongoDB PAPI Bridge
1.3[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:
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.
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta