Fixed Multiple Servers Skill Tree Bug

This commit is contained in:
Ka0rX 2023-03-19 13:33:13 +01:00
parent 57fe9f1f1b
commit ae9c396c25
4 changed files with 29 additions and 23 deletions

View File

@ -183,11 +183,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
skillTree.setupNodeStates(this);
// Stat triggers setup
if (!areStatsLoaded()) {
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
for (SkillTreeNode node : skillTree.getNodes())
node.getExperienceTable().claimStatTriggers(this, node);
}
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
for (SkillTreeNode node : skillTree.getNodes())
node.getExperienceTable().claimStatTriggers(this, node);
}
public int getPointSpent(SkillTree skillTree) {
@ -232,15 +232,18 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return nodeLevelsString.entrySet();
}
public boolean areStatsLoaded() {
// Used to see if the triggers need to be applied
for (StatInstance instance : mmoData.getStatMap().getInstances())
for (StatModifier modifier : instance.getModifiers())
public void resetTriggerStats() {
for (StatInstance instance : mmoData.getStatMap().getInstances()) {
Iterator<StatModifier> iter = instance.getModifiers().iterator();
while (iter.hasNext()) {
StatModifier modifier = iter.next();
if (modifier.getKey().startsWith(StatTrigger.TRIGGER_PREFIX))
return true;
return false;
modifier.unregister(mmoData);
}
}
}
public Map<SkillTreeNode, Integer> getNodeLevels() {
return new HashMap<>(nodeLevels);
}
@ -748,9 +751,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
final double r = Math.sin((double) t / warpTime * Math.PI);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE, getPlayer().getLocation().add(
Math.cos((double) 5 * t / warpTime + j) * r,
(double) 2 * t / warpTime,
Math.sin((double) 5 * t / warpTime + j) * r),
Math.cos((double) 5 * t / warpTime + j) * r,
(double) 2 * t / warpTime,
Math.sin((double) 5 * t / warpTime + j) * r),
1, new Particle.DustOptions(Color.PURPLE, 1.25f));
}
}.runTaskTimer(MMOCore.plugin, 0, 1);
@ -1199,7 +1202,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
* checks if they could potentially upgrade to one of these
*
* @return If the player can change its current class to
* a subclass
* a subclass
*/
@Deprecated
public boolean canChooseSubclass() {

View File

@ -101,15 +101,12 @@ public class PlayerProfessions {
for (Entry<String, JsonElement> entry : obj.getAsJsonObject("timesClaimed").entrySet())
playerData.getItemClaims().put("profession." + entry.getKey(), entry.getValue().getAsInt());
if (!playerData.areStatsLoaded()) {
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
if (profession.hasExperienceTable())
profession.getExperienceTable().claimStatTriggers(playerData, profession);
}
if (playerData.getProfess().hasExperienceTable())
playerData.getProfess().getExperienceTable().claimStatTriggers(playerData, playerData.getProfess());
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
if (profession.hasExperienceTable())
profession.getExperienceTable().claimStatTriggers(playerData, profession);
}
if (playerData.getProfess().hasExperienceTable())
playerData.getProfess().getExperienceTable().claimStatTriggers(playerData, playerData.getProfess());
}

View File

@ -37,6 +37,9 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer {
@Override
public void loadData(ResultSet result) throws SQLException {
//Reset stats linked to triggers
data.resetTriggerStats();
// Initialize custom resources
data.setMana(result.getFloat("mana"));

View File

@ -33,6 +33,9 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
public void loadData(PlayerData data) {
FileConfiguration config = new ConfigFile(data.getUniqueId()).getConfig();
//Reset stats linked to triggers.
data.resetTriggerStats();
data.setClassPoints(config.getInt("class-points", getDefaultData().getClassPoints()));
data.setSkillPoints(config.getInt("skill-points", getDefaultData().getSkillPoints()));
data.setSkillReallocationPoints(config.getInt("skill-reallocation-points", getDefaultData().getSkillReallocationPoints()));