Fixed issue #820 about skills not being locked when reallocating skill tree.

This commit is contained in:
Ka0rX 2023-05-07 15:11:20 +01:00
parent 13440600a8
commit aa6a1d7101
2 changed files with 3 additions and 1 deletions

View File

@ -377,6 +377,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
*/
public boolean unlock(Unlockable unlockable) {
Validate.isTrue(!unlockable.isUnlockedByDefault(), "Cannot unlock an item unlocked by default");
unlockable.whenUnlocked(this);
final boolean wasLocked = unlockedItems.add(unlockable.getUnlockNamespacedKey());
// Call the event synchronously
if (wasLocked)
@ -392,6 +393,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
*/
public boolean lock(Unlockable unlockable) {
Validate.isTrue(!unlockable.isUnlockedByDefault(), "Cannot lock an item unlocked by default");
unlockable.whenLocked(this);
boolean wasUnlocked = unlockedItems.remove(unlockable.getUnlockNamespacedKey());
if (wasUnlocked)
//Calls the event synchronously

View File

@ -87,7 +87,7 @@ public class ClassSkill implements CooldownObject, Unlockable {
@Override
public void whenLocked(PlayerData playerData) {
playerData.mapBoundSkills().forEach((slot, skill) -> {
if (skill.equals(getUnlockNamespacedKey().split(":")[1]))
if (skill.equalsIgnoreCase(getUnlockNamespacedKey().split(":")[1]))
playerData.unbindSkill(slot);
});
}