PrePauseSoundEvent

The PrePauseSoundEvent class is a custom event in the Bukkit API. It is triggered before a sound is paused in the MelodyMine plugin. This event provides information about the sound that is about to be paused, including the sound name, whether the pause should be sent to all players, and the socket ID associated with the event.

Class Properties

PropertyTypeDescription

soundName

String

The name of the sound that is about to be paused.

sendToAll

Boolean

Indicates whether the pause event should be sent to all players.

socketID

String?

The socket ID associated with the event. This could be null.

Class Methods

MethodReturn TypeDescription

isCancelled

Boolean

Checks if the event is cancelled.

setCancelled

Void

Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

Example Usage

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

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

public class ExampleListener implements Listener {

    @EventHandler
    public void onPrePauseSound(PrePauseSoundEvent event) {
        // Check if the event is cancelled
        if (event.isCancelled()) {
            return;
        }

        // Get the sound name
        String soundName = event.getSoundName();

        // Log the sound name to the console
        Bukkit.getLogger().info("About to pause sound: " + soundName);

        // If the event is set to send to all, log this information
        if (event.isSendToAll()) {
            Bukkit.getLogger().info("The sound pause will be sent to all players.");
        }

        // Get the socket ID, if it exists
        String socketID = event.getSocketID();
        if (socketID != null) {
            Bukkit.getLogger().info("The socket ID associated with this event is: " + socketID);
        }
    }
}

Remember to register your event listener in your plugin's onEnable method for the event to be properly handled.

Last updated