You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 07:26:18 +00:00
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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user