Skip to content

Commit

Permalink
refactor: convert interval to millions and post-99
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy committed Apr 14, 2024
1 parent 65f9ab2 commit 4d06c93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
20 changes: 6 additions & 14 deletions src/main/java/dinkplugin/DinkPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,24 +778,16 @@ default int levelIntervalOverride() {

@ConfigItem(
keyName = "xpInterval",
name = "XP Interval",
description = "XP interval at which to fire notifications (disabled if set to 0)",
name = "Post-99 XP Interval",
description = "XP interval at which to fire notifications (in millions).<br/>" +
"Does not apply to skills that are below level 99<br/>" +
"Disabled if set to 0",
position = 27,
section = levelSection
)
@Units("M xp")
default int xpInterval() {
return 5_000_000;
}

@ConfigItem(
keyName = "ignoreXpBelowMax",
name = "Skip XP Interval below Lvl 99",
description = "Prevent XP interval notifications for levels below 99",
position = 28,
section = levelSection
)
default boolean ignoreXpBelowMax() {
return true;
return 5;
}

@ConfigItem(
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dinkplugin/notifiers/LevelNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ private void handleLevelUp(Skill skill, int level, int xp) {
checkLevelUp(enabled, skillName, previousLevel, virtualLevel);

// Check if xp milestone reached
int xpInterval = config.xpInterval();
if (enabled && xpInterval > 0 && (level >= MAX_REAL_LEVEL || !config.ignoreXpBelowMax())) {
int xpInterval = config.xpInterval() * 1_000_000;
if (enabled && xpInterval > 0 && level >= MAX_REAL_LEVEL) {
int remainder = xp % xpInterval;
if (remainder == 0 || xp - remainder > previousXp) {
log.debug("Observed XP milestone for {} to {}", skill, xp);
Expand Down Expand Up @@ -208,7 +208,7 @@ private void notifyXp() {
final int n = xpReached.size();
if (n == 0) return;

int interval = config.xpInterval();
int interval = Math.max(config.xpInterval(), 1) * 1_000_000;
Map<Skill, Integer> current = new EnumMap<>(currentXp);
List<Skill> milestones = new ArrayList<>(n);
JoiningReplacement.JoiningReplacementBuilder skillMessage = JoiningReplacement.builder().delimiter(", ");
Expand Down

0 comments on commit 4d06c93

Please sign in to comment.