From 88d68220d023f6e3ee0dd494ee6d27ee0080ddec Mon Sep 17 00:00:00 2001 From: Swirny Date: Sat, 23 May 2020 17:57:29 +0200 Subject: [PATCH] Added Ban counter to MOD Tools --- .../modtool/ModToolUserInfoComposer.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 5e1b4111..d0322384 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 @@ -11,8 +11,7 @@ import gnu.trove.map.hash.THashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.ArrayList; public class ModToolUserInfoComposer extends MessageComposer { @@ -28,6 +27,17 @@ public class ModToolUserInfoComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.ModToolUserInfoComposer); try { + int totalBans = 0; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) AS amount FROM bans WHERE user_id = ?")) { + statement.setInt(1, this.set.getInt("user_id")); + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + totalBans = set.getInt("totalBans"); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } this.response.appendInt(this.set.getInt("user_id")); this.response.appendString(this.set.getString("username")); this.response.appendString(this.set.getString("look")); @@ -42,7 +52,7 @@ public class ModToolUserInfoComposer extends MessageComposer { this.response.appendString(""); //Trading lock expiry timestamp this.response.appendString(""); //Last Purchase Timestamp this.response.appendInt(this.set.getInt("user_id")); //Personal Identification # - this.response.appendInt(0); //Number of bans + this.response.appendInt(totalBans); //Number of bans this.response.appendString(this.set.getString("mail")); this.response.appendString("Rank (" + this.set.getInt("rank_id") + "): " + this.set.getString("rank_name")); //user_class_txt