PreAcceptCallEvent
Event Details
Attribute
Description
Example
import ir.taher7.melodymine.api.events.PreAcceptCallEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPreAcceptCall(PreAcceptCallEvent event) {
// Access the MelodyPlayer instances
MelodyPlayer melodyPlayer = event.getMelodyPlayer();
MelodyPlayer targetPlayer = event.getTargetPlayer();
// Print to console
getLogger().info(melodyPlayer.getName() + " is accepting a call from " + targetPlayer.getName());
// Cancel the event if needed
if (someCondition) {
event.setCancelled(true);
getLogger().info("Call acceptance cancelled due to some condition.");
}
// Prevent sending a message to the player
if (anotherCondition) {
event.setCanSendMessage(false);
getLogger().info("Prevented sending a message to the player.");
}
}
}Last updated