Skip to content

Commit 3e16648

Browse files
committed
configurable limits for XP subtraction
1 parent 8969ae6 commit 3e16648

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/main/java/net/discordjug/javabot/data/config/guild/HelpConfig.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,17 @@ public class HelpConfig extends GuildConfigItem {
116116
private double thankExperience = 3;
117117

118118
/**
119-
* The amount that should be subtracted from every Help Account each day.
119+
* The minimum total amount of XP that should be subtracted from every Help Account each day.
120+
*/
121+
private int minDailyExperienceSubtraction = 1;
122+
123+
/**
124+
* The maximum total amount of XP that should be subtracted from every Help Account each day.
125+
*/
126+
private int maxDailyExperienceSubtraction = 50;
127+
128+
/**
129+
* The percentage of XP that should be subtracted from every Help Account each day.
120130
*/
121131
private double dailyExperienceSubtraction = 5;
122132

src/main/java/net/discordjug/javabot/systems/help/HelpExperienceJob.java

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

33
import lombok.RequiredArgsConstructor;
44
import net.discordjug.javabot.data.config.BotConfig;
5+
import net.discordjug.javabot.data.config.guild.HelpConfig;
56
import net.discordjug.javabot.data.h2db.DbHelper;
67
import net.discordjug.javabot.systems.help.dao.HelpAccountRepository;
78
import net.discordjug.javabot.util.ExceptionLogger;
@@ -31,9 +32,12 @@ public class HelpExperienceJob {
3132
public void execute() {
3233
asyncPool.execute(() -> {
3334
try {
35+
// just get the config for the first guild the bot is in, as it's not designed to work in multiple guilds anyway
36+
HelpConfig helpConfig = botConfig.get(jda.getGuilds().get(0)).getHelpConfig();
3437
helpAccountRepository.removeExperienceFromAllAccounts(
35-
// just get the config for the first guild the bot is in, as it's not designed to work in multiple guilds anyway
36-
botConfig.get(jda.getGuilds().get(0)).getHelpConfig().getDailyExperienceSubtraction(), 1, 50);
38+
helpConfig.getDailyExperienceSubtraction(),
39+
helpConfig.getMinDailyExperienceSubtraction(),
40+
helpConfig.getMaxDailyExperienceSubtraction());
3741
} catch (DataAccessException e) {
3842
ExceptionLogger.capture(e, DbHelper.class.getSimpleName());
3943
}

0 commit comments

Comments
 (0)