package de.viper.survivalplus.listeners;

import de.viper.survivalplus.commands.FriendCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

public class PlayerJoinListener implements Listener {
    private final FriendCommand friendCommand;

    public PlayerJoinListener(FriendCommand friendCommand) {
        this.friendCommand = friendCommand;
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        friendCommand.notifyFriendsOfJoin(player);
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        friendCommand.updateLastOnline(player);
    }
}