Skip to content

Commit

Permalink
Fixes #104 (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongmario authored Dec 16, 2023
1 parent 2cd6506 commit 6b4ae6a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import org.jetbrains.annotations.ApiStatus;

import java.util.Arrays;
import java.util.Random;

public class PerkTreeConfig extends VirtualizedRegistry<Closure<Long>> {

@Override
@GroovyBlacklist
@ApiStatus.Internal
public void onReload() {
this.setXpFunction(null);
this.xpFunction = null;
this.setLevelCap(30);
}

Expand All @@ -30,12 +29,15 @@ public void setXpFunction(Closure<Long> func) {
GroovyLog.msg("Warning: Astral Perk xp closures must take the following parameters (int levelNumber, long previousLevelXp)").debug().post();
}
this.xpFunction = func;
((PerkLevelManagerAccessor) PerkLevelManager.INSTANCE).getLevelMap().clear();
((PerkLevelManagerAccessor) PerkLevelManager.INSTANCE).generateLevelMap();
resetLevelMap();
}

public void setLevelCap(int cap) {
PerkLevelManagerAccessor.setLevelCap(cap);
resetLevelMap();
}

private void resetLevelMap() {
((PerkLevelManagerAccessor) PerkLevelManager.INSTANCE).getLevelMap().clear();
((PerkLevelManagerAccessor) PerkLevelManager.INSTANCE).generateLevelMap();
}
Expand Down

0 comments on commit 6b4ae6a

Please sign in to comment.