PreStartCallEvent
Event Details
melodyPlayer
MelodyPlayer
The player who is initiating the call.
targetPlayer
MelodyPlayer
The player who is the target of the call.
canSendMessage
boolean
A flag indicating whether a message can be sent to the players involved in the call.
isCancelled
boolean
A flag indicating whether the event is cancelled. If true, the call will not be initiated.
Example Usage
Here is an example of how to listen to this event using the Bukkit event API:
import ir.taher7.melodymine.api.events.PreStartCallEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class CustomListener implements Listener {
@EventHandler
public void onPreStartCall(PreStartCallEvent event) {
// Access the MelodyPlayer objects
MelodyPlayer melodyPlayer = event.getMelodyPlayer();
MelodyPlayer targetPlayer = event.getTargetPlayer();
// Print to console
Bukkit.getLogger().info(melodyPlayer.getName() + " is initiating a call with " + targetPlayer.getName());
// Check if a message can be sent
if (event.canSendMessage()) {
// Add custom logic here
}
// Cancel the event
// event.setCancelled(true);
}
}
In this example, we're listening for the PreStartCallEvent
. When the event is triggered, we're logging the names of the players involved in the call to the console. We also check if a message can be sent during this event. If the event is cancelled, the call will not be initiated.
Remember to register your event listener in your plugin's onEnable()
method to ensure that it is active.
Last updated