diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java index 1fd869fb..5141e462 100644 --- a/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -8,6 +8,7 @@ import io.lumine.mythic.utils.plugin.LuminePlugin; import net.Indyuce.mmocore.api.ConfigFile; import net.Indyuce.mmocore.api.PlayerActionBar; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.player.attribute.AttributeModifier; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.util.debug.DebugMode; @@ -31,7 +32,6 @@ import net.Indyuce.mmocore.listener.event.PlayerPressKeyListener; import net.Indyuce.mmocore.listener.option.*; import net.Indyuce.mmocore.listener.profession.FishingListener; import net.Indyuce.mmocore.listener.profession.PlayerCollectStats; -import net.Indyuce.mmocore.loot.chest.LootChest; import net.Indyuce.mmocore.manager.*; import net.Indyuce.mmocore.manager.data.DataProvider; import net.Indyuce.mmocore.manager.data.mysql.MySQLDataProvider; @@ -55,7 +55,6 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.lang.reflect.Field; -import java.util.Iterator; import java.util.logging.Level; public class MMOCore extends LuminePlugin { @@ -116,8 +115,9 @@ public class MMOCore extends LuminePlugin { return; } - // Register MMOCore-specific target restrictions + // Register MMOCore-specific objects MythicLib.plugin.getEntities().registerRestriction(new PartyMemberTargetRestriction()); + MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject)); // Register extra objective, drop items... if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java b/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java index 108d3ebb..7dd53051 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java @@ -12,6 +12,7 @@ import net.Indyuce.mmocore.api.player.PlayerData; import org.apache.commons.lang.Validate; import java.text.DecimalFormat; +import java.util.Objects; public class AttributeModifier extends PlayerModifier { private final String attribute; @@ -74,9 +75,10 @@ public class AttributeModifier extends PlayerModifier { public AttributeModifier(ConfigObject object) { super(object.getString("key"), EquipmentSlot.OTHER, ModifierSource.OTHER); + String str = Objects.requireNonNull(object.getString("value")); + type = str.toCharArray()[str.length() - 1] == '%' ? ModifierType.RELATIVE : ModifierType.FLAT; + value = Double.parseDouble(type == ModifierType.RELATIVE ? str.substring(0, str.length() - 1) : str); this.attribute = object.getString("attribute"); - this.value = object.getDouble("value"); - type = object.getBoolean("multiplicative", false) ? ModifierType.RELATIVE : ModifierType.FLAT; } public String getAttribute() { diff --git a/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java b/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java index 445e81c8..c14f0232 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java +++ b/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java @@ -7,11 +7,10 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; /** - * General implementation for professions and classes. + * General implementation for professions, classes and attributes. *

- * An experience object is a type of object that can - * level up. It has an experience curve and table and - * can receive EXP + * An experience object is a type of object that can level up. + * It has an experience curve and table and can receive EXP * * @author jules */