PostSetVolumeEvent

The PostSetVolumeEvent is a custom event in the MelodyMine plugin. This event is triggered after the volume of a player is set. It provides information about the player whose volume was set and the target player who set the volume.

Event Details

FieldTypeDescription

playerUuid

String

The UUID of the player whose volume was set.

targetSocketID

String

The socket ID of the target player who set the volume.

Methods

MethodReturn TypeDescription

getPlayer()

MelodyPlayer

Returns the MelodyPlayer instance of the player whose volume was set.

getTargetPlayer()

MelodyPlayer

Returns the MelodyPlayer instance of the target player who set the volume.

Example Usage

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

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

public class VolumeListener implements Listener {

    @EventHandler
    public void onVolumeSet(PostSetVolumeEvent event) {
        // Get the player who had their volume set
        MelodyPlayer player = event.getPlayer();

        // Get the target player who set the volume
        MelodyPlayer targetPlayer = event.getTargetPlayer();

        // Log the event to the console
        Bukkit.getLogger().info(targetPlayer.getName() + " set the volume for " + player.getName());
    }
}

Remember to register your listener in your plugin's onEnable() method to ensure that it is active.

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

This example will print a message to the console whenever a player's volume is set, indicating who set the volume and for whom.

Last updated