Skip to content

Commit

Permalink
Add jobs.income.batching.display_individual option
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jun 19, 2024
1 parent 25f6ecf commit 8b2f454
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum Option {
JOBS_INCOME_USE_FINAL_XP("jobs.income.use_final_xp", OptionType.BOOLEAN),
JOBS_INCOME_BATCHING_ENABLED("jobs.income.batching.enabled", OptionType.BOOLEAN),
JOBS_INCOME_BATCHING_INTERVAL_MS("jobs.income.batching.interval_ms", OptionType.INT),
JOBS_INCOME_BATCHING_DISPLAY_INDIVIDUAL("jobs.income.batching.display_individual", OptionType.BOOLEAN),
ENABLE_ROMAN_NUMERALS("enable_roman_numerals", OptionType.BOOLEAN),
// Damage hologram options
DAMAGE_HOLOGRAMS_ENABLED("damage_holograms.enabled", OptionType.BOOLEAN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,24 @@ private double addJobsIncome(User user, Skill skill, double amount, @Nullable Xp
}

double income = source.getIncome().getIncomeEarned(user.toApi(), source.getValues(), skill, amount);
double originalIncome = income;
boolean displayIndividual = false;

if (plugin.configBoolean(Option.JOBS_INCOME_BATCHING_ENABLED)) {
income = handleBatching(user, income); // Sets income to 0 if not enough time has passed, or gets batched income
displayIndividual = plugin.configBoolean(Option.JOBS_INCOME_BATCHING_DISPLAY_INDIVIDUAL);
}

if (income > 0 && plugin.getHookManager().isRegistered(EconomyHook.class)) {
EconomyHook economy = plugin.getHookManager().getHook(EconomyHook.class);
economy.deposit(user, income);
}
return income;
if (displayIndividual) {
// If batched and display_individual is true, show the individual income to UI instead of batched
return originalIncome;
} else {
return income;
}
}

private double handleBatching(User user, double income) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
batching:
enabled: false
interval_ms: 2000
display_individual: false
enable_roman_numerals: false
damage_holograms:
enabled: true
Expand Down

0 comments on commit 8b2f454

Please sign in to comment.