PreDenyCallEvent

The PreDenyCallEvent is a custom event in the Bukkit API that is called before a call is denied in the MelodyMine plugin. This event provides information about the player who is denying the call (melodyPlayer) and the target player whose call is being denied (targetPlayer).

Event Details

AttributeDescription

melodyPlayer

The player who is denying the call.

targetPlayer

The player whose call is being denied.

Example Usage

Here is an example of how to listen to this event using the Bukkit event API:

import ir.taher7.melodymine.api.events.PreDenyCallEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public class ExampleListener implements Listener {

    private JavaPlugin plugin;

    public ExampleListener(JavaPlugin plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void onPreDenyCall(PreDenyCallEvent event) {
        plugin.getLogger().info(event.getMelodyPlayer().getName() + " is denying a call from " + event.getTargetPlayer().getName());

        // If the event is cancellable and you want to cancel it based on some condition
        // event.setCancelled(true);

        // If the event has a canSendMessage method and you want to prevent the message
        // event.setCanSendMessage(false);
    }
}

In this example, when a player denies a call, a message is logged in the console indicating who is denying the call and from whom the call is being denied. If the event is cancellable, you can cancel it based on some condition. Similarly, if the event has a canSendMessage method, you can prevent the message from being sent.

Remember to register your event listener in the onEnable method of your main plugin class.

@Override
public void onEnable() {
    getServer().getPluginManager().registerEvents(new ExampleListener(this), this);
}

This will ensure that your listener is active and can respond to the PreDenyCallEvent.

Last updated