forked from Upstream/mmocore
Modifications to make UnlockSkillTrigger work with the rest of MMOCore.
This commit is contained in:
parent
b1b1a6eddd
commit
e518cafc85
@ -21,6 +21,8 @@ public class DefaultMMOLoader extends MMOLoader {
|
||||
return new FromTrigger(config);
|
||||
if (config.getKey().equals("stat"))
|
||||
return new StatTrigger(config);
|
||||
if (config.getKey().equals("unlock_skill"))
|
||||
return new UnlockSkillTrigger(config);
|
||||
if (config.getKey().equals("message"))
|
||||
return new MessageTrigger(config);
|
||||
if (config.getKey().equals("sound") || config.getKey().equals("playsound"))
|
||||
|
@ -550,6 +550,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
return unlockedItems.add(unlockable.getUnlockNamespacedKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks an item for the player by removing it from the unlocked items map if it is present.
|
||||
* This is mainly used to remove unlocked items when changing class or reallocating a skill tree.
|
||||
*/
|
||||
public void lock(Unlockable unlockable){
|
||||
unlockedItems.remove(unlockable.getUnlockNamespacedKey());
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = Math.max(1, level);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.StatTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
@ -105,15 +106,16 @@ public class ExperienceItem {
|
||||
* Used when the player level is reset to 0 ( reallocate point in skill tree for instance)
|
||||
* Creates an opposite playerModifier to compensate all the effect that existed before.
|
||||
*/
|
||||
public void removeStatTriggers(PlayerData playerData) {
|
||||
public void removeTriggers(PlayerData playerData) {
|
||||
for (Trigger trigger : triggers) {
|
||||
if (trigger instanceof StatTrigger statTrigger)
|
||||
statTrigger.remove(playerData);
|
||||
if (trigger instanceof Removable)
|
||||
((Removable) trigger).remove(playerData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when a player connects back to give back all the stats that he should have.
|
||||
*
|
||||
* @param playerData
|
||||
*/
|
||||
public void applyStatTriggers(PlayerData playerData) {
|
||||
|
@ -4,7 +4,6 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.ExperienceObject;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -62,7 +61,7 @@ public class ExperienceTable {
|
||||
for (ExperienceItem item : items) {
|
||||
int timesClaimed = playerData.getClaims(object, this, item);
|
||||
for (int i = 0; i < timesClaimed; i++)
|
||||
item.removeStatTriggers(playerData);
|
||||
item.removeTriggers(playerData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ public class ExperienceTable {
|
||||
int timesClaimed = playerData.getClaims(object, this, item);
|
||||
playerData.setClaims(object, this, item, 0);
|
||||
for (int i = 0; i < timesClaimed; i++)
|
||||
item.removeStatTriggers(playerData);
|
||||
item.removeTriggers(playerData);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user