setPlayerSelfMute()

setPlayerSelfMute Method in MelodyManager Class

The setPlayerSelfMute method is a part of the MelodyManager class. This method is used to mute or unmute a player in the MelodyMine plugin.

Method Signature

public void setPlayerSelfMute(MelodyPlayer melodyPlayer, boolean value)

Parameters

ParameterTypeDescription

melodyPlayer

MelodyPlayer

The player who will be muted or unmuted.

value

boolean

The mute status to be set. true for mute and false for unmute.

Usage

To use this method, you need to have an instance of the MelodyPlayer class which represents the player you want to mute or unmute. You also need to decide the mute status.

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

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 mutePlayerExample(String playerName, boolean muteStatus) {
        Player player = Bukkit.getPlayer(playerName);
        if (player != null) {
            MelodyPlayer melodyPlayer = MelodyManager.INSTANCE.getMelodyPlayer(player.getUniqueId());
            if (melodyPlayer != null) {
                MelodyManager.INSTANCE.setPlayerSelfMute(melodyPlayer, muteStatus);
                Bukkit.getLogger().info("Set mute status of " + playerName + " to " + muteStatus);
            }
        }
    }
}

In this example, we first get the Player object from Bukkit using the player's name. Then, we get the MelodyPlayer instance for that player. Finally, we call the setPlayerSelfMute method on the MelodyManager instance to set the mute status of the player. We also log the action to the console.

Last updated