From e3e9286c513a22f5fcf91d9ca6af82e4d80529ae Mon Sep 17 00:00:00 2001 From: Swirny Date: Sat, 23 May 2020 11:50:26 +0200 Subject: [PATCH 1/3] Added MOD Tools Tradelocks counter --- .../commands/AllowTradingCommand.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java index d6ab608c..ad2a16b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java @@ -38,20 +38,30 @@ public class AllowTradingCommand extends Command { return true; } else { boolean found; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) { - statement.setString(1, enabled ? "1" : "0"); - statement.setString(2, username); - found = statement.executeUpdate() > 0; - } + if (enabled == params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) { + statement.setString(1, "1"); + statement.setString(2, username); + found = statement.executeUpdate() > 0; + } + } else if (enabled == params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ?, tradelock_amount = tradelock_amount + ? WHERE users.username LIKE ?")) { + statement.setString(1, "0"); + statement.setInt(2, 1); + statement.setString(3, username); + found = statement.executeUpdate() > 0; + } - if (!found) { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.user_not_found").replace("%username%", params[1])); - return true; - } + if (!found) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.user_not_found").replace("%username%", params[1])); + return true; + } - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); + } } - } else { + } + else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.incorrect_setting").replace("%enabled%", Emulator.getTexts().getValue("generic.yes")).replace("%disabled%", Emulator.getTexts().getValue("generic.no"))); } return true; From 418bc882fa63044e1ea54196623d358b08f9f9e3 Mon Sep 17 00:00:00 2001 From: Swirny <140-Swirny@users.noreply.git.krews.org> Date: Sat, 23 May 2020 05:58:38 -0400 Subject: [PATCH 2/3] Update ModToolUserInfoComposer.java --- .../messages/outgoing/modtool/ModToolUserInfoComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java index e8ab502e..5e1b4111 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java @@ -38,7 +38,7 @@ public class ModToolUserInfoComposer extends MessageComposer { this.response.appendInt(this.set.getInt("cfh_abusive")); this.response.appendInt(this.set.getInt("cfh_warnings")); this.response.appendInt(this.set.getInt("cfh_bans")); - this.response.appendInt(0); //Trading lock count + this.response.appendInt(this.set.getInt("tradelock_amount")); this.response.appendString(""); //Trading lock expiry timestamp this.response.appendString(""); //Last Purchase Timestamp this.response.appendInt(this.set.getInt("user_id")); //Personal Identification # From a20dc373d744150bed8789ba524a63aab86fd44b Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Sun, 7 Jun 2020 02:42:54 +0200 Subject: [PATCH 3/3] Fix merge request --- sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql | 3 ++ .../commands/AllowTradingCommand.java | 52 +++++++++---------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql index c8e18803..46a1f7fa 100644 --- a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql +++ b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql @@ -18,3 +18,6 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.allow.ignore.staf INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('error.bots.max.inventory', 'You can\'t buy or pickup anymore bots until you place some, the maximum amount of bots you are allowed is %amount%.'); UPDATE `emulator_texts` SET `value` = 'You\'ve reached the maximum amount of pets in your inventory! The Limit is %amount%!' WHERE `key` = 'error.pets.max.inventory'; + +-- Tradelock counter +ALTER TABLE `users_settings` ADD `tradelock_amount` INT(11) NOT NULL DEFAULT '0' AFTER `helper_level`; \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java index ad2a16b4..649d5137 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java @@ -25,43 +25,43 @@ public class AllowTradingCommand extends Command { return true; } - if (params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")) || params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) { - String username = params[1]; - boolean enabled = params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")); + final String username = params[1]; + final String option = params[2]; - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); + if (option.equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")) || option.equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) { + final boolean enabled = option.equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")); + final Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); if (habbo != null) { + if (!enabled) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET tradelock_amount = tradelock_amount + 1 WHERE user_id = ?")) { + statement.setInt(1, habbo.getHabboInfo().getId()); + statement.executeUpdate(); + } + } habbo.getHabboStats().setAllowTrade(enabled); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); habbo.getClient().sendResponse(new UserPerksComposer(habbo)); return true; } else { boolean found; - if (enabled == params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) { - statement.setString(1, "1"); - statement.setString(2, username); - found = statement.executeUpdate() > 0; - } - } else if (enabled == params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ?, tradelock_amount = tradelock_amount + ? WHERE users.username LIKE ?")) { - statement.setString(1, "0"); - statement.setInt(2, 1); - statement.setString(3, username); - found = statement.executeUpdate() > 0; - } - - if (!found) { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.user_not_found").replace("%username%", params[1])); - return true; - } - - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.user_id SET can_trade = ?, tradelock_amount = tradelock_amount + ? WHERE users.username LIKE ?")) { + statement.setString(1, enabled ? "1" : "0"); + statement.setInt(2, enabled ? 0 : 1); + statement.setString(3, username); + found = statement.executeUpdate() > 0; } + + if (!found) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.user_not_found").replace("%username%", params[1])); + return true; + } + + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1])); } - } - else { + } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_allow_trading.incorrect_setting").replace("%enabled%", Emulator.getTexts().getValue("generic.yes")).replace("%disabled%", Emulator.getTexts().getValue("generic.no"))); } return true;