Package com.mmoscene.h4j.habbohotel.rooms.models

Examples of com.mmoscene.h4j.habbohotel.rooms.models.Model


        try(Connection connection = H4J.getStorage().getConnection()) {
            try(PreparedStatement statement = connection.prepareStatement("SELECT * FROM server_room_models")) {
                try(ResultSet set = statement.executeQuery()) {
                    while(set.next()) {
                        Model m = new Model();

                        m.setName(set.getString("id"));

                        m.setDoor(new Position(
                                set.getInt("door_x"),
                                set.getInt("door_y"),
                                set.getInt("door_z"),
                                set.getInt("door_dir")));

                        m.setHeightmap(set.getString("heightmap"));

                        String s_map = "";
                        String[] lines = m.getHeightmap().split(Character.toString((char) 13));

                        m.setLimitX(lines[0].length());
                        m.setLimitY(lines.length);

                        m.setSquareStates(new int[m.getLimitX()][m.getLimitY()]);
                        m.setSquareHeight(new double[m.getLimitX()][m.getLimitY()]);
                        m.setSquares(new SquareState[m.getLimitX()][m.getLimitY()]);

                        String relative = "";

                        for (int y = 0; y < m.getLimitY(); y++) {
                            if (y > 0) {
                                lines[y] = lines[y].substring(1);
                            }

                            for (int x = 0; x < m.getLimitX(); x++) {
                                String sq = lines[y].substring(x, x + 1).trim().toLowerCase();

                                if (sq.equals("x")) {
                                    m.getSquares()[x][y] = SquareState.CLOSED;
                                    m.getSquareStates()[x][y] = 0;
                                } else if (Ints.tryParse(sq) != null) {
                                    m.getSquares()[x][y] = SquareState.OPEN;
                                    m.getSquareStates()[x][y] = 1;
                                    m.getSquareHeight()[x][y] = Double.parseDouble(sq);
                                }

                                if (x == m.getDoor().getX() && y == m.getDoor().getY()) {
                                    m.getSquares()[x][y] = SquareState.OPEN;
                                    relative += m.getDoor().getZ() + "";
                                } else {
                                    if (!sq.isEmpty() && sq != null) {
                                        relative += sq;
                                    }
                                }
                            }

                            relative += (char) 13;
                        }

                        m.setRelativeHeightmap(relative);

                        for(String l : lines) {
                            if (!l.isEmpty() && l != null) {
                                s_map += l + (char) 13;
                            }
                        }

                        m.setHeightmap(s_map);

                        models.put(m.getName(), m);
                    }
                }
            }
        } catch (Exception ex) {
            H4J.getLogger(Room.class.getName()).info(ex.getMessage());
View Full Code Here

TOP

Related Classes of com.mmoscene.h4j.habbohotel.rooms.models.Model

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.