diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 1984ad28..03546504 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -651,6 +651,10 @@ public class ModToolManager { sender.getClient().sendResponse(new ModToolIssueHandledComposer(ModToolIssueHandledComposer.ABUSIVE)); } + // Reporter (the user who opened the CFH) gets their abusive + // counter bumped — the legacy stat shown in the User Info table. + bumpUserSettingCounter(issue.senderId, "cfh_abusive"); + this.updateTicketToMods(issue); this.removeTicket(issue); @@ -737,4 +741,38 @@ public class ModToolManager { return issues; } + + /** + * Increments a single integer counter on `users_settings` for the + * given user. Used by the moderation sanction handlers to bump the + * legacy counters that `ModToolUserInfoComposer` surfaces (cfh_warnings, + * cfh_bans, cfh_abusive, tradelock_amount) — historically these were + * only ever incremented by the CFH submission path, so a user could + * accumulate any number of bans/mutes without the User Info table + * reflecting it. + * + * Restricted to a whitelisted column name to keep the dynamic SQL + * safe; the caller passes a Permission-style constant. + */ + public static void bumpUserSettingCounter(int userId, String column) { + switch (column) { + case "cfh_warnings": + case "cfh_bans": + case "cfh_abusive": + case "tradelock_amount": + break; + default: + LOGGER.warn("Refusing to bump unrecognized user_settings column: {}", column); + return; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement( + "UPDATE users_settings SET " + column + " = " + column + " + 1 WHERE user_id = ?")) { + statement.setInt(1, userId); + statement.executeUpdate(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception bumping {} for user {}", column, userId, e); + } + } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java index 4c901c46..21bd1393 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolManager; import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.permissions.Permission; @@ -47,6 +48,8 @@ public class ModToolSanctionAlertEvent extends MessageHandler { } else { habbo.alert(message); } + + ModToolManager.bumpUserSettingCounter(userId, "cfh_warnings"); } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java index 1814041b..5a2c8afa 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolBanType; +import com.eu.habbo.habbohotel.modtool.ModToolManager; import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.modtool.ScripterManager; @@ -73,6 +74,7 @@ public class ModToolSanctionBanEvent extends MessageHandler { Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic); } + ModToolManager.bumpUserSettingCounter(userId, "cfh_bans"); } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ban").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java index e9356fdf..3be70cf6 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolManager; import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctions; @@ -59,6 +60,8 @@ public class ModToolSanctionMuteEvent extends MessageHandler { habbo.alert(message); this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername())); } + + ModToolManager.bumpUserSettingCounter(userId, "cfh_warnings"); } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java index 0cece3ce..d501eba5 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolManager; import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.permissions.Permission; @@ -49,6 +50,8 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler { habbo.getHabboStats().setAllowTrade(false); habbo.alert(message); } + + ModToolManager.bumpUserSettingCounter(userId, "tradelock_amount"); } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); }