fix(rcon): report missing offline credit targets

GiveCredits treated offline UPDATE execution as success without checking whether any user row was changed. Nonexistent user ids could therefore return an offline success response while granting nothing. Use executeUpdate(), return HABBO_NOT_FOUND when no row is affected, and keep SQL errors from falling through to the offline success message.
This commit is contained in:
simoleo89
2026-06-13 15:19:53 +02:00
parent 4330bf5a62
commit b94acdf719
2 changed files with 29 additions and 1 deletions
@@ -29,10 +29,14 @@ public class GiveCredits extends RCONMessage<GiveCredits.JSONGiveCredits> {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1")) {
statement.setInt(1, object.credits);
statement.setInt(2, object.user_id);
statement.execute();
if (statement.executeUpdate() == 0) {
this.status = RCONMessage.HABBO_NOT_FOUND;
return;
}
} catch (SQLException e) {
this.status = RCONMessage.SYSTEM_ERROR;
LOGGER.error("Caught SQL exception", e);
return;
}
this.message = "offline";