setPlayerDeafen()
setPlayerDeafen Method in MelodyManager Class
setPlayerDeafen Method in MelodyManager ClassMethod Signature
public void setPlayerDeafen(MelodyPlayer melodyPlayer, boolean value)Parameters
Parameter
Type
Description
melodyPlayer
MelodyPlayer
The player whose deafen status is to be set.
value
boolean
The deafen status to be set. If true, the player will not be able to hear others in the voice chat. If false, the player will be able to hear others.
Usage
To use this method in another plugin, you need to get an instance of the MelodyManager class and call the setPlayerDeafen method on it. Here is an example:
import ir.taher7.melodymine.core.MelodyManager;
import ir.taher7.melodymine.models.MelodyPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class ExamplePlugin {
public void deafenPlayer(Player player, boolean value) {
MelodyPlayer melodyPlayer = MelodyManager.INSTANCE.getOnlinePlayer(player.getUniqueId().toString());
if (melodyPlayer != null) {
MelodyManager.INSTANCE.setPlayerDeafen(melodyPlayer, value);
Bukkit.getLogger().info("Set deafen status of player " + player.getName() + " to " + value);
}
}
}In this example, the deafenPlayer method takes a Player object and a boolean value. It retrieves the MelodyPlayer object corresponding to the Player and sets the deafen status of the MelodyPlayer to the provided boolean value. It then logs the action to the console.
Last updated