mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Merge branch 'master' into 'dev'
COUNT() always return something, statement found would be always true. See merge request morningstar/Arcturus-Community!440
This commit is contained in:
commit
b2f5c5fe71
@ -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