Fix achievement RoomEntry

This commit is contained in:
Snaiker 2020-12-26 04:25:54 +00:00
parent 8edb5f00fa
commit 3f07f3f546
2 changed files with 19 additions and 1 deletions

View File

@ -672,7 +672,7 @@ public class RoomManager {
habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null)); habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null));
} }
if (room.getOwnerId() != habbo.getHabboInfo().getId()) { if (room.getOwnerId() != habbo.getHabboInfo().getId() && !habbo.getHabboStats().visitedRoom(room.getId())) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry")); AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry"));
} }
} }
@ -916,6 +916,9 @@ public class RoomManager {
statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(2, habbo.getHabboInfo().getId());
statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp)); statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp));
statement.execute(); statement.execute();
if (!habbo.getHabboStats().visitedRoom(room.getId()))
habbo.getHabboStats().addVisitRoom(room.getId());
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error("Caught SQL exception", e); LOGGER.error("Caught SQL exception", e);
} }

View File

@ -41,6 +41,7 @@ public class HabboStats implements Runnable {
private final THashMap<Integer, CatalogItem> recentPurchases; private final THashMap<Integer, CatalogItem> recentPurchases;
private final TIntArrayList favoriteRooms; private final TIntArrayList favoriteRooms;
private final TIntArrayList ignoredUsers; private final TIntArrayList ignoredUsers;
private TIntArrayList roomsVists;
public int achievementScore; public int achievementScore;
public int respectPointsReceived; public int respectPointsReceived;
public int respectPointsGiven; public int respectPointsGiven;
@ -106,6 +107,7 @@ public class HabboStats implements Runnable {
this.recentPurchases = new THashMap<>(0); this.recentPurchases = new THashMap<>(0);
this.favoriteRooms = new TIntArrayList(0); this.favoriteRooms = new TIntArrayList(0);
this.ignoredUsers = new TIntArrayList(0); this.ignoredUsers = new TIntArrayList(0);
this.roomsVists = new TIntArrayList(0);
this.secretRecipes = new TIntArrayList(0); this.secretRecipes = new TIntArrayList(0);
this.calendarRewardsClaimed = new TIntArrayList(0); this.calendarRewardsClaimed = new TIntArrayList(0);
@ -236,6 +238,15 @@ public class HabboStats implements Runnable {
} }
} }
} }
try (PreparedStatement loadRoomsVisit = set.getStatement().getConnection().prepareStatement("SELECT DISTINCT room_id FROM room_enter_log WHERE user_id = ?")) {
loadRoomsVisit.setInt(1, this.habboInfo.getId());
try (ResultSet roomSet = loadRoomsVisit.executeQuery()) {
while (roomSet.next()) {
this.roomsVists.add(roomSet.getInt("room_id"));
}
}
}
} }
private static HabboStats createNewStats(HabboInfo habboInfo) { private static HabboStats createNewStats(HabboInfo habboInfo) {
@ -622,6 +633,10 @@ public class HabboStats implements Runnable {
return this.favoriteRooms.contains(roomId); return this.favoriteRooms.contains(roomId);
} }
public boolean visitedRoom(int roomId) { return this.roomsVists.contains(roomId); }
public void addVisitRoom(int roomId) { this.roomsVists.add(roomId); }
public TIntArrayList getFavoriteRooms() { public TIntArrayList getFavoriteRooms() {
return this.favoriteRooms; return this.favoriteRooms;
} }