mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
COUNT() always return something, statement found would be always true.
This commit is contained in:
parent
be3207eca0
commit
e76c2de94a
@ -55,16 +55,18 @@ public class GiveBadge extends RCONMessage<GiveBadge.GiveBadgeJSON> {
|
|||||||
} else {
|
} else {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
||||||
for (String badgeCode : json.badge.split(";")) {
|
for (String badgeCode : json.badge.split(";")) {
|
||||||
boolean found;
|
int numberOfRows = 0;
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.id = ? AND badge_code = ? LIMIT 1")) {
|
try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.id = ? AND badge_code = ? LIMIT 1")) {
|
||||||
statement.setInt(1, json.user_id);
|
statement.setInt(1, json.user_id);
|
||||||
statement.setString(2, badgeCode);
|
statement.setString(2, badgeCode);
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
found = set.next();
|
if (set.next()){
|
||||||
|
numberOfRows = set.getInt(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (numberOfRows != 0) {
|
||||||
this.status = RCONMessage.STATUS_ERROR;
|
this.status = RCONMessage.STATUS_ERROR;
|
||||||
this.message += Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", username).replace("%badge%", badgeCode) + "\r";
|
this.message += Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", username).replace("%badge%", badgeCode) + "\r";
|
||||||
} else {
|
} else {
|
||||||
@ -92,4 +94,4 @@ public class GiveBadge extends RCONMessage<GiveBadge.GiveBadgeJSON> {
|
|||||||
|
|
||||||
public String badge;
|
public String badge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user