PreEnableVoiceEvent

The PreEnableVoiceEvent is a custom event in the Bukkit API. It is triggered before a player enables their voice in the MelodyMine plugin. This event provides information about the player and the target socket ID.

Event Details

FieldTypeDescription

playerName

String

The name of the player who is about to enable their voice.

playerUuid

String

The UUID of the player who is about to enable their voice.

playerServer

String

The server that the player is currently on.

targetSocketID

String

The socket ID of the target player.

Methods

MethodReturn TypeDescription

getPlayer()

MelodyPlayer

Returns the MelodyPlayer instance of the player who is about to enable their voice.

getTargetPlayer()

MelodyPlayer

Returns the MelodyPlayer instance of the target player.

Example Usage

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

import ir.taher7.melodymine.api.events.PreEnableVoiceEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class MyListener implements Listener {

    @EventHandler
    public void onPreEnableVoice(PreEnableVoiceEvent event) {
        // Get the player's name
        String playerName = event.getPlayerName();

        // Get the target socket ID
        String targetSocketID = event.getTargetSocketID();

        // Log the information to the console
        Bukkit.getLogger().info(playerName + " is about to enable their voice. Target Socket ID: " + targetSocketID);
        
        getLogger().info("Player UUID: " + event.getPlayerUuid());
        getLogger().info("Player Server: " + event.getPlayerServer());
        getLogger().info("Target Socket ID: " + event.getTargetSocketID());
    }
}

In this example, we create a listener for the PreEnableVoiceEvent. When the event is triggered, we retrieve the player's name and the target socket ID, and then log this information to the console.

Remember to register your event listener in your plugin's onEnable() method for it to work correctly.

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

Last updated