PlayerChangeControlWebEvent
Event Details
Property
Description
melodyPlayer
The MelodyPlayer
instance representing the player who changed their control settings.
control
The MelodyControl
instance representing the control settings that were changed.
Example Usage
Here is an example of how to listen to this event using the Bukkit event API in Java:
import ir.taher7.melodymine.api.events.PlayerChangeControlWebEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class ExampleListener implements Listener {
private final JavaPlugin plugin;
public ExampleListener(JavaPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerChangeControlWeb(PlayerChangeControlWebEvent event) {
String playerName = event.getMelodyPlayer().getName();
String controlType = event.getControl().getType();
boolean controlValue = event.getControl().getValue();
String message = String.format("Player %s changed their %s control to %s", playerName, controlType, controlValue ? "enabled" : "disabled");
plugin.getLogger().info(message);
}
}
In this example, we're creating a listener for the PlayerChangeControlWebEvent
. When the event is triggered, we retrieve the player's name, the type of control that was changed, and the new value of the control. We then log this information to the console.
Remember to register your listener in your plugin's onEnable
method:
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new ExampleListener(this), this);
}
Last updated