Skip to content

Commit 8c66fb1

Browse files
committed
ensure precision in XP subtraction calculation
1 parent 3e16648 commit 8c66fb1

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/main/java/net/discordjug/javabot/systems/help/dao/HelpAccountRepository.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import lombok.RequiredArgsConstructor;
44
import lombok.extern.slf4j.Slf4j;
5-
import net.discordjug.javabot.data.config.BotConfig;
65
import net.discordjug.javabot.systems.help.model.HelpAccount;
76

87
import org.jetbrains.annotations.NotNull;
@@ -26,7 +25,6 @@
2625
@Repository
2726
public class HelpAccountRepository {
2827
private final JdbcTemplate jdbcTemplate;
29-
private final BotConfig botConfig;
3028

3129
/**
3230
* Inserts a new {@link HelpAccount}.
@@ -105,7 +103,7 @@ public int getTotalAccounts() throws DataAccessException {
105103
* @throws DataAccessException If an error occurs.
106104
*/
107105
public void removeExperienceFromAllAccounts(double change, int min, int max) throws DataAccessException {
108-
long rows = jdbcTemplate.execute("UPDATE help_account SET experience = GREATEST(experience - LEAST(GREATEST(experience * (? / 100), ?), ?), 0)",new CallableStatementCallback<Long>() {
106+
long rows = jdbcTemplate.execute("UPDATE help_account SET experience = GREATEST(experience - LEAST(GREATEST((experience * ?) / 100, ?), ?), 0)",new CallableStatementCallback<Long>() {
109107

110108
@Override
111109
public Long doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {

0 commit comments

Comments
 (0)