Save UI flags in database

This commit is contained in:
Alejandro 2019-05-27 22:55:23 +03:00
parent 3ec3a6aca6
commit 5943d1f060
6 changed files with 26 additions and 4 deletions

View File

@ -4,4 +4,7 @@ CREATE TABLE `users_saved_searches` (
`filter` varchar(255) NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
);
ALTER TABLE `users_settings`
ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`;

View File

@ -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();
}

View File

@ -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 {

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;
}