mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
Fixed skills not unregistering on logout/changing class
This commit is contained in:
parent
0bcd11cf68
commit
39f95634a0
@ -452,6 +452,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
// Close quest data
|
// Close quest data
|
||||||
questData.close();
|
questData.close();
|
||||||
|
|
||||||
|
// Close bound skills
|
||||||
|
boundSkills.forEach((slot, info) -> info.close());
|
||||||
|
|
||||||
// Stop skill casting
|
// Stop skill casting
|
||||||
if (isCasting()) leaveSkillCasting();
|
if (isCasting()) leaveSkillCasting();
|
||||||
}
|
}
|
||||||
@ -1165,17 +1168,17 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
/**
|
/**
|
||||||
* Binds a skill to the player.
|
* Binds a skill to the player.
|
||||||
*
|
*
|
||||||
* @param slot Slot to which you're binding the skill.
|
* @param slot Slot to which you're binding the skill
|
||||||
* Use -1 to force-register the skill
|
|
||||||
* @param skill Skill being bound
|
* @param skill Skill being bound
|
||||||
*/
|
*/
|
||||||
public void bindSkill(int slot, ClassSkill skill) {
|
public void bindSkill(int slot, @NotNull ClassSkill skill) {
|
||||||
Validate.notNull(skill, "Skill cannot be null");
|
Validate.notNull(skill, "Skill cannot be null");
|
||||||
|
|
||||||
// Unbinds the previous skill (important for passive skills)
|
|
||||||
unbindSkill(slot);
|
|
||||||
|
|
||||||
if (slot >= 0) {
|
if (slot >= 0) {
|
||||||
|
|
||||||
|
// Unbinds the previous skill (important for passive skills)
|
||||||
|
unbindSkill(slot);
|
||||||
|
|
||||||
final SkillSlot skillSlot = getProfess().getSkillSlot(slot);
|
final SkillSlot skillSlot = getProfess().getSkillSlot(slot);
|
||||||
boundSkills.put(slot, new BoundSkillInfo(skillSlot, skill, this));
|
boundSkills.put(slot, new BoundSkillInfo(skillSlot, skill, this));
|
||||||
}
|
}
|
||||||
|
@ -301,22 +301,18 @@ public class SavedClassInformation implements ClassDataContainer {
|
|||||||
player.clearSkillTreePoints();
|
player.clearSkillTreePoints();
|
||||||
player.clearNodeLevels();
|
player.clearNodeLevels();
|
||||||
player.clearNodeStates();
|
player.clearNodeStates();
|
||||||
|
player.clearNodeTimesClaimed();
|
||||||
|
|
||||||
// We remove perm stats for nodes and class.
|
// Remove perm stats for nodes and class
|
||||||
for (SkillTree skillTree : player.getProfess().getSkillTrees())
|
for (SkillTree skillTree : player.getProfess().getSkillTrees())
|
||||||
for (SkillTreeNode node : skillTree.getNodes())
|
for (SkillTreeNode node : skillTree.getNodes())
|
||||||
node.getExperienceTable().removePermStats(player, node);
|
node.getExperienceTable().removePermStats(player, node);
|
||||||
if (player.getProfess().hasExperienceTable())
|
if (player.getProfess().hasExperienceTable())
|
||||||
player.getProfess().getExperienceTable().removePermStats(player, player.getProfess());
|
player.getProfess().getExperienceTable().removePermStats(player, player.getProfess());
|
||||||
|
|
||||||
while (player.hasSkillBound(0))
|
|
||||||
player.unbindSkill(0);
|
|
||||||
player.clearNodeTimesClaimed();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads this class info, applies it to the player. set class after
|
* Reads this class info, applies it to the player. set class after
|
||||||
* changing level so the player stats can be calculated based on new
|
* changing level so the player stats can be calculated based on new level
|
||||||
* level.
|
|
||||||
*/
|
*/
|
||||||
player.setLevel(level);
|
player.setLevel(level);
|
||||||
player.setExperience(experience);
|
player.setExperience(experience);
|
||||||
@ -326,6 +322,7 @@ public class SavedClassInformation implements ClassDataContainer {
|
|||||||
player.setSkillTreeReallocationPoints(skillTreeReallocationPoints);
|
player.setSkillTreeReallocationPoints(skillTreeReallocationPoints);
|
||||||
player.setSkillReallocationPoints(skillReallocationPoints);
|
player.setSkillReallocationPoints(skillReallocationPoints);
|
||||||
player.setUnlockedItems(unlockedItems);
|
player.setUnlockedItems(unlockedItems);
|
||||||
|
player.setClass(profess);
|
||||||
for (int slot : boundSkills.keySet())
|
for (int slot : boundSkills.keySet())
|
||||||
player.bindSkill(slot, profess.getSkill(boundSkills.get(slot)));
|
player.bindSkill(slot, profess.getSkill(boundSkills.get(slot)));
|
||||||
|
|
||||||
@ -351,11 +348,7 @@ public class SavedClassInformation implements ClassDataContainer {
|
|||||||
node.getExperienceTable().claimStatTriggers(player, node);
|
node.getExperienceTable().claimStatTriggers(player, node);
|
||||||
profess.getExperienceTable().claimStatTriggers(player, profess);
|
profess.getExperienceTable().claimStatTriggers(player, profess);
|
||||||
|
|
||||||
/*
|
// Unload current class information
|
||||||
* Unload current class information and set
|
|
||||||
* the new profess once everything is changed
|
|
||||||
*/
|
|
||||||
player.setClass(profess);
|
|
||||||
player.unloadClassInfo(profess);
|
player.unloadClassInfo(profess);
|
||||||
|
|
||||||
// This needs to be done at the end to make sure the MAX_HEALTH/MAX_MANA/... stats are loaded.
|
// This needs to be done at the end to make sure the MAX_HEALTH/MAX_MANA/... stats are loaded.
|
||||||
|
@ -99,12 +99,12 @@ public class PlayerStats {
|
|||||||
*/
|
*/
|
||||||
final PassiveSkillMap skillMap = data.getMMOPlayerData().getPassiveSkillMap();
|
final PassiveSkillMap skillMap = data.getMMOPlayerData().getPassiveSkillMap();
|
||||||
|
|
||||||
if (!MMOCore.plugin.configManager.passiveSkillNeedBound) {
|
//if (!MMOCore.plugin.configManager.passiveSkillNeedBound) {
|
||||||
skillMap.removeModifiers("MMOCorePassiveSkill");
|
// skillMap.removeModifiers("MMOCorePassiveSkill");
|
||||||
for (ClassSkill skill : data.getProfess().getSkills())
|
// for (ClassSkill skill : data.getProfess().getSkills())
|
||||||
if (skill.getSkill().getTrigger().isPassive())
|
// if (skill.getSkill().getTrigger().isPassive())
|
||||||
skillMap.addModifier(skill.toPassive(data));
|
// skillMap.addModifier(skill.toPassive(data));
|
||||||
}
|
//}
|
||||||
|
|
||||||
// This updates the player's class SCRIPTS
|
// This updates the player's class SCRIPTS
|
||||||
skillMap.removeModifiers("MMOCoreClassScript");
|
skillMap.removeModifiers("MMOCoreClassScript");
|
||||||
|
@ -9,13 +9,10 @@ import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
|||||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
|
||||||
import net.Indyuce.mmocore.skilltree.SkillTreeNode;
|
import net.Indyuce.mmocore.skilltree.SkillTreeNode;
|
||||||
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -61,8 +58,8 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer {
|
|||||||
data.setSkillTreePoints(skillTree.getId(), json.has(skillTree.getId()) ? json.get(skillTree.getId()).getAsInt() : 0);
|
data.setSkillTreePoints(skillTree.getId(), json.has(skillTree.getId()) ? json.get(skillTree.getId()).getAsInt() : 0);
|
||||||
}
|
}
|
||||||
data.setSkillTreePoints("global", json.has("global") ? json.get("global").getAsInt() : 0);
|
data.setSkillTreePoints("global", json.has("global") ? json.get("global").getAsInt() : 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(result.getString("skill_tree_levels"))) {
|
if (!isEmpty(result.getString("skill_tree_levels"))) {
|
||||||
JsonObject json = new JsonParser().parse(result.getString("skill_tree_levels")).getAsJsonObject();
|
JsonObject json = new JsonParser().parse(result.getString("skill_tree_levels")).getAsJsonObject();
|
||||||
for (SkillTreeNode skillTreeNode : MMOCore.plugin.skillTreeManager.getAllNodes()) {
|
for (SkillTreeNode skillTreeNode : MMOCore.plugin.skillTreeManager.getAllNodes()) {
|
||||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmocore.api.quest.trigger.SkillModifierTrigger;
|
|||||||
import net.Indyuce.mmocore.api.util.Closable;
|
import net.Indyuce.mmocore.api.util.Closable;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ public class BoundSkillInfo implements Closable {
|
|||||||
if (classSkill.getSkill().getTrigger().isPassive()) {
|
if (classSkill.getSkill().getTrigger().isPassive()) {
|
||||||
registered = classSkill.toPassive(playerData);
|
registered = classSkill.toPassive(playerData);
|
||||||
registered.register(playerData.getMMOPlayerData());
|
registered.register(playerData.getMMOPlayerData());
|
||||||
|
Bukkit.broadcastMessage("Registering passive skill " + classSkill.getSkill().getHandler().getId());
|
||||||
} else registered = null;
|
} else registered = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +66,10 @@ public class BoundSkillInfo implements Closable {
|
|||||||
open = false;
|
open = false;
|
||||||
|
|
||||||
// Unregister skill if passive
|
// Unregister skill if passive
|
||||||
if (isPassive()) registered.unregister(playerData.getMMOPlayerData());
|
if (isPassive()) {
|
||||||
|
Bukkit.broadcastMessage("Unregistered passive skill " + classSkill.getSkill().getHandler().getId());
|
||||||
|
registered.unregister(playerData.getMMOPlayerData());
|
||||||
|
}
|
||||||
|
|
||||||
// Remove skill buffs associated to the slot
|
// Remove skill buffs associated to the slot
|
||||||
skillSlot.getSkillBuffTriggers().forEach(skillBuffTrigger -> skillBuffTrigger.remove(playerData, classSkill.getSkill().getHandler()));
|
skillSlot.getSkillBuffTriggers().forEach(skillBuffTrigger -> skillBuffTrigger.remove(playerData, classSkill.getSkill().getHandler()));
|
||||||
|
Loading…
Reference in New Issue
Block a user