Solving Passenger Compatibility Issues with PassengerAPI
PassengerAPI is a specialized plugin that addresses common compatibility problems between various modifications managing entity passenger systems. When different plugins independently work with passengers by sending network packets, conflicts arise leading to unpredictable behavior and detachment of previously set passengers.
How Compatibility Conflicts Are Resolved
The passenger API centralizes management of entity passengers, preventing typical issues such as:
- Loss of visual elements
- Incorrect displays
- Unexpected passenger detachment
Full out-of-the-box compatibility - the plugin starts working immediately after installation in the plugins folder and server restart.
(Requires installed Packet Events)
Demonstration in Action
Examples of Plugin Cooperation
PassengerAPI provides seamless integration between popular modifications such as:
- Better Chat Bubbles
- ProdigyCape
- VanillaMinimaps
- PlayerMounts
Without PassengerAPI different plugins cannot simultaneously set passengers since they send their own passenger packets independently of each other.
Settings and Management
Configuration
# DO NOT MODIFY ANYTHING IN THIS FILE
# UNLESS YOU ARE 100% SURE OF YOUR ACTIONS!
AutoPassengerDetection:
SetPassengerPacket: true
EntityDestroyPacket: true
Administrator Commands
Permission: passengerapi.commands
/passengerapi debug
/passengerapi reload
Note: In debug mode with a block in hand, you will receive enhanced diagnostic information in the chat.
For Developers: Powerful API Functionality
PassengerAPI provides developers with tools for complete control over entity passengers without destroying the entity itself.
Obtaining PassengerActions Instance
PassengerActions passengerActions = PassengerAPI.getAPI(yourPluginInstance);
Replace yourPluginInstance with the instance of your plugin's main class (typically use this when calling from the main class).
Passenger Management
// Add a single passenger
passengerActions.addPassenger(targetEntityId, passengerEntityId);
// Add multiple passengers
passengerActions.addPassengers(targetEntityId, Set.of(passenger1Id, passenger2Id, ...));
// Remove a passenger
passengerActions.removePassenger(targetEntityId, passengerEntityId);
// Remove multiple passengers
passengerActions.removePassengers(targetEntityId, Set.of(passenger1Id, passenger2Id, ...));
// Remove all passengers for an entity
passengerActions.removeAllPassengers(targetEntityId);
// Get passengers
Set<Integer> passengers = passengerActions.getPassengers(targetEntityId);
// Global methods for passengers from all plugins
passengerActions.removeGlobalPassengers(targetEntityId, Set.of(passenger1Id, passenger2Id, ...));
passengerActions.removeAllGlobalPassengers(targetEntityId);
Set<Integer> globalPassengers = passengerActions.getGlobalPassengers(targetEntityId);
Important: All entities are identified by entity ID (not UUID).
Event System
PassengerAPI provides a set of events for responding to passenger changes:
@EventHandler
public void onAddPassenger(AddPassengerEvent event) {
// The plugin name trying to add passengers
String pluginName = event.getPluginName();
int targetEntity = event.getTargetEntityID();
Set<Integer> passengers = event.getPassengerList();
// Your handling code
}
@EventHandler
public void onRemovePassenger(RemovePassengerEvent event) {
// The plugin removing passengers
String pluginName = event.getPluginName();
int targetEntity = event.getTargetEntityID();
Set<Integer> removedPassengers = event.getPassengerList();
// Your processing logic
}
@EventHandler
public void onPassengerPacket(PassengerPacketEvent event) {
int targetEntity = event.getTargetEntityID();
Set<Integer> passengers = event.getPassengerList();
// List of players to receive the packet (can be modified)
List<Player> receivers = event.getPacketReceivers();
// Additional processing
}
Don't forget to register your event classes for their processing.