Skip to content

Commit

Permalink
Merge pull request #13 from cs-jako/develop
Browse files Browse the repository at this point in the history
Possible Fix for review
  • Loading branch information
cs-jako authored Jan 8, 2024
2 parents added8a + cebb27c commit 75debbf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public boolean compact() {
public boolean showOwn() {
return this.showOwn.get();
}

public ConfigProperty<Boolean> getCompactBadges() {
return this.compactBadges;
}
}
15 changes: 15 additions & 0 deletions core/src/main/java/net/crazy/badges/core/Badges.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ protected void enable() {
configuration().size()
));

addon.configuration().getCompactBadges().addChangeListener((state) -> {
if (state) {
// Don't purge "cache" when enabling compact mode as this doesn't cause any issues
return;
}

/**
* Purge "Cache"
* Meaning: Clear the playerCache as due to the #removeIf inside BadgeTag the badges list get's updated
* This should not really be a performance bottleneck as it's just resets everything back to the beginning
* and when a player is rendered, their correct badges are loaded from the normal badges cache
*/
playerCache.clear();
});

this.logger().info("[Badges] Addon enabled.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void render(Stack stack, Entity livingEntity) {
return;
}

LinkedList<Badge> badges = new LinkedList<>(addon.playerCache.get(player.getUniqueId()));
LinkedList<Badge> badges = addon.playerCache.get(player.getUniqueId());

if (badges.isEmpty()) {
return;
Expand Down

0 comments on commit 75debbf

Please sign in to comment.