playSound()
playSound
Method in MelodyManager
Class
playSound
Method in MelodyManager
ClassThe playSound
method is used to play a sound in the MelodyMine plugin. This method can play a sound for a specific player or for all players, and the volume of the sound can be adjusted.
Method Signature
Parameters
soundName
String
The name of the sound to be played.
sendToAll
boolean
Determines whether the sound should be played for all players or not.
socketID
String
The socket ID of the player for whom the sound should be played. This is ignored if sendToAll
is true
.
volume
Double
The volume at which the sound should be played.
Example
Here is an example of how to use the playSound
method in another plugin:
In this example, the playSoundForPlayer
method in the ExamplePlugin
class retrieves the MelodyPlayer
instance for the player using their UUID. It then uses the playSound
method of the MelodyManager
class to play a sound for the player. If the sound is successfully played, a message is logged to the console. If the player is not found, a warning is logged instead.
Last updated