PrePlayerMuteEvent
Class Structure
Method/Variable
Type
Description
melodyPlayer
MelodyPlayer
The player who is about to be muted.
isCancelled
boolean
Determines whether the event should be cancelled or not.
Example
Here is an example of how to listen to this event:
import ir.taher7.melodymine.api.events.PrePlayerMuteEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class MyListener implements Listener {
@EventHandler
public void onPlayerMute(PrePlayerMuteEvent event) {
// Get the player who is about to be muted
MelodyPlayer player = event.getMelodyPlayer();
// Print the player's name to the console
Bukkit.getLogger().info(player.getName() + " is about to be muted.");
// If the player's name is "TAHER7", cancel the event
if (player.getName().equals("TAHER7")) {
event.setCancelled(true);
Bukkit.getLogger().info("Cancelled the mute event for boi-carti.");
}
}
}
In this example, we're listening for the PrePlayerMuteEvent
. When the event is triggered, we log the name of the player who is about to be muted. If the player's name is "TAHER7", we cancel the event and log a message to the console.
Remember to register your event listener in your plugin's onEnable
method for the event to be properly handled.
Last updated