PlayerJoinWebEvent
Properties
Property
Type
Description
melodyPlayer
MelodyPlayer
The player who has joined the web client.
Example
Here is an example of how to listen to the PlayerJoinWebEvent
using the Bukkit event API in Java:
import ir.taher7.melodymine.api.events.PlayerJoinWebEvent;
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 onPlayerJoinWeb(PlayerJoinWebEvent event) {
String playerName = event.getMelodyPlayer().getName();
plugin.getLogger().info(playerName + " has joined the web client.");
}
}
In this example, we create a class ExampleListener
that implements the Listener
interface. Inside this class, we define a method onPlayerJoinWeb
with the @EventHandler
annotation to specify that this method should be called when the PlayerJoinWebEvent
is triggered. In the method body, we retrieve the name of the player who has joined the web client and log a message to the console.
Remember to register the event listener in your plugin's onEnable
method:
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new ExampleListener(this), this);
}
This will ensure that your onPlayerJoinWeb
method is called whenever a PlayerJoinWebEvent
is triggered.
Last updated