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
fix(rcon): bind offline respect counters correctly
GiveRespect inverted the offline SQL parameters for respects_given and respects_received. Online users received the intended counters, but offline users had the two persisted counters swapped. Bind respect_given to respects_given and respect_received to respects_received, with a contract test to keep the RCON offline path aligned.
This commit is contained in:
@@ -30,8 +30,8 @@ public class GiveRespect extends RCONMessage<GiveRespect.JSONGiveRespect> {
|
||||
habbo.getClient().sendResponse(new UserDataComposer(habbo));
|
||||
} else {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_given + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, object.respect_received);
|
||||
statement.setInt(2, object.respect_given);
|
||||
statement.setInt(1, object.respect_given);
|
||||
statement.setInt(2, object.respect_received);
|
||||
statement.setInt(3, object.daily_respects);
|
||||
statement.setInt(4, object.user_id);
|
||||
statement.execute();
|
||||
@@ -50,4 +50,4 @@ public class GiveRespect extends RCONMessage<GiveRespect.JSONGiveRespect> {
|
||||
public int respect_received = 0;
|
||||
public int daily_respects = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.eu.habbo.messages.rcon;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class GiveRespectContractTest {
|
||||
private static String giveRespectSource() throws Exception {
|
||||
return Files.readString(Path.of("src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void offlineRespectGrantBindsGivenAndReceivedToMatchingColumns() throws Exception {
|
||||
String source = giveRespectSource();
|
||||
|
||||
assertTrue(source.contains("statement.setInt(1, object.respect_given);"),
|
||||
"respects_given must be incremented with respect_given");
|
||||
assertTrue(source.contains("statement.setInt(2, object.respect_received);"),
|
||||
"respects_received must be incremented with respect_received");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user