PreEndCallEvent
Class Structure
Method/Variable
Type
Description
Example Usage
import ir.taher7.melodymine.api.events.PreEndCallEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class MyListener implements Listener {
@EventHandler
public void onPreEndCall(PreEndCallEvent event) {
// Access the players involved in the call
MelodyPlayer player1 = event.getMelodyPlayer();
MelodyPlayer player2 = event.getTargetPlayer();
// Print their names to the console
Bukkit.getLogger().info(player1.getName() + " and " + player2.getName() + " are about to end their call.");
// If a certain condition is met, cancel the event
if (someCondition) {
event.setCancelled(true);
Bukkit.getLogger().info("The call between " + player1.getName() + " and " + player2.getName() + " was prevented from ending.");
}
// If another condition is met, prevent the message from being sent
if (anotherCondition) {
event.setCanSendMessage(false);
Bukkit.getLogger().info("No message will be sent to " + player1.getName() + " and " + player2.getName() + " about the call ending.");
}
}
}Last updated