From e2f67a53ad4cef41fb9f9eb08c38044bfc5db130 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 30 May 2019 19:18:48 +0300 Subject: [PATCH] Add default saved searches --- .../com/eu/habbo/habbohotel/users/HabboStats.java | 7 +++++-- .../incoming/handshake/SecureLoginEvent.java | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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 6dc2929d..7373b749 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -81,6 +81,7 @@ public class HabboStats implements Runnable { public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); public int uiFlags; + public boolean hasGottenDefaultSavedSearches; private HabboInfo habboInfo; private boolean allowTrade; private int clubExpireTimestamp; @@ -133,6 +134,7 @@ public class HabboStats implements Runnable { this.perkTrade = set.getString("perk_trade").equalsIgnoreCase("1"); this.forumPostsCount = set.getInt("forums_post_count"); this.uiFlags = set.getInt("ui_flags"); + this.hasGottenDefaultSavedSearches = set.getInt("has_gotten_default_saved_searches") == 1; this.nuxReward = this.nux; try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) { @@ -292,7 +294,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` = ?, ui_flags = ? 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 = ?, has_gotten_default_saved_searches = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.achievementScore); statement.setInt(2, this.respectPointsReceived); statement.setInt(3, this.respectPointsGiven); @@ -326,8 +328,9 @@ 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.hasGottenDefaultSavedSearches ? 1 : 0); - statement.setInt(34, this.habboInfo.getId()); + statement.setInt(35, this.habboInfo.getId()); statement.executeUpdate(); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index b146d0e1..a899c5b0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; +import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboManager; @@ -148,6 +149,17 @@ public class SecureLoginEvent extends MessageHandler { } Messenger.checkFriendSizeProgress(habbo); + + if (!habbo.getHabboStats().hasGottenDefaultSavedSearches) { + habbo.getHabboStats().hasGottenDefaultSavedSearches = true; + Emulator.getThreading().run(habbo.getHabboStats()); + + habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("official-root", "")); + habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("my", "")); + habbo.getHabboInfo().addSavedSearch(new NavigatorSavedSearch("favorites", "")); + + this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); + } } else { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); }