Files
Server/src/engine/db/handlers/dbRaceHandler.java
T

110 lines
3.7 KiB
Java
Raw Normal View History

2026-07-26 19:08:44 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2026
// https://www.magicbane.com
2022-04-30 09:41:17 -04:00
package engine.db.handlers;
2023-05-22 12:35:15 -04:00
import engine.gameManager.DbManager;
2022-04-30 09:41:17 -04:00
import org.pmw.tinylog.Logger;
2023-05-22 12:35:15 -04:00
import java.sql.Connection;
import java.sql.PreparedStatement;
2022-04-30 09:41:17 -04:00
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
2022-04-30 09:41:17 -04:00
import java.util.HashSet;
public class dbRaceHandler extends dbHandlerBase {
public dbRaceHandler() {
}
public HashSet<Integer> BEARD_COLORS_FOR_RACE(final int id) {
2023-05-22 12:35:15 -04:00
HashSet<Integer> integerSet = new HashSet<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `color` FROM `static_rune_racebeardcolor` WHERE `RaceID` = ?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next())
integerSet.add(rs.getInt(1));
} catch (SQLException e) {
Logger.error(e);
}
return integerSet;
2022-04-30 09:41:17 -04:00
}
public HashSet<Integer> HAIR_COLORS_FOR_RACE(final int id) {
2023-05-22 12:35:15 -04:00
HashSet<Integer> integerSet = new HashSet<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `color` FROM `static_rune_racehaircolor` WHERE `RaceID` = ?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next())
integerSet.add(rs.getInt(1));
} catch (SQLException e) {
Logger.error(e);
}
return integerSet;
2022-04-30 09:41:17 -04:00
}
public HashSet<Integer> SKIN_COLOR_FOR_RACE(final int id) {
2023-05-22 12:35:15 -04:00
HashSet<Integer> integerSet = new HashSet<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `color` FROM `static_rune_raceskincolor` WHERE `RaceID` = ?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next())
integerSet.add(rs.getInt(1));
} catch (SQLException e) {
Logger.error(e);
}
return integerSet;
2022-04-30 09:41:17 -04:00
}
// Rune id -> {minHeight, strHeightMod}; the rows also decide which race runes are player races
public HashMap<Integer, float[]> LOAD_RACE_HEIGHTS() {
2022-04-30 09:41:17 -04:00
HashMap<Integer, float[]> raceHeights = new HashMap<>();
2022-04-30 09:41:17 -04:00
2023-05-22 12:35:15 -04:00
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_race")) {
2022-04-30 09:41:17 -04:00
2023-05-22 12:35:15 -04:00
ResultSet rs = preparedStatement.executeQuery();
2022-04-30 09:41:17 -04:00
while (rs.next())
raceHeights.put(rs.getInt("ID"), new float[]{rs.getFloat("minHeight"), rs.getFloat("strHeightMod")});
2022-04-30 09:41:17 -04:00
} catch (SQLException e) {
2023-05-22 12:35:15 -04:00
Logger.error(e);
2022-04-30 09:41:17 -04:00
}
2023-05-22 12:35:15 -04:00
return raceHeights;
2022-04-30 09:41:17 -04:00
}
}