From 5943d1f060ab48555017b8e6be98c8672908eda7 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 22:55:23 +0300 Subject: [PATCH 1/3] Save UI flags in database --- sqlupdates/2_0_0_TO_2_1_0-RC-1.sql | 5 ++++- .../com/eu/habbo/habbohotel/users/HabboStats.java | 8 ++++++-- .../java/com/eu/habbo/messages/PacketManager.java | 1 + .../com/eu/habbo/messages/incoming/Incoming.java | 1 + .../messages/incoming/users/UpdateUIFlagsEvent.java | 13 +++++++++++++ .../outgoing/users/MeMenuSettingsComposer.java | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java diff --git a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql index 4625f0a7..a1c78768 100644 --- a/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql +++ b/sqlupdates/2_0_0_TO_2_1_0-RC-1.sql @@ -4,4 +4,7 @@ CREATE TABLE `users_saved_searches` ( `filter` varchar(255) NULL, `user_id` int(11) NOT NULL, PRIMARY KEY (`id`) -); \ No newline at end of file +); + +ALTER TABLE `users_settings` +ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`; \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index edca1192..2e180bfc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -80,6 +80,7 @@ public class HabboStats implements Runnable { public long lastTradeTimestamp = Emulator.getIntUnixTimestamp(); public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); + public int uiFlags; private HabboInfo habboInfo; private boolean allowTrade; private int clubExpireTimestamp; @@ -131,6 +132,7 @@ public class HabboStats implements Runnable { this.allowNameChange = set.getString("allow_name_change").equalsIgnoreCase("1"); this.perkTrade = set.getString("perk_trade").equalsIgnoreCase("1"); this.forumPostsCount = set.getInt("forums_post_count"); + this.uiFlags = set.getInt("ui_flags"); this.nuxReward = this.nux; try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) { @@ -290,7 +292,7 @@ public class HabboStats implements Runnable { @Override public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ? WHERE user_id = ? LIMIT 1")) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ?, ui_flags = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.achievementScore); statement.setInt(2, this.respectPointsReceived); statement.setInt(3, this.respectPointsGiven); @@ -323,7 +325,9 @@ public class HabboStats implements Runnable { statement.setString(30, this.perkTrade ? "1" : "0"); statement.setString(31, this.allowTrade ? "1" : "0"); statement.setInt(32, this.forumPostsCount); - statement.setInt(33, this.habboInfo.getId()); + statement.setInt(33, this.uiFlags); + + statement.setInt(34, this.habboInfo.getId()); statement.executeUpdate(); } diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index b64e7481..96dfbb30 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -288,6 +288,7 @@ public class PacketManager { this.registerHandler(Incoming.ChangeNameCheckUsernameEvent, ChangeNameCheckUsernameEvent.class); this.registerHandler(Incoming.ConfirmChangeNameEvent, ConfirmChangeNameEvent.class); this.registerHandler(Incoming.ChangeChatBubbleEvent, ChangeChatBubbleEvent.class); + this.registerHandler(Incoming.UpdateUIFlagsEvent, UpdateUIFlagsEvent.class); } private void registerNavigator() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 1d961b8b..a47fd162 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -289,6 +289,7 @@ public class Incoming { public static final int DeleteSavedSearchEvent = 1954; public static final int SaveWindowSettingsEvent = 3159; public static final int GetHabboGuildBadgesMessageEvent = 21; + public static final int UpdateUIFlagsEvent = 2313; public static final int RequestCraftingRecipesEvent = 1173; public static final int RequestCraftingRecipesAvailableEvent = 3086; diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java new file mode 100644 index 00000000..8983b29e --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateUIFlagsEvent.java @@ -0,0 +1,13 @@ +package com.eu.habbo.messages.incoming.users; + +import com.eu.habbo.messages.incoming.MessageHandler; + +public class UpdateUIFlagsEvent extends MessageHandler { + @Override + public void handle() throws Exception { + int flags = this.packet.readInt(); + + this.client.getHabbo().getHabboStats().uiFlags = flags; + this.client.getHabbo().getHabboStats().run(); + } +} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java index de1d10b0..48319066 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/MeMenuSettingsComposer.java @@ -21,7 +21,7 @@ public class MeMenuSettingsComposer extends MessageComposer { this.response.appendBoolean(this.habbo.getHabboStats().preferOldChat); this.response.appendBoolean(this.habbo.getHabboStats().blockRoomInvites); this.response.appendBoolean(this.habbo.getHabboStats().blockCameraFollow); - this.response.appendInt(1); + this.response.appendInt(this.habbo.getHabboStats().uiFlags); this.response.appendInt(this.habbo.getHabboStats().chatColor.getType()); return this.response; } From ae555d29fb982e5f6531365e2bfb0b04ba82ca03 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 23:17:54 +0300 Subject: [PATCH 2/3] Add my friends category to my world in navigator --- .../navigation/NavigatorManager.java | 3 +++ .../navigation/NavigatorUserFilter.java | 6 ++++++ .../habbo/habbohotel/rooms/RoomManager.java | 20 +++++++++++++++++++ .../eu/habbo/habbohotel/users/HabboStats.java | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java index 2767a48f..070051e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -153,6 +153,9 @@ public class NavigatorManager { case "categories": rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsPromoted(); break; + case "with_friends": + rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithFriendsIn(habbo, 25); + break; default: return null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java index 997a1e5f..38f70200 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorUserFilter.java @@ -42,6 +42,12 @@ public class NavigatorUserFilter extends NavigatorFilter { i++; } + List friendRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("with_friends", habbo); + if (!friendRooms.isEmpty()) { + resultLists.add(new SearchResultList(i, "with_friends", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("with_friends"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("with_friends"), friendRooms, true, true, DisplayOrder.ORDER_NUM, i)); + i++; + } + List rightRooms = Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("with_rights", habbo); if (!rightRooms.isEmpty()) { resultLists.add(new SearchResultList(i, "with_rights", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("with_rights"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("with_rights"), rightRooms, true, true, DisplayOrder.ORDER_NUM, i)); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index de8e9241..967eb331 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -54,6 +54,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; public class RoomManager { private static final int page = 0; @@ -1271,6 +1272,25 @@ public class RoomManager { return rooms; } + public ArrayList getRoomsWithFriendsIn(Habbo habbo, int limit) { + final ArrayList rooms = new ArrayList<>(); + + for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) { + Habbo friend = Emulator.getGameEnvironment().getHabboManager().getHabbo(buddy.getId()); + + if (friend == null || friend.getHabboInfo() == null) continue; + + Room room = friend.getHabboInfo().getCurrentRoom(); + if (room != null) rooms.add(room); + + if (rooms.size() >= limit) break; + } + + Collections.sort(rooms); + + return rooms; + } + public ArrayList getRoomsWithAdminRights(Habbo habbo) { ArrayList rooms = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 2e180bfc..6dc2929d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -326,7 +326,7 @@ public class HabboStats implements Runnable { statement.setString(31, this.allowTrade ? "1" : "0"); statement.setInt(32, this.forumPostsCount); statement.setInt(33, this.uiFlags); - + statement.setInt(34, this.habboInfo.getId()); statement.executeUpdate(); } From ad6e70c4e498d4a21797f5ad1fb386bea6ea3d31 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 May 2019 23:49:01 +0300 Subject: [PATCH 3/3] Make popular groups show top hotel rooms --- .../incoming/navigator/RequestNewNavigatorRoomsEvent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 8db7fbe4..872db874 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -18,6 +18,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { String query = this.packet.readString(); if (view.equals("query")) view = "hotel_view"; + if (view.equals("groups")) view = "hotel_view"; NavigatorFilter filter = Emulator.getGameEnvironment().getNavigatorManager().filters.get(view); RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategoryBySafeCaption(view);