package net.cobem.grizzly.habbohotel.rooms.models;

import net.cobem.grizzly.Grizzly;
import net.cobem.grizzly.storage.DatabaseResult;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;


public class ModelHandler {
    private Map<String, Model> Models;

    public ModelHandler() {
        Grizzly.write("Loading room models... ", true, false);

        Models = new HashMap<String, Model>();

        DatabaseResult GrabModels = Grizzly.getStorage().query("SELECT * FROM room_models");

        try {
            ResultSet Results = GrabModels.getTable();

            while (Results.next()) {
                Models.put(Results.getString("id"), new Model(Results));
            }
        } catch (SQLException e) {
            //
        }

        Grizzly.write(Models.size(), false, true);
    }

    public Model get(String Name) {
        return Models.get(Name);
    }
}
