forked from Upstream/mmocore
Merging skill update 1
This commit is contained in:
parent
841264df95
commit
786d1881bf
@ -12,15 +12,19 @@ import net.Indyuce.mmocore.api.SoundEvent;
|
|||||||
import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent;
|
import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent;
|
||||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||||
|
import net.Indyuce.mmocore.api.event.unlocking.ItemLockedEvent;
|
||||||
|
import net.Indyuce.mmocore.api.event.unlocking.ItemUnlockedEvent;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
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.player.profess.Subclass;
|
import net.Indyuce.mmocore.api.player.profess.Subclass;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.skillbinding.BoundSkillInfo;
|
||||||
import net.Indyuce.mmocore.api.player.social.FriendRequest;
|
import net.Indyuce.mmocore.api.player.social.FriendRequest;
|
||||||
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
||||||
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
||||||
|
import net.Indyuce.mmocore.api.quest.trigger.StatTrigger;
|
||||||
import net.Indyuce.mmocore.api.util.Closable;
|
import net.Indyuce.mmocore.api.util.Closable;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.experience.EXPSource;
|
import net.Indyuce.mmocore.experience.EXPSource;
|
||||||
@ -32,6 +36,8 @@ import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
|||||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||||
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
|
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
|
||||||
import net.Indyuce.mmocore.party.AbstractParty;
|
import net.Indyuce.mmocore.party.AbstractParty;
|
||||||
|
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||||
|
import net.Indyuce.mmocore.party.provided.Party;
|
||||||
import net.Indyuce.mmocore.player.ClassDataContainer;
|
import net.Indyuce.mmocore.player.ClassDataContainer;
|
||||||
import net.Indyuce.mmocore.player.CombatHandler;
|
import net.Indyuce.mmocore.player.CombatHandler;
|
||||||
import net.Indyuce.mmocore.player.Unlockable;
|
import net.Indyuce.mmocore.player.Unlockable;
|
||||||
@ -118,6 +124,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
* -Skill Books
|
* -Skill Books
|
||||||
*/
|
*/
|
||||||
private final Set<String> unlockedItems= new HashSet<>();
|
private final Set<String> unlockedItems= new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the amount of times the player has claimed some
|
* Saves the amount of times the player has claimed some
|
||||||
* exp item in exp tables, for both exp tables used
|
* exp item in exp tables, for both exp tables used
|
||||||
@ -396,12 +403,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
* @return If the item was locked when calling this method.
|
* @return If the item was locked when calling this method.
|
||||||
*/
|
*/
|
||||||
public boolean unlock(Unlockable unlockable) {
|
public boolean unlock(Unlockable unlockable) {
|
||||||
boolean wasLocked = unlockedItems.add(unlockable.getUnlockNamespacedKey());
|
final boolean wasLocked = unlockedItems.add(unlockable.getUnlockNamespacedKey());
|
||||||
|
// Call the event synchronously
|
||||||
if (wasLocked)
|
if (wasLocked)
|
||||||
//Calls the event synchronously
|
Bukkit.getScheduler().runTask(MythicLib.plugin, () -> Bukkit.getPluginManager().callEvent(new ItemUnlockedEvent(this, unlockable.getUnlockNamespacedKey())));
|
||||||
Bukkit.getScheduler().runTask(MythicLib.plugin,
|
|
||||||
() -> Bukkit.getPluginManager().callEvent(new ItemUnlockedEvent(this, unlockable.getUnlockNamespacedKey())));
|
|
||||||
|
|
||||||
return wasLocked;
|
return wasLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1174,7 +1179,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
if (isOnline())
|
if (isOnline())
|
||||||
getStats().updateStats();
|
getStats().updateStats();
|
||||||
|
|
||||||
//Loads the classUnlockedSkills
|
// Loads the classUnlockedSkills
|
||||||
profess.getSkills()
|
profess.getSkills()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(ClassSkill::isUnlockedByDefault)
|
.filter(ClassSkill::isUnlockedByDefault)
|
||||||
|
@ -5,9 +5,12 @@ import com.google.gson.JsonObject;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||||
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
|
import net.Indyuce.mmocore.player.ClassDataContainer;
|
||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
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.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -311,14 +314,12 @@ public class SavedClassInformation {
|
|||||||
player.setClass(profess);
|
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.
|
||||||
player.getPlayer().setHealth(Math.min(health, player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
player.getPlayer().setHealth(MMOCoreUtils.fixResource(health, player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
||||||
player.setMana(mana);
|
player.setMana(mana);
|
||||||
player.setStellium(stellium);
|
player.setStellium(stellium);
|
||||||
player.setStamina(stamina);
|
player.setStamina(stamina);
|
||||||
double health=this.health;
|
|
||||||
health = health == 0 ? 20 : health;
|
|
||||||
player.getPlayer().setHealth(Math.min(health,player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
|
||||||
// Updates level on exp bar
|
// Updates level on exp bar
|
||||||
player.refreshVanillaExp();
|
player.refreshVanillaExp();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.api.quest.trigger;
|
package net.Indyuce.mmocore.api.quest.trigger;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
import io.lumine.mythic.lib.api.skill.SkillBuff;
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
|
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
|
||||||
@ -19,6 +18,7 @@ public class SkillBuffTrigger extends Trigger implements Removable {
|
|||||||
|
|
||||||
public SkillBuffTrigger(MMOLineConfig config) {
|
public SkillBuffTrigger(MMOLineConfig config) {
|
||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
config.validateKeys("modifier");
|
config.validateKeys("modifier");
|
||||||
config.validateKeys("amount");
|
config.validateKeys("amount");
|
||||||
config.validateKeys("formula");
|
config.validateKeys("formula");
|
||||||
@ -27,10 +27,10 @@ public class SkillBuffTrigger extends Trigger implements Removable {
|
|||||||
String skillModifier = config.getString("modifier");
|
String skillModifier = config.getString("modifier");
|
||||||
String formula = config.getString("formula");
|
String formula = config.getString("formula");
|
||||||
List<String> targetSkills = new ArrayList<>();
|
List<String> targetSkills = new ArrayList<>();
|
||||||
for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll()) {
|
for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll())
|
||||||
if (skill.matchesFormula(formula))
|
if (skill.matchesFormula(formula))
|
||||||
targetSkills.add(skill.getHandler().getId());
|
targetSkills.add(skill.getHandler().getId());
|
||||||
}
|
|
||||||
skillBuff = new SkillBuff(buffKey, skillModifier, targetSkills, amount);
|
skillBuff = new SkillBuff(buffKey, skillModifier, targetSkills, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ public class MMOCoreUtils {
|
|||||||
: caseOnWords(item.getType().name().replace("_", " "));
|
: caseOnWords(item.getType().name().replace("_", " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double fixResource(double current, double maxStat) {
|
||||||
|
return current == 0 ? maxStat : Math.min(current, maxStat);
|
||||||
|
}
|
||||||
|
|
||||||
public static String caseOnWords(String s) {
|
public static String caseOnWords(String s) {
|
||||||
StringBuilder builder = new StringBuilder(s);
|
StringBuilder builder = new StringBuilder(s);
|
||||||
boolean isLastSpace = true;
|
boolean isLastSpace = true;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.api.player;
|
package net.Indyuce.mmocore.player;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some item that can be unlocked. All unlockables are saved in the
|
* Some item that can be unlocked. All unlockables are saved in the
|
@ -45,18 +45,20 @@ public class CastableSkill extends Skill {
|
|||||||
// Cooldown check
|
// Cooldown check
|
||||||
if (skillMeta.getCaster().getData().getCooldownMap().isOnCooldown(this)) {
|
if (skillMeta.getCaster().getData().getCooldownMap().isOnCooldown(this)) {
|
||||||
if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown",
|
if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown",
|
||||||
"cooldown",MythicLib.plugin.getMMOConfig().decimal.format(skillMeta.getCaster().getData().getCooldownMap().getCooldown(this))).send(playerData.getPlayer());
|
"cooldown", MythicLib.plugin.getMMOConfig().decimal.format(skillMeta.getCaster().getData().getCooldownMap().getCooldown(this))).send(playerData.getPlayer());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mana cost
|
// Mana cost
|
||||||
if (playerData.getMana() < getModifier("mana",playerData.getMMOPlayerData())) {
|
if (playerData.getMana() < getModifier("mana")) {
|
||||||
if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana", "mana-required",MythicLib.plugin.getMMOConfig().decimal.format((getModifier("mana",playerData.getMMOPlayerData())-playerData.getMana())),"mana", playerData.getProfess().getManaDisplay().getName()).send(playerData.getPlayer());
|
if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana",
|
||||||
|
"mana-required", MythicLib.plugin.getMMOConfig().decimal.format((getModifier("mana") - playerData.getMana())),
|
||||||
|
"mana", playerData.getProfess().getManaDisplay().getName()).send(playerData.getPlayer());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stamina cost
|
// Stamina cost
|
||||||
if (playerData.getStamina() < getModifier("stamina",skillMeta.getCaster().getData())) {
|
if (playerData.getStamina() < getModifier("stamina")) {
|
||||||
if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.no-stamina").send(playerData.getPlayer());
|
if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.no-stamina").send(playerData.getPlayer());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -77,11 +79,11 @@ public class CastableSkill extends Skill {
|
|||||||
|
|
||||||
// Cooldown
|
// Cooldown
|
||||||
double flatCooldownReduction = Math.max(0, Math.min(1, skillMeta.getCaster().getStat("COOLDOWN_REDUCTION") / 100));
|
double flatCooldownReduction = Math.max(0, Math.min(1, skillMeta.getCaster().getStat("COOLDOWN_REDUCTION") / 100));
|
||||||
CooldownInfo cooldownHandler = skillMeta.getCaster().getData().getCooldownMap().applyCooldown(this, getModifier("cooldown",casterData.getMMOPlayerData()));
|
CooldownInfo cooldownHandler = skillMeta.getCaster().getData().getCooldownMap().applyCooldown(this, getModifier("cooldown"));
|
||||||
cooldownHandler.reduceInitialCooldown(flatCooldownReduction);
|
cooldownHandler.reduceInitialCooldown(flatCooldownReduction);
|
||||||
|
|
||||||
casterData.giveMana(-getModifier("mana",skillMeta.getCaster().getData()), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
|
casterData.giveMana(-getModifier("mana"), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
|
||||||
casterData.giveStamina(-getModifier("stamina",casterData.getMMOPlayerData()), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
|
casterData.giveStamina(-getModifier("stamina"), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getTrigger().isPassive())
|
if (!getTrigger().isPassive())
|
||||||
@ -94,8 +96,7 @@ public class CastableSkill extends Skill {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getModifier(String mod, MMOPlayerData playerData) {
|
public double getModifier(String mod) {
|
||||||
return playerData.getSkillBuffMap().getSkillInstance(getHandler().getId())
|
return skill.getModifier(mod, skillLevel);
|
||||||
.getSkillModifier(mod).getTotal(skill.getModifier(mod, skillLevel));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,8 @@ import io.lumine.mythic.lib.MythicLib;
|
|||||||
import io.lumine.mythic.lib.UtilityMethods;
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.Unlockable;
|
import net.Indyuce.mmocore.player.Unlockable;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||||
|
@ -34,7 +34,7 @@ public class Neptune_Gift extends SkillHandler<SimpleSkillResult> implements Lis
|
|||||||
if (skill == null)
|
if (skill == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setAmount(event.getAmount() * (1 + skill.getTriggeredSkill().getModifier("extra", PlayerData.get(event.getPlayer()).getMMOPlayerData()) / 100));
|
event.setAmount(event.getAmount() * (1 + skill.getTriggeredSkill().getModifier("extra") / 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
|
|||||||
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.Unlockable;
|
import net.Indyuce.mmocore.player.Unlockable;
|
||||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||||
import net.Indyuce.mmocore.loot.chest.condition.ConditionInstance;
|
import net.Indyuce.mmocore.loot.chest.condition.ConditionInstance;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
Loading…
Reference in New Issue
Block a user