Load navigator after removing a room

This commit is contained in:
Alejandro 2019-05-28 16:52:07 +03:00
parent 0a3877db1b
commit 6d23533abd
2 changed files with 38 additions and 6 deletions

View File

@ -156,6 +156,9 @@ public class NavigatorManager {
case "with_friends":
rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithFriendsIn(habbo, 25);
break;
case "highest_score":
rooms = Emulator.getGameEnvironment().getRoomManager().getTopRatedRooms(25);
break;
default:
return null;
}

View File

@ -1236,15 +1236,21 @@ public class RoomManager {
public List<Room> getGroupRooms(Habbo habbo, int limit) {
final ArrayList<Room> rooms = new ArrayList<>();
for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getGuilds(habbo.getHabboInfo().getId())) {
if (guild.getOwnerId() != habbo.getHabboInfo().getId()) {
Room room = this.getRoom(guild.getRoomId());
if (room != null) {
rooms.add(room);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM rooms INNER JOIN guilds_members ON guilds_members.guild_id = rooms.guild_id WHERE guilds_members.user_id = ? AND level_id != 3")) {
statement.setInt(1, habbo.getHabboInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
if (this.activeRooms.containsKey(set.getInt("id"))) {
rooms.add(this.activeRooms.get(set.getInt("id")));
} else {
rooms.add(new Room(set));
}
}
}
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
Collections.sort(rooms);
@ -1291,6 +1297,29 @@ public class RoomManager {
return rooms;
}
public List<Room> getTopRatedRooms(int limit) {
final ArrayList<Room> rooms = new ArrayList<>();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT * FROM rooms ORDER BY score DESC LIMIT ?")) {
statement.setInt(1, limit);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
if (this.activeRooms.containsKey(set.getInt("id"))) {
rooms.add(this.activeRooms.get(set.getInt("id")));
} else {
rooms.add(new Room(set));
}
}
}
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
return rooms;
}
public ArrayList<Room> getRoomsWithAdminRights(Habbo habbo) {
ArrayList<Room> rooms = new ArrayList<>();