From f7539f0aae02250407c26b8f33d31f424b1381af Mon Sep 17 00:00:00 2001 From: David Silva Date: Tue, 28 Apr 2020 01:16:56 +0200 Subject: [PATCH] feat(HabboStats): update last catalogue purchase --- sqlupdates/2_3_1_TO_2_4_0-RC-1.sql | 2 ++ .../eu/habbo/habbohotel/catalog/CatalogManager.java | 2 ++ .../java/com/eu/habbo/habbohotel/users/HabboStats.java | 10 +++++++--- .../messages/incoming/catalog/CatalogBuyItemEvent.java | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql index bee4dbe3..8727e26a 100644 --- a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql +++ b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql @@ -1 +1,3 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.stickies.max', '200'); + +ALTER TABLE `users_settings` ADD COLUMN `last_purchase_timestamp` int(11) NOT NULL DEFAULT UNIX_TIMESTAMP(); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 009b0828..bcb5a67c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -1124,6 +1124,8 @@ public class CatalogManager { habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } finally { + habbo.getHabboStats().lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); + habbo.getHabboStats().run(); habbo.getHabboStats().isPurchasingFurniture = false; } } 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 7373b749..5e84e5cb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -78,7 +78,7 @@ public class HabboStats implements Runnable { public int forumPostsCount; public THashMap> ltdPurchaseLog = new THashMap<>(0); public long lastTradeTimestamp = Emulator.getIntUnixTimestamp(); - public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); + public int lastPurchaseTimestamp; public long lastGiftTimestamp = Emulator.getIntUnixTimestamp(); public int uiFlags; public boolean hasGottenDefaultSavedSearches; @@ -135,6 +135,8 @@ public class HabboStats implements Runnable { this.forumPostsCount = set.getInt("forums_post_count"); this.uiFlags = set.getInt("ui_flags"); this.hasGottenDefaultSavedSearches = set.getInt("has_gotten_default_saved_searches") == 1; + this.lastPurchaseTimestamp = set.getInt("last_purchase_timestamp"); + this.nuxReward = this.nux; try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1")) { @@ -294,7 +296,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 = ?, has_gotten_default_saved_searches = ? 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 = ?, last_purchase_timestamp = ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, this.achievementScore); statement.setInt(2, this.respectPointsReceived); statement.setInt(3, this.respectPointsGiven); @@ -329,8 +331,10 @@ public class HabboStats implements Runnable { statement.setInt(32, this.forumPostsCount); statement.setInt(33, this.uiFlags); statement.setInt(34, this.hasGottenDefaultSavedSearches ? 1 : 0); + statement.setInt(35, this.lastPurchaseTimestamp); - statement.setInt(35, this.habboInfo.getId()); + statement.setInt(36, this.habboInfo.getId()); + statement.executeUpdate(); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java index 67a89975..f7cc5ad7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java @@ -177,6 +177,8 @@ public class CatalogBuyItemEvent extends MessageHandler { this.client.sendResponse(new PurchaseOKComposer(null)); this.client.sendResponse(new InventoryRefreshComposer()); + + this.client.getHabbo().getHabboStats().lastPurchaseTimestamp = Emulator.getIntUnixTimestamp(); this.client.getHabbo().getHabboStats().run(); } return;