Skip to content

Commit

Permalink
Reload modifiers on remove a tick later
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSzabo committed Jul 13, 2024
1 parent ab86bd2 commit 2565363
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.aurelium.auraskills.api.ability.AbstractAbility;
import dev.aurelium.auraskills.api.mana.ManaAbility;
import dev.aurelium.auraskills.api.registry.NamespacedId;
import dev.aurelium.auraskills.api.skill.Multiplier;
import dev.aurelium.auraskills.api.skill.Skill;
import dev.aurelium.auraskills.api.stat.Stat;
import dev.aurelium.auraskills.api.stat.StatModifier;
Expand All @@ -18,7 +19,6 @@
import dev.aurelium.auraskills.common.config.Option;
import dev.aurelium.auraskills.common.jobs.JobsBatchData;
import dev.aurelium.auraskills.common.mana.ManaAbilityData;
import dev.aurelium.auraskills.api.skill.Multiplier;
import dev.aurelium.auraskills.common.ui.ActionBarType;
import dev.aurelium.auraskills.common.util.data.KeyIntPair;
import net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -117,7 +117,7 @@ public double getSkillAverage() {
for (Map.Entry<Skill, Integer> entry : skillLevels.entrySet()) {
if (entry.getKey().isEnabled()) {
sum += entry.getValue();
numEnabled ++;
numEnabled++;
}
}
return sum / (double) numEnabled;
Expand Down Expand Up @@ -298,7 +298,8 @@ private <T extends AuraSkillsModifier<V>, V> boolean removeModifier(String name,
map.remove(name);
// Reloads modifier type
if (reload) {
plugin.getStatManager().reload(this, modifier.type());
// Run a tick later to prevent invalid removing then readding of the same modifier by 3rd parties
plugin.getScheduler().executeSync(() -> plugin.getStatManager().reload(this, modifier.type()));
}
return true;
}
Expand Down Expand Up @@ -510,6 +511,7 @@ public JobsBatchData getJobsBatchData() {

/**
* Checks if the profile has not had any changes since creation
*
* @return True if profile has not been modified, false if player has leveled profile
*/
public boolean isBlankProfile() {
Expand Down

0 comments on commit 2565363

Please sign in to comment.