use of au.com.mineauz.minigames.stats.StatFormat in project Minigames by AddstarMC.
the class SQLiteBackend method loadStatSettings.
@Override
public Map<MinigameStat, StatSettings> loadStatSettings(Minigame minigame) {
ConnectionHandler handler = null;
try {
handler = pool.getConnection();
int minigameId = getMinigameId(handler, minigame);
ResultSet rs = handler.executeQuery(loadStatSettings, minigameId);
Map<MinigameStat, StatSettings> settings = Maps.newHashMap();
try {
while (rs.next()) {
String statName = rs.getString("stat");
String rawFormat = rs.getString("format");
String displayName = rs.getString("display_name");
MinigameStat stat = MinigameStats.getStat(statName);
if (stat == null) {
// Just ignore it
continue;
}
// Decode format
StatFormat format = null;
for (StatFormat f : StatFormat.values()) {
if (f.name().equalsIgnoreCase(rawFormat)) {
format = f;
break;
}
}
if (format == null) {
format = stat.getFormat();
}
StatSettings setting = new StatSettings(stat, format, displayName);
settings.put(stat, setting);
}
return settings;
} finally {
rs.close();
}
} catch (SQLException e) {
e.printStackTrace();
return Collections.emptyMap();
} finally {
if (handler != null) {
handler.release();
}
}
}
use of au.com.mineauz.minigames.stats.StatFormat in project Minigames by AddstarMC.
the class MySQLBackend method loadStatSettings.
@Override
public Map<MinigameStat, StatSettings> loadStatSettings(Minigame minigame) {
ConnectionHandler handler = null;
try {
handler = pool.getConnection();
int minigameId = getMinigameId(handler, minigame);
ResultSet rs = handler.executeQuery(loadStatSettings, minigameId);
Map<MinigameStat, StatSettings> settings = Maps.newHashMap();
try {
while (rs.next()) {
String statName = rs.getString("stat");
String rawFormat = rs.getString("format");
String displayName = rs.getString("display_name");
MinigameStat stat = MinigameStats.getStat(statName);
if (stat == null) {
// Just ignore it
continue;
}
// Decode format
StatFormat format = null;
for (StatFormat f : StatFormat.values()) {
if (f.name().equalsIgnoreCase(rawFormat)) {
format = f;
break;
}
}
if (format == null) {
format = stat.getFormat();
}
StatSettings setting = new StatSettings(stat, format, displayName);
settings.put(stat, setting);
}
return settings;
} finally {
rs.close();
}
} catch (SQLException e) {
e.printStackTrace();
return Collections.emptyMap();
} finally {
if (handler != null) {
handler.release();
}
}
}
Aggregations