setVolume()

setVolume Method in MelodyManager Class

The setVolume method is a part of the MelodyManager class. It is used to set the volume for a specific player in the game. The volume level is determined based on the player's location and the target's location.

Method Signature

public void setVolume(String playerUuid, String targetSocketID, Location playerLocation, Location targetLocation)

Parameters

ParameterTypeDescription

playerUuid

String

The UUID of the player for whom the volume is to be set.

targetSocketID

String

The socket ID of the target player.

playerLocation

Location

The current location of the player.

targetLocation

Location

The current location of the target player.

Example

Here is an example of how to use the setVolume method in another plugin:

import org.bukkit.Location;
import org.bukkit.entity.Player;
import ir.taher7.melodymine.core.MelodyManager;

public class ExamplePlugin {

    public void adjustPlayerVolume(Player player, Player target) {
        String playerUuid = player.getUniqueId().toString();
        String targetSocketID = "exampleSocketID"; // Replace with actual socket ID
        Location playerLocation = player.getLocation();
        Location targetLocation = target.getLocation();
        

        MelodyManager.INSTANCE.setVolume(playerUuid, targetSocketID, playerLocation, targetLocation);

        Bukkit.getLogger().info("Set volume for player " + player.getName() + " based on location of target player " + target.getName());
    }
}

In this example, the adjustPlayerVolume method retrieves the UUIDs and locations of the player and target, and then uses these values to call the setVolume method. After the volume is set, a message is logged to the console.

Last updated