mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Support for latest ML
This commit is contained in:
parent
be82279540
commit
dc9f1bc1aa
@ -1,9 +1,10 @@
|
||||
package net.Indyuce.mmocore.api.player.attribute;
|
||||
|
||||
import io.lumine.mythic.lib.api.stat.StatMap;
|
||||
import io.lumine.mythic.lib.api.stat.StatInstance;
|
||||
import io.lumine.mythic.lib.api.stat.handler.StatHandler;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* This fixes an issue where registering new stat modifiers in ML
|
||||
@ -13,17 +14,13 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
* This stat handler MAY call subsequent stat handlers. There might
|
||||
* be infinite recursion problems if another attr. grants extra attribute pts.
|
||||
*/
|
||||
public class MMOCoreAttributeStatHandler implements StatHandler {
|
||||
public class MMOCoreAttributeStatHandler extends StatHandler {
|
||||
private final PlayerAttribute attr;
|
||||
private final String statName;
|
||||
|
||||
public MMOCoreAttributeStatHandler(PlayerAttribute attr) {
|
||||
public MMOCoreAttributeStatHandler(ConfigurationSection config, PlayerAttribute attr) {
|
||||
super(config, "ADDITIONAL_" + attr.getId().toUpperCase().replace("-", "_"));
|
||||
|
||||
this.attr = attr;
|
||||
this.statName = "ADDITIONAL_" + attr.getId().toUpperCase().replace("-", "_");
|
||||
}
|
||||
|
||||
public String getStat() {
|
||||
return statName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,22 +28,12 @@ public class MMOCoreAttributeStatHandler implements StatHandler {
|
||||
* is not loaded yet, hence the try/catch clause
|
||||
*/
|
||||
@Override
|
||||
public void runUpdate(StatMap statMap) {
|
||||
public void runUpdate(StatInstance instance) {
|
||||
try {
|
||||
final PlayerData playerData = MMOCore.plugin.dataProvider.getDataManager().get(statMap.getPlayerData().getUniqueId());
|
||||
final PlayerData playerData = MMOCore.plugin.dataProvider.getDataManager().get(instance.getMap().getPlayerData().getUniqueId());
|
||||
playerData.getAttributes().getInstance(attr).updateStats();
|
||||
} catch (NullPointerException exception) {
|
||||
// Player data is not loaded yet so there's nothing to update.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseValue(StatMap statMap) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTotalValue(StatMap statMap) {
|
||||
return statMap.getStat(statName);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.player.attribute.MMOCoreAttributeStatHandler;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -46,8 +47,9 @@ public class AttributeManager implements MMOCoreManager {
|
||||
MMOCore.log(Level.WARNING, "Could not load attribute '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
final ConfigurationSection statsConfig = new ConfigFile(MythicLib.plugin, "", "stats").getConfig();
|
||||
for (PlayerAttribute attr : getAll()) {
|
||||
final MMOCoreAttributeStatHandler handler = new MMOCoreAttributeStatHandler(attr);
|
||||
final MMOCoreAttributeStatHandler handler = new MMOCoreAttributeStatHandler(statsConfig, attr);
|
||||
MythicLib.plugin.getStats().registerStat(handler.getStat(), handler);
|
||||
MythicLib.plugin.getStats().registerStat(handler.getStat() + "_PERCENT", handler);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class Ambers extends SkillHandler<SimpleSkillResult> implements Listener
|
||||
if (passive == null)
|
||||
return;
|
||||
|
||||
passive.getTriggeredSkill().cast(new TriggerMetadata(event.getAttacker(), event.getAttack(), event.getEntity()));
|
||||
passive.getTriggeredSkill().cast(new TriggerMetadata(event));
|
||||
}
|
||||
|
||||
public static class Amber extends BukkitRunnable {
|
||||
|
@ -45,6 +45,6 @@ public class Sneaky_Picky extends SkillHandler<SimpleSkillResult> implements Lis
|
||||
if (skill == null)
|
||||
return;
|
||||
|
||||
skill.getTriggeredSkill().cast(new TriggerMetadata(event.getAttacker(), event.getAttack(), event.getEntity()));
|
||||
skill.getTriggeredSkill().cast(new TriggerMetadata(event));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user