package de.teleportsuite.listeners;

import de.teleportsuite.TeleportSuite;
import de.teleportsuite.models.TeleportLocation;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;

public class PlayerDeathListener implements Listener {
    private final TeleportSuite plugin;
    public PlayerDeathListener(TeleportSuite plugin) { this.plugin = plugin; }

    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        var player = event.getEntity();
        TeleportLocation deathLoc = new TeleportLocation(player.getLocation(), plugin.getConfigManager().getServerName());
        plugin.getDatabaseManager().saveDeathLocation(player.getUniqueId(), deathLoc);
    }
}
