package net.cobem.grizzly.habbohotel.furni;

import gnu.trove.map.hash.THashMap;
import net.cobem.grizzly.Grizzly;

import java.sql.ResultSet;

public class TeleporterHandler {
    public THashMap<Integer, Integer> Links;

    public TeleporterHandler() {
        Links = new THashMap<>();

        ResultSet Teleporters = Grizzly.getStorage().query("SELECT * FROM tele_links").getTable();
        try {
            while (Teleporters.next()) {
                Links.put(Teleporters.getInt("tele_one_id"), Teleporters.getInt("tele_two_id"));
                Links.put(Teleporters.getInt("tele_two_id"), Teleporters.getInt("tele_one_id"));
            }
        } catch (Exception ex) {
        }
    }

    public int getPair(int ID) {
        if (Links.get(ID) != null) //It isn't a first linked
        {
            return Links.get(ID);
        }

        return 0;
    }

    public void addPair(int Furni, int Pair) {
        Links.put(Furni, Pair);
        Links.put(Pair, Furni);
    }
}
