forked from Upstream/mmocore
Fixed skills not updating when using /mmocore reload
This commit is contained in:
parent
f13957b119
commit
bb73fb57df
@ -45,9 +45,6 @@ import net.Indyuce.mmocore.script.mechanic.ManaMechanic;
|
|||||||
import net.Indyuce.mmocore.script.mechanic.StaminaMechanic;
|
import net.Indyuce.mmocore.script.mechanic.StaminaMechanic;
|
||||||
import net.Indyuce.mmocore.script.mechanic.StelliumMechanic;
|
import net.Indyuce.mmocore.script.mechanic.StelliumMechanic;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
||||||
import net.Indyuce.mmocore.skill.list.Ambers;
|
|
||||||
import net.Indyuce.mmocore.skill.list.Neptune_Gift;
|
|
||||||
import net.Indyuce.mmocore.skill.list.Sneaky_Picky;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -359,7 +356,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
|
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
|
||||||
|
|
||||||
if (clearBefore)
|
if (clearBefore)
|
||||||
PlayerData.getAll().forEach(PlayerData::update);
|
PlayerData.getAll().forEach(PlayerData::reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message) {
|
public static void log(String message) {
|
||||||
|
@ -161,10 +161,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
* <p>
|
* <p>
|
||||||
* It's OK if bound skills disappear because of a configuration issue
|
* It's OK if bound skills disappear because of a configuration issue
|
||||||
* on the user's end. After all this method is only called when using
|
* on the user's end. After all this method is only called when using
|
||||||
* /reload and /reload is considered a bad practice. If any error
|
* /mmocore reload
|
||||||
* happens then just don't update the player's skill.
|
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void reload() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
profess = profess == null ? null : MMOCore.plugin.classManager.get(profess.getId());
|
profess = profess == null ? null : MMOCore.plugin.classManager.get(profess.getId());
|
||||||
@ -173,13 +172,20 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
MMOCore.log(Level.SEVERE, "[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
|
MMOCore.log(Level.SEVERE, "[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Integer> ite = boundSkills.keySet().iterator();
|
final Iterator<Integer> ite = boundSkills.keySet().iterator();
|
||||||
while (ite.hasNext()) try {
|
while (ite.hasNext())
|
||||||
int slot = ite.next();
|
try {
|
||||||
BoundSkillInfo boundSkillInfo = new BoundSkillInfo(boundSkills.get(slot));
|
final int slot = ite.next();
|
||||||
boundSkills.put(slot, boundSkillInfo);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
Bukkit.broadcastMessage("OLD " + boundSkills.get(slot).getClassSkill().getSkill().getModifierInfo("cooldown"));
|
||||||
|
|
||||||
|
boundSkills.put(slot, new BoundSkillInfo(boundSkills.get(slot)));
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage("NEW " + boundSkills.get(slot).getClassSkill().getSkill().getModifierInfo("cooldown"));
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
for (SkillTree skillTree : getProfess().getSkillTrees())
|
for (SkillTree skillTree : getProfess().getSkillTrees())
|
||||||
for (SkillTreeNode node : skillTree.getNodes())
|
for (SkillTreeNode node : skillTree.getNodes())
|
||||||
@ -528,6 +534,13 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public List<ClassSkill> getUnlockedSkills() {
|
||||||
|
return getProfess().getSkills().stream()
|
||||||
|
.filter((classSkill) -> hasUnlocked(classSkill))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAttributePoints() {
|
public int getAttributePoints() {
|
||||||
return attributePoints;
|
return attributePoints;
|
||||||
@ -1161,22 +1174,19 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
*/
|
*/
|
||||||
public void bindSkill(int slot, ClassSkill skill) {
|
public void bindSkill(int slot, ClassSkill skill) {
|
||||||
Validate.notNull(skill, "Skill cannot be null");
|
Validate.notNull(skill, "Skill cannot be null");
|
||||||
//Unbinds the previous skill (Important for passive skills.
|
|
||||||
|
// Unbinds the previous skill (Important for passive skills.
|
||||||
String skillId = skill.getSkill().getHandler().getId();
|
String skillId = skill.getSkill().getHandler().getId();
|
||||||
if (boundSkills.containsKey(slot)) boundSkills.get(slot).unbind();
|
if (boundSkills.containsKey(slot)) boundSkills.get(slot).unbind();
|
||||||
|
|
||||||
if (slot >= 0) {
|
if (slot >= 0) {
|
||||||
//We apply the skill buffs associated with the slot to the skill.
|
|
||||||
|
// We apply the skill buffs associated with the slot to the skill.
|
||||||
for (SkillModifierTrigger skillBuffTrigger : profess.getSkillSlot(slot).getSkillBuffTriggers())
|
for (SkillModifierTrigger skillBuffTrigger : profess.getSkillSlot(slot).getSkillBuffTriggers())
|
||||||
if (skillBuffTrigger.getTargetSkills().contains(skillId))
|
if (skillBuffTrigger.getTargetSkills().contains(skillId))
|
||||||
skillBuffTrigger.apply(this, skill.getSkill().getHandler());
|
skillBuffTrigger.apply(this, skill.getSkill().getHandler());
|
||||||
|
|
||||||
if (skill.getSkill().getTrigger().isPassive()) {
|
boundSkills.put(slot, new BoundSkillInfo(skill, this));
|
||||||
PassiveSkill passiveSkill = skill.toPassive(this);
|
|
||||||
passiveSkill.register(mmoData);
|
|
||||||
boundSkills.put(slot, new BoundSkillInfo(skill, this, passiveSkill.getUniqueId()));
|
|
||||||
} else {
|
|
||||||
boundSkills.put(slot, new BoundSkillInfo(skill, this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,10 +422,12 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean hasSkill(RegisteredSkill skill) {
|
public boolean hasSkill(RegisteredSkill skill) {
|
||||||
return hasSkill(skill.getHandler().getId());
|
return hasSkill(skill.getHandler().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean hasSkill(String id) {
|
public boolean hasSkill(String id) {
|
||||||
return skills.containsKey(id);
|
return skills.containsKey(id);
|
||||||
}
|
}
|
||||||
@ -456,6 +458,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
return skills.get(id);
|
return skills.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Collection<ClassSkill> getSkills() {
|
public Collection<ClassSkill> getSkills() {
|
||||||
return skills.values();
|
return skills.values();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class PlayerStats {
|
|||||||
* MythicLib. Must be ran everytime the player levels up or changes class.
|
* MythicLib. Must be ran everytime the player levels up or changes class.
|
||||||
* <p>
|
* <p>
|
||||||
* This is also called when reloading the plugin to make class setup easier,
|
* This is also called when reloading the plugin to make class setup easier,
|
||||||
* see {@link PlayerData#update()} for more info
|
* see {@link PlayerData#reload()} for more info
|
||||||
*/
|
*/
|
||||||
public synchronized void updateStats() {
|
public synchronized void updateStats() {
|
||||||
for (String stat : MMOCore.plugin.statManager.getRegistered()) {
|
for (String stat : MMOCore.plugin.statManager.getRegistered()) {
|
||||||
|
@ -108,15 +108,6 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
|||||||
return Objects.requireNonNull(modifiers.get(modifier), "Could not find modifier '" + modifier + "'").calculate(level);
|
return Objects.requireNonNull(modifiers.get(modifier), "Could not find modifier '" + modifier + "'").calculate(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the delay to launch the skill
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getDelay(PlayerData data) {
|
|
||||||
return modifiers.containsKey("delay") ? (int) modifiers.get("delay").calculate(data.getSkillLevel(getSkill())) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> calculateLore(PlayerData data) {
|
public List<String> calculateLore(PlayerData data) {
|
||||||
return calculateLore(data, data.getSkillLevel(skill));
|
return calculateLore(data, data.getSkillLevel(skill));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package net.Indyuce.mmocore.skill.binding;
|
|||||||
import io.lumine.mythic.lib.player.skill.PassiveSkill;
|
import io.lumine.mythic.lib.player.skill.PassiveSkill;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -12,17 +14,21 @@ public class BoundSkillInfo {
|
|||||||
private final PlayerData playerData;
|
private final PlayerData playerData;
|
||||||
private final ClassSkill classSkill;
|
private final ClassSkill classSkill;
|
||||||
|
|
||||||
private UUID passiveSkillId;
|
/**
|
||||||
|
* Private skills must be registered inside of MythicLib when bound.
|
||||||
|
* When set to null, the skill is NOT registered.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
private PassiveSkill registered;
|
||||||
|
|
||||||
public BoundSkillInfo(ClassSkill classSkill, PlayerData playerData) {
|
public BoundSkillInfo(ClassSkill classSkill, PlayerData playerData) {
|
||||||
this.classSkill = classSkill;
|
this.classSkill = classSkill;
|
||||||
this.playerData = playerData;
|
this.playerData = playerData;
|
||||||
}
|
|
||||||
|
|
||||||
public BoundSkillInfo(ClassSkill classSkill, PlayerData playerData, UUID passiveSkillId) {
|
if (classSkill.getSkill().getTrigger().isPassive()) {
|
||||||
this.classSkill = classSkill;
|
registered = classSkill.toPassive(playerData);
|
||||||
this.playerData = playerData;
|
registered.register(playerData.getMMOPlayerData());
|
||||||
this.passiveSkillId = passiveSkillId;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,10 +37,12 @@ public class BoundSkillInfo {
|
|||||||
public BoundSkillInfo(BoundSkillInfo info) {
|
public BoundSkillInfo(BoundSkillInfo info) {
|
||||||
this.playerData = info.getPlayerData();
|
this.playerData = info.getPlayerData();
|
||||||
this.classSkill = Objects.requireNonNull(playerData.getProfess().getSkill(info.getClassSkill().getSkill()));
|
this.classSkill = Objects.requireNonNull(playerData.getProfess().getSkill(info.getClassSkill().getSkill()));
|
||||||
info.unbind();
|
|
||||||
PassiveSkill passiveSkill = classSkill.toPassive(playerData);
|
if (classSkill.getSkill().getTrigger().isPassive()) {
|
||||||
passiveSkill.register(playerData.getMMOPlayerData());
|
info.unbind();
|
||||||
this.passiveSkillId = passiveSkill.getUniqueId();
|
registered = classSkill.toPassive(playerData);
|
||||||
|
registered.register(playerData.getMMOPlayerData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -47,25 +55,23 @@ public class BoundSkillInfo {
|
|||||||
return playerData;
|
return playerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
public boolean isPassive() {
|
||||||
public UUID getPassiveSkillId() {
|
return registered != null;
|
||||||
return passiveSkillId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used to refresh the PassiveSkill playerModifier so it is always associated to the
|
* This is used to refresh the PassiveSkill playerModifier
|
||||||
|
* so it is always associated to the right skill level.
|
||||||
*/
|
*/
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
if (classSkill.getSkill().getTrigger().isPassive()) {
|
if (isPassive()) {
|
||||||
playerData.getMMOPlayerData().getPassiveSkillMap().removeModifier(passiveSkillId);
|
registered.unregister(playerData.getMMOPlayerData());
|
||||||
PassiveSkill passiveSkill = classSkill.toPassive(playerData);
|
registered = classSkill.toPassive(playerData);
|
||||||
passiveSkill.register(playerData.getMMOPlayerData());
|
registered.register(playerData.getMMOPlayerData());
|
||||||
this.passiveSkillId = passiveSkill.getUniqueId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
if (classSkill.getSkill().getTrigger().isPassive())
|
if (isPassive()) registered.unregister(playerData.getMMOPlayerData());
|
||||||
playerData.getMMOPlayerData().getPassiveSkillMap().removeModifier(passiveSkillId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,7 @@ items:
|
|||||||
slot:
|
slot:
|
||||||
slots: [ 8,17,26,35,44,53 ]
|
slots: [ 8,17,26,35,44,53 ]
|
||||||
function: slot
|
function: slot
|
||||||
item: BOOK
|
item: GRAY_DYE
|
||||||
|
|
||||||
# Material used when the slot is empty
|
|
||||||
empty-item: GRAY_DYE
|
|
||||||
|
|
||||||
name: '&aSkill Slot {slot}'
|
name: '&aSkill Slot {slot}'
|
||||||
no-skill: '&cNone'
|
no-skill: '&cNone'
|
||||||
|
Loading…
Reference in New Issue
Block a user