package de.teleportsuite.managers;

import de.teleportsuite.TeleportSuite;
import de.teleportsuite.models.TeleportLocation;
import org.bukkit.entity.Player;

public class SavePointManager {
    private final TeleportSuite plugin;
    public SavePointManager(TeleportSuite plugin) { this.plugin = plugin; }

    public void setSavePoint(Player player, String name) {
        TeleportLocation loc = new TeleportLocation(player.getLocation(), plugin.getConfigManager().getServerName());
        plugin.getDatabaseManager().saveSavePoint(player.getUniqueId(), name, loc);
        player.sendMessage(plugin.getConfigManager().getMessage("savepoint-set", "name", name));
    }

    public void teleportToSavePoint(Player player, String name) {
        TeleportLocation loc = plugin.getDatabaseManager().getSavePoint(player.getUniqueId(), name);
        if (loc == null) { player.sendMessage("§cSavepoint §6" + name + " §cnicht gefunden."); return; }
        plugin.getTeleportManager().teleport(player, loc);
    }
}
