You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
Merge pull request #115 from simoleo89/fix/modtool-counter-bumps
fix(modtool): bump users_settings counters on every sanction
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -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"))));
|
||||
}
|
||||
|
||||
+2
@@ -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()));
|
||||
}
|
||||
|
||||
+3
@@ -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"))));
|
||||
}
|
||||
|
||||
+3
@@ -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"))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user