Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java

55 lines
1.5 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.hotelview;
import com.eu.habbo.Emulator;
import gnu.trove.map.hash.THashMap;
2020-05-04 22:24:09 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2018-07-06 15:30:00 +02:00
2018-09-28 21:25:00 +02:00
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public class HallOfFame {
2020-05-04 22:24:09 +02:00
private static final Logger LOGGER = LoggerFactory.getLogger(HallOfFame.class);
2018-07-08 23:32:00 +02:00
2018-09-28 21:25:00 +02:00
private final THashMap<Integer, HallOfFameWinner> winners = new THashMap<>();
2018-07-06 15:30:00 +02:00
2018-07-08 23:32:00 +02:00
2018-09-28 21:25:00 +02:00
private String competitionName;
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public HallOfFame() {
2019-03-18 02:22:00 +01:00
this.setCompetitionName("xmasRoomComp");
2018-07-06 15:30:00 +02:00
2019-03-18 02:22:00 +01:00
this.reload();
2018-07-06 15:30:00 +02:00
}
2018-07-08 23:32:00 +02:00
2019-05-26 20:14:53 +02:00
public void reload() {
2018-07-06 15:30:00 +02:00
this.winners.clear();
2019-05-26 20:14:53 +02:00
synchronized (this.winners) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery(Emulator.getConfig().getValue("hotelview.halloffame.query"))) {
while (set.next()) {
2018-07-06 15:30:00 +02:00
HallOfFameWinner winner = new HallOfFameWinner(set);
this.winners.put(winner.getId(), winner);
}
2019-05-26 20:14:53 +02:00
} catch (SQLException e) {
2020-05-04 22:24:09 +02:00
LOGGER.error("Caught SQL exception", e);
2018-07-06 15:30:00 +02:00
}
}
}
2019-05-26 20:14:53 +02:00
public THashMap<Integer, HallOfFameWinner> getWinners() {
2018-07-06 15:30:00 +02:00
return this.winners;
}
2019-05-26 20:14:53 +02:00
public String getCompetitionName() {
2018-07-06 15:30:00 +02:00
return this.competitionName;
}
2019-05-26 20:14:53 +02:00
void setCompetitionName(String name) {
2018-07-06 15:30:00 +02:00
this.competitionName = name;
}
}