PreEndPendingCallEvent

The PreEndPendingCallEvent is a custom event in the MelodyMine plugin. This event is triggered before a pending call ends between two players. It provides access to the MelodyPlayer instances of both the caller and the receiver.

Event Details

FieldTypeDescription

melodyPlayer

MelodyPlayer

The player who initiated the call.

targetPlayer

MelodyPlayer

The player who was the target of the call.

Example Usage

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

import ir.taher7.melodymine.api.events.PreEndPendingCallEvent;
import ir.taher7.melodymine.models.MelodyPlayer;
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 onPreEndPendingCall(PreEndPendingCallEvent event) {
        MelodyPlayer caller = event.getMelodyPlayer();
        MelodyPlayer receiver = event.getTargetPlayer();

        plugin.getLogger().info(caller.getName() + " is ending a pending call with " + receiver.getName());
    }
}

In this example, we create a listener for the PreEndPendingCallEvent. When the event is triggered, we retrieve the MelodyPlayer instances of the caller and the receiver. We then log a message to the console indicating that the caller is ending a pending call with the receiver.

Remember to register your event listener in your plugin's onEnable method like so:

getServer().getPluginManager().registerEvents(new ExampleListener(this), this);

Last updated