package listeners;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import net.dv8tion.jda.api.entities.TextChannel;


public class MinecraftEventListener implements Listener {
   
    private final TextChannel updateChannel; // Discord channel to send updates

    public MinecraftEventListener(TextChannel updateChannel) {
        this.updateChannel = updateChannel;
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        String playerName = event.getPlayer().getName();
        updateChannel.sendMessage("Player " + playerName + " has joined the server.").queue();
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        String playerName = event.getPlayer().getName();
        updateChannel.sendMessage("Player " + playerName + " has left the server.").queue();
    }
}
