From 97ea879d87c82f02ae64983da7beff79dab0b2d8 Mon Sep 17 00:00:00 2001 From: Jules Date: Thu, 24 Oct 2024 13:01:46 +0200 Subject: [PATCH 1/3] Updated version nb --- MMOItems-API/pom.xml | 2 +- MMOItems-Dist/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MMOItems-API/pom.xml b/MMOItems-API/pom.xml index 6d3ba447..168c8fc0 100644 --- a/MMOItems-API/pom.xml +++ b/MMOItems-API/pom.xml @@ -5,7 +5,7 @@ MMOItems net.Indyuce - 6.10-SNAPSHOT + 6.10.1-SNAPSHOT jar 4.0.0 diff --git a/MMOItems-Dist/pom.xml b/MMOItems-Dist/pom.xml index 37aa4f14..512740ab 100644 --- a/MMOItems-Dist/pom.xml +++ b/MMOItems-Dist/pom.xml @@ -5,7 +5,7 @@ MMOItems net.Indyuce - 6.10-SNAPSHOT + 6.10.1-SNAPSHOT jar 4.0.0 @@ -35,7 +35,7 @@ net.Indyuce MMOItems-API - 6.10-SNAPSHOT + 6.10.1-SNAPSHOT true diff --git a/pom.xml b/pom.xml index 827425b8..82887d44 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ net.Indyuce MMOItems pom - 6.10-SNAPSHOT + 6.10.1-SNAPSHOT MMOItems-API From f43837e2f1bb1dbf756181394e80f218a41d9dec Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 25 Oct 2024 00:05:18 +0200 Subject: [PATCH 2/3] Gave categories to all stats inside the item browser --- .../java/net/Indyuce/mmoitems/ItemStats.java | 115 ++++++++------- .../java/net/Indyuce/mmoitems/MMOItems.java | 4 +- .../net/Indyuce/mmoitems/StatCategories.java | 41 ++++++ .../java/net/Indyuce/mmoitems/api/Type.java | 20 ++- .../api/item/template/MMOItemTemplate.java | 12 +- .../api/item/template/ModifierNode.java | 4 + .../AdvancedEnchantmentsHook.java | 12 +- .../mmoitems/comp/mmocore/MMOCoreHook.java | 11 +- .../comp/mmocore/MMOCoreMMOLoader.java | 19 +-- .../mmocore/stat/AdditionalProfessionExp.java | 21 +++ .../comp/mmocore/stat/ExtraAttribute.java | 2 + .../comp/mmocore/stat/RequiredAttribute.java | 2 + .../comp/mmocore/stat/RequiredProfession.java | 2 + .../comp/mmoinventory/stat/AccessorySet.java | 2 + .../Indyuce/mmoitems/comp/rpg/HeroesHook.java | 8 +- .../Indyuce/mmoitems/comp/rpg/McMMOHook.java | 19 ++- .../Indyuce/mmoitems/manager/StatManager.java | 138 +++++++++++++----- .../Indyuce/mmoitems/manager/TypeManager.java | 7 +- .../net/Indyuce/mmoitems/stat/Abilities.java | 52 +++---- .../mmoitems/stat/ActionLeftClick.java | 2 + .../mmoitems/stat/ActionRightClick.java | 2 + .../net/Indyuce/mmoitems/stat/Amphibian.java | 2 + .../Indyuce/mmoitems/stat/ArrowParticles.java | 2 + .../mmoitems/stat/ArrowPotionEffects.java | 2 + .../mmoitems/stat/BrowserDisplayIDX.java | 17 +-- .../net/Indyuce/mmoitems/stat/CanBreak.java | 2 + .../Indyuce/mmoitems/stat/CanDeconstruct.java | 2 + .../net/Indyuce/mmoitems/stat/CanDeskin.java | 2 + .../Indyuce/mmoitems/stat/CanIdentify.java | 2 + .../Indyuce/mmoitems/stat/CanUnsocket.java | 2 + .../net/Indyuce/mmoitems/stat/Commands.java | 2 + .../Indyuce/mmoitems/stat/CompatibleIds.java | 2 + .../mmoitems/stat/CompatibleMaterials.java | 2 + .../mmoitems/stat/CompatibleTypes.java | 2 + .../net/Indyuce/mmoitems/stat/Crafting.java | 5 +- .../mmoitems/stat/CraftingPermission.java | 9 +- .../mmoitems/stat/CustomDurability.java | 2 + .../mmoitems/stat/CustomModelData.java | 2 + .../Indyuce/mmoitems/stat/CustomSounds.java | 2 + .../mmoitems/stat/DisableDeathDrop.java | 2 + .../Indyuce/mmoitems/stat/DisplayName.java | 2 + .../Indyuce/mmoitems/stat/DisplayedType.java | 8 +- .../net/Indyuce/mmoitems/stat/DyeColor.java | 2 + .../net/Indyuce/mmoitems/stat/Effects.java | 2 + .../net/Indyuce/mmoitems/stat/Elements.java | 27 ++-- .../net/Indyuce/mmoitems/stat/Enchants.java | 2 + .../mmoitems/stat/FallDamageMultiplier.java | 2 + .../net/Indyuce/mmoitems/stat/GemColor.java | 2 + .../net/Indyuce/mmoitems/stat/GemSockets.java | 23 ++- .../mmoitems/stat/GemUpgradeScaling.java | 2 + .../mmoitems/stat/GrantedPermissions.java | 9 +- .../mmoitems/stat/HideDurabilityBar.java | 4 +- .../net/Indyuce/mmoitems/stat/HideDye.java | 2 + .../Indyuce/mmoitems/stat/HideEnchants.java | 2 + .../mmoitems/stat/HidePotionEffects.java | 2 + .../net/Indyuce/mmoitems/stat/HideTrim.java | 2 + .../net/Indyuce/mmoitems/stat/ItemDamage.java | 3 + .../net/Indyuce/mmoitems/stat/ItemLevel.java | 8 +- .../Indyuce/mmoitems/stat/ItemParticles.java | 4 +- .../Indyuce/mmoitems/stat/ItemSetStat.java | 2 + .../Indyuce/mmoitems/stat/ItemTierStat.java | 2 + .../mmoitems/stat/ItemTypeRestriction.java | 2 + .../java/net/Indyuce/mmoitems/stat/Lore.java | 2 + .../net/Indyuce/mmoitems/stat/LoreFormat.java | 53 +++---- .../Indyuce/mmoitems/stat/LostWhenBroken.java | 2 + .../mmoitems/stat/LuteAttackEffectStat.java | 6 + .../mmoitems/stat/LuteAttackSoundStat.java | 6 + .../net/Indyuce/mmoitems/stat/ManaCost.java | 3 +- .../Indyuce/mmoitems/stat/MaterialStat.java | 2 + .../net/Indyuce/mmoitems/stat/MaxConsume.java | 3 + .../Indyuce/mmoitems/stat/MaxItemDamage.java | 1 + .../mmoitems/stat/MaximumDurability.java | 7 +- .../net/Indyuce/mmoitems/stat/NBTTags.java | 2 + .../mmoitems/stat/PermanentEffects.java | 6 +- .../net/Indyuce/mmoitems/stat/Permission.java | 2 + .../Indyuce/mmoitems/stat/PickaxePower.java | 2 + .../Indyuce/mmoitems/stat/PotionColor.java | 2 + .../Indyuce/mmoitems/stat/PotionEffects.java | 2 + .../mmoitems/stat/ProjectileParticles.java | 3 +- .../Indyuce/mmoitems/stat/RandomUnsocket.java | 2 + .../Indyuce/mmoitems/stat/RepairPower.java | 2 + .../mmoitems/stat/RepairPowerPercent.java | 2 + .../mmoitems/stat/RepairReference.java | 2 + .../Indyuce/mmoitems/stat/RequiredBiomes.java | 2 + .../Indyuce/mmoitems/stat/RequiredClass.java | 2 + .../Indyuce/mmoitems/stat/RequiredLevel.java | 2 + .../Indyuce/mmoitems/stat/RestoreFood.java | 8 +- .../Indyuce/mmoitems/stat/RestoreHealth.java | 2 + .../Indyuce/mmoitems/stat/RestoreMana.java | 2 + .../mmoitems/stat/RestoreSaturation.java | 2 + .../Indyuce/mmoitems/stat/RestoreStamina.java | 2 + .../net/Indyuce/mmoitems/stat/RevisionID.java | 15 +- .../mmoitems/stat/ShieldPatternStat.java | 2 + .../mmoitems/stat/SkullTextureStat.java | 2 + .../net/Indyuce/mmoitems/stat/StoredTags.java | 2 + .../Indyuce/mmoitems/stat/SuccessRate.java | 20 ++- .../Indyuce/mmoitems/stat/TooltipStat.java | 11 +- .../mmoitems/stat/TrimMaterialStat.java | 2 + .../mmoitems/stat/TrimPatternStat.java | 2 + .../Indyuce/mmoitems/stat/Unbreakable.java | 2 + .../Indyuce/mmoitems/stat/Unstackable.java | 2 + .../Indyuce/mmoitems/stat/UpgradeStat.java | 2 + .../mmoitems/stat/VanillaEatingAnimation.java | 8 +- .../stat/annotation/DeprecatedStat.java | 8 - .../Indyuce/mmoitems/stat/block/BlockID.java | 2 + .../mmoitems/stat/block/GenTemplate.java | 2 + .../Indyuce/mmoitems/stat/block/MaxXP.java | 2 + .../Indyuce/mmoitems/stat/block/MinXP.java | 2 + .../stat/block/RequirePowerToBreak.java | 2 + .../mmoitems/stat/block/RequiredPower.java | 2 + .../mmoitems/stat/category/StatCategory.java | 52 ++++++- .../stat/component/DoubleComponent.java | 14 ++ .../stat/component/IntegerComponent.java | 14 ++ .../mmoitems/stat/component/Mergeable.java | 6 +- .../stat/component/ObjectComponent.java | 49 +++++++ .../stat/component/StatComponent.java | 12 -- .../mmoitems/stat/component/Upgradable.java | 6 +- .../type/AbstractObjectComponent.java | 36 ----- .../stat/component/type/ComponentType.java | 4 + .../stat/component/type/DoubleComponent.java | 20 --- .../component/type/DoubleComponentType.java | 11 ++ .../component/type/IntegerComponentType.java | 16 ++ .../stat/component/type/ObjectComponent.java | 37 ----- .../component/type/ObjectComponentType.java | 16 ++ .../stat/legacy/LegacyConfigAdapter.java | 26 ++++ .../stat/legacy/LegacyConfigAdapters.java | 29 ++++ .../mmoitems/stat/type/DisableStat.java | 25 ++-- .../mmoitems/stat/type/DoubleStat.java | 24 +-- .../mmoitems/stat/type/FakeElementalStat.java | 2 +- .../mmoitems/stat/type/InternalStat.java | 5 +- .../Indyuce/mmoitems/stat/type/ItemStat.java | 28 ++-- .../mmoitems/stat/type/TemplateOption.java | 51 +------ .../src/main/resources/default/item-types.yml | 1 + .../main/resources/default/language/stats.yml | 2 +- 134 files changed, 902 insertions(+), 480 deletions(-) create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/StatCategories.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/AdditionalProfessionExp.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/DeprecatedStat.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapter.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapters.java diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java index bf20be42..8344a93c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java @@ -2,7 +2,6 @@ package net.Indyuce.mmoitems; import io.lumine.mythic.lib.version.VMaterial; import net.Indyuce.mmoitems.stat.*; -import net.Indyuce.mmoitems.stat.annotation.DeprecatedStat; import net.Indyuce.mmoitems.stat.block.*; import net.Indyuce.mmoitems.stat.type.*; import org.bukkit.Material; @@ -69,44 +68,44 @@ public class ItemStats { REQUIRED_CLASS = new RequiredClass(), ATTACK_DAMAGE = new AttackDamage(), ATTACK_SPEED = new AttackSpeed(), - CRITICAL_STRIKE_CHANCE = new DoubleStat("CRITICAL_STRIKE_CHANCE", Material.NETHER_STAR, "Critical Strike Chance", new String[]{"Critical Strikes deal more damage.", "In % chance."}, new String[]{"!miscellaneous", "!block", "all"}), - CRITICAL_STRIKE_POWER = new DoubleStat("CRITICAL_STRIKE_POWER", Material.NETHER_STAR, "Critical Strike Power", new String[]{"The extra damage weapon crits deals.", "(Stacks with default value)", "In %."}, new String[]{"!miscellaneous", "!block", "all"}), - SKILL_CRITICAL_STRIKE_CHANCE = new DoubleStat("SKILL_CRITICAL_STRIKE_CHANCE", Material.NETHER_STAR, "Skill Critical Strike Chance", new String[]{"Increases the chance of dealing skill crits (in %)."}, new String[]{"!miscellaneous", "!block", "all"}), - SKILL_CRITICAL_STRIKE_POWER = new DoubleStat("SKILL_CRITICAL_STRIKE_POWER", Material.NETHER_STAR, "Skill Critical Strike Power", new String[]{"Extra damage dealt (in %) by skill crits.", "(Stacks with default value)", "In %."}, new String[]{"!miscellaneous", "!block", "all"}), - BLOCK_POWER = new DoubleStat("BLOCK_POWER", Material.IRON_HELMET, "Block Power", new String[]{"The % of the damage your", "armor/shield can block.", "Default: 25%"}, new String[]{"!miscellaneous", "!block", "all"}), - BLOCK_RATING = new DoubleStat("BLOCK_RATING", Material.IRON_HELMET, "Block Rating", new String[]{"The chance your piece of armor", "has to block any entity attack."}, new String[]{"!miscellaneous", "!block", "all"}), - BLOCK_COOLDOWN_REDUCTION = new DoubleStat("BLOCK_COOLDOWN_REDUCTION", Material.IRON_HELMET, "Block Cooldown Reduction", new String[]{"Reduces the blocking cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}), - DODGE_RATING = new DoubleStat("DODGE_RATING", Material.FEATHER, "Dodge Rating", new String[]{"The chance to dodge an attack.", "Dodging completely negates", "the attack damage."}, new String[]{"!miscellaneous", "!block", "all"}), - DODGE_COOLDOWN_REDUCTION = new DoubleStat("DODGE_COOLDOWN_REDUCTION", Material.FEATHER, "Dodge Cooldown Reduction", new String[]{"Reduces the dodging cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}), - PARRY_RATING = new DoubleStat("PARRY_RATING", Material.BUCKET, "Parry Rating", new String[]{"The chance to parry an attack.", "Parrying negates the damage", "and knocks the attacker back."}, new String[]{"!miscellaneous", "!block", "all"}), - PARRY_COOLDOWN_REDUCTION = new DoubleStat("PARRY_COOLDOWN_REDUCTION", Material.BUCKET, "Parry Cooldown Reduction", new String[]{"Reduces the parrying cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}), - COOLDOWN_REDUCTION = new DoubleStat("COOLDOWN_REDUCTION", Material.BOOK, "Cooldown Reduction", new String[]{"Reduces cooldowns of item and player skills (%)."}), - RANGE = new DoubleStat("RANGE", Material.STICK, "Range", new String[]{"The range of your item attacks."}, new String[]{"staff", "whip", "wand", "musket", "gem_stone"}), + CRITICAL_STRIKE_CHANCE = new DoubleStat("CRITICAL_STRIKE_CHANCE", Material.NETHER_STAR, "Critical Strike Chance", new String[]{"Critical Strikes deal more damage.", "In % chance."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + CRITICAL_STRIKE_POWER = new DoubleStat("CRITICAL_STRIKE_POWER", Material.NETHER_STAR, "Critical Strike Power", new String[]{"The extra damage weapon crits deals.", "(Stacks with default value)", "In %."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + SKILL_CRITICAL_STRIKE_CHANCE = new DoubleStat("SKILL_CRITICAL_STRIKE_CHANCE", Material.NETHER_STAR, "Skill Critical Strike Chance", new String[]{"Increases the chance of dealing skill crits (in %)."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + SKILL_CRITICAL_STRIKE_POWER = new DoubleStat("SKILL_CRITICAL_STRIKE_POWER", Material.NETHER_STAR, "Skill Critical Strike Power", new String[]{"Extra damage dealt (in %) by skill crits.", "(Stacks with default value)", "In %."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + BLOCK_POWER = new DoubleStat("BLOCK_POWER", Material.IRON_HELMET, "Block Power", new String[]{"The % of the damage your", "armor/shield can block.", "Default: 25%"}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + BLOCK_RATING = new DoubleStat("BLOCK_RATING", Material.IRON_HELMET, "Block Rating", new String[]{"The chance your piece of armor", "has to block any entity attack."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + BLOCK_COOLDOWN_REDUCTION = new DoubleStat("BLOCK_COOLDOWN_REDUCTION", Material.IRON_HELMET, "Block Cooldown Reduction", new String[]{"Reduces the blocking cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + DODGE_RATING = new DoubleStat("DODGE_RATING", Material.FEATHER, "Dodge Rating", new String[]{"The chance to dodge an attack.", "Dodging completely negates", "the attack damage."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + DODGE_COOLDOWN_REDUCTION = new DoubleStat("DODGE_COOLDOWN_REDUCTION", Material.FEATHER, "Dodge Cooldown Reduction", new String[]{"Reduces the dodging cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + PARRY_RATING = new DoubleStat("PARRY_RATING", Material.BUCKET, "Parry Rating", new String[]{"The chance to parry an attack.", "Parrying negates the damage", "and knocks the attacker back."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + PARRY_COOLDOWN_REDUCTION = new DoubleStat("PARRY_COOLDOWN_REDUCTION", Material.BUCKET, "Parry Cooldown Reduction", new String[]{"Reduces the parrying cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}).setCategory(StatCategories.OFFENSE), + COOLDOWN_REDUCTION = new DoubleStat("COOLDOWN_REDUCTION", Material.BOOK, "Cooldown Reduction", new String[]{"Reduces cooldowns of item and player skills (%)."}).setCategory(StatCategories.OFFENSE), + RANGE = new DoubleStat("RANGE", Material.STICK, "Range", new String[]{"The range of your item attacks."}, new String[]{"staff", "whip", "wand", "musket", "gem_stone"}).setCategory(StatCategories.RANGED_WEAPONS), MANA_COST = new ManaCost(), - STAMINA_COST = new DoubleStat("STAMINA_COST", Material.LIGHT_GRAY_DYE, "Stamina Cost", new String[]{"Stamina spent by your weapon to be used."}, new String[]{"weapon"}), - ARROW_VELOCITY = new DoubleStat("ARROW_VELOCITY", Material.ARROW, "Arrow Velocity", new String[]{"Determines how far your", "weapon can shoot.", "Default: 1.0"}, new String[]{"gem_stone", "bow", "crossbow"}), + STAMINA_COST = new DoubleStat("STAMINA_COST", Material.LIGHT_GRAY_DYE, "Stamina Cost", new String[]{"Stamina spent by your weapon to be used."}, new String[]{"weapon"}).setCategory(StatCategories.USE_COST), + ARROW_VELOCITY = new DoubleStat("ARROW_VELOCITY", Material.ARROW, "Arrow Velocity", new String[]{"Determines how far your", "weapon can shoot.", "Default: 1.0"}, new String[]{"gem_stone", "bow", "crossbow"}).setCategory(StatCategories.RANGED_WEAPONS), ARROW_POTION_EFFECTS = new ArrowPotionEffects(), - PVE_DAMAGE = new DoubleStat("PVE_DAMAGE", Material.PORKCHOP, "PvE Damage", new String[]{"Additional damage against", "non human entities in %."}, new String[]{"equipment", "gem_stone"}), - PVP_DAMAGE = new DoubleStat("PVP_DAMAGE", Material.SKELETON_SKULL, "PvP Damage", new String[]{"Additional damage", "against players in %."}, new String[]{"equipment", "gem_stone"}), - BLUNT_POWER = new DoubleStat("BLUNT_POWER", Material.IRON_AXE, "Blunt Power", new String[]{"The radius of the AoE attack.", "If set to 2.0, enemies within 2 blocks", "around your target will take damage.", "&9This stat only applies to Blunt weapons."}, new String[]{"weapon", "gem_stone"}), - BLUNT_RATING = new DoubleStat("BLUNT_RATING", Material.BRICK, "Blunt Rating", new String[]{"The force of the blunt attack.", "If set to 50%, enemies hit by the attack", "will take 50% of the initial damage.", "&9This stat only applies to Blunt weapons."}, new String[]{"weapon", "gem_stone"}), - WEAPON_DAMAGE = new DoubleStat("WEAPON_DAMAGE", Material.IRON_SWORD, "Weapon Damage", new String[]{"Additional on-hit weapon damage in %."}), - SKILL_DAMAGE = new DoubleStat("SKILL_DAMAGE", Material.BOOK, "Skill Damage", new String[]{"Additional ability damage in %."}), - PROJECTILE_DAMAGE = new DoubleStat("PROJECTILE_DAMAGE", Material.ARROW, "Projectile Damage", new String[]{"Additional skill/weapon projectile damage."}), - MAGIC_DAMAGE = new DoubleStat("MAGIC_DAMAGE", Material.MAGMA_CREAM, "Magic Damage", new String[]{"Additional magic skill damage in %."}), - PHYSICAL_DAMAGE = new DoubleStat("PHYSICAL_DAMAGE", Material.IRON_AXE, "Physical Damage", new String[]{"Additional skill/weapon physical damage."}), - DEFENSE = new DoubleStat("DEFENSE", Material.SHIELD, "Defense", new String[]{"Reduces damage from any source.", "Formula can be set in MMOLib Config."}), - DAMAGE_REDUCTION = new DoubleStat("DAMAGE_REDUCTION", Material.IRON_CHESTPLATE, "Damage Reduction", new String[]{"Reduces damage from any source.", "In %."}), - FALL_DAMAGE_REDUCTION = new DoubleStat("FALL_DAMAGE_REDUCTION", Material.FEATHER, "Fall Damage Reduction", new String[]{"Reduces fall damage.", "In %."}), - PROJECTILE_DAMAGE_REDUCTION = new DoubleStat("PROJECTILE_DAMAGE_REDUCTION", Material.SNOWBALL, "Projectile Damage Reduction", new String[]{"Reduces projectile damage.", "In %."}), - PHYSICAL_DAMAGE_REDUCTION = new DoubleStat("PHYSICAL_DAMAGE_REDUCTION", Material.LEATHER_CHESTPLATE, "Physical Damage Reduction", new String[]{"Reduces physical damage.", "In %."}), - FIRE_DAMAGE_REDUCTION = new DoubleStat("FIRE_DAMAGE_REDUCTION", Material.BLAZE_POWDER, "Fire Damage Reduction", new String[]{"Reduces fire damage.", "In %."}), - MAGIC_DAMAGE_REDUCTION = new DoubleStat("MAGIC_DAMAGE_REDUCTION", Material.POTION, "Magic Damage Reduction", new String[]{"Reduce magic damage dealt by potions.", "In %."}), - PVE_DAMAGE_REDUCTION = new DoubleStat("PVE_DAMAGE_REDUCTION", Material.PORKCHOP, "PvE Damage Reduction", new String[]{"Reduces damage dealt by mobs.", "In %."}), - PVP_DAMAGE_REDUCTION = new DoubleStat("PVP_DAMAGE_REDUCTION", Material.SKELETON_SKULL, "PvP Damage Reduction", new String[]{"Reduces damage dealt by players", "In %."}), - UNDEAD_DAMAGE = new DoubleStat("UNDEAD_DAMAGE", Material.SKELETON_SKULL, "Undead Damage", new String[]{"Deals additional damage to undead.", "In %."}), - LIFESTEAL = new DoubleStat("LIFESTEAL", Material.REDSTONE, "Lifesteal", new String[]{"Percentage of damage you gain back as", "health when inflicting weapon damage."}), - SPELL_VAMPIRISM = new DoubleStat("SPELL_VAMPIRISM", Material.REDSTONE, "Spell Vampirism", new String[]{"Percentage of damage you gain back as", "health when inflicting skill damage."}), + PVE_DAMAGE = new DoubleStat("PVE_DAMAGE", Material.PORKCHOP, "PvE Damage", new String[]{"Additional damage against", "non human entities in %."}, new String[]{"equipment", "gem_stone"}).setCategory(StatCategories.OFFENSE), + PVP_DAMAGE = new DoubleStat("PVP_DAMAGE", Material.SKELETON_SKULL, "PvP Damage", new String[]{"Additional damage", "against players in %."}, new String[]{"equipment", "gem_stone"}).setCategory(StatCategories.OFFENSE), + BLUNT_POWER = new DoubleStat("BLUNT_POWER", Material.IRON_AXE, "Blunt Power", new String[]{"The radius of the AoE attack.", "If set to 2.0, enemies within 2 blocks", "around your target will take damage.", "&9This stat only applies to Blunt weapons."}, new String[]{"weapon", "gem_stone"}).setCategory(StatCategories.DAMAGE_MITIGATION), + BLUNT_RATING = new DoubleStat("BLUNT_RATING", Material.BRICK, "Blunt Rating", new String[]{"The force of the blunt attack.", "If set to 50%, enemies hit by the attack", "will take 50% of the initial damage.", "&9This stat only applies to Blunt weapons."}, new String[]{"weapon", "gem_stone"}).setCategory(StatCategories.DAMAGE_MITIGATION), + WEAPON_DAMAGE = new DoubleStat("WEAPON_DAMAGE", Material.IRON_SWORD, "Weapon Damage", new String[]{"Additional on-hit weapon damage in %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + SKILL_DAMAGE = new DoubleStat("SKILL_DAMAGE", Material.BOOK, "Skill Damage", new String[]{"Additional ability damage in %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + PROJECTILE_DAMAGE = new DoubleStat("PROJECTILE_DAMAGE", Material.ARROW, "Projectile Damage", new String[]{"Additional skill/weapon projectile damage."}).setCategory(StatCategories.DAMAGE_MITIGATION), + MAGIC_DAMAGE = new DoubleStat("MAGIC_DAMAGE", Material.MAGMA_CREAM, "Magic Damage", new String[]{"Additional magic skill damage in %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + PHYSICAL_DAMAGE = new DoubleStat("PHYSICAL_DAMAGE", Material.IRON_AXE, "Physical Damage", new String[]{"Additional skill/weapon physical damage."}).setCategory(StatCategories.DAMAGE_MITIGATION), + DEFENSE = new DoubleStat("DEFENSE", Material.SHIELD, "Defense", new String[]{"Reduces damage from any source.", "Formula can be set in MMOLib Config."}).setCategory(StatCategories.DAMAGE_MITIGATION), + DAMAGE_REDUCTION = new DoubleStat("DAMAGE_REDUCTION", Material.IRON_CHESTPLATE, "Damage Reduction", new String[]{"Reduces damage from any source.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + FALL_DAMAGE_REDUCTION = new DoubleStat("FALL_DAMAGE_REDUCTION", Material.FEATHER, "Fall Damage Reduction", new String[]{"Reduces fall damage.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + PROJECTILE_DAMAGE_REDUCTION = new DoubleStat("PROJECTILE_DAMAGE_REDUCTION", Material.SNOWBALL, "Projectile Damage Reduction", new String[]{"Reduces projectile damage.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + PHYSICAL_DAMAGE_REDUCTION = new DoubleStat("PHYSICAL_DAMAGE_REDUCTION", Material.LEATHER_CHESTPLATE, "Physical Damage Reduction", new String[]{"Reduces physical damage.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + FIRE_DAMAGE_REDUCTION = new DoubleStat("FIRE_DAMAGE_REDUCTION", Material.BLAZE_POWDER, "Fire Damage Reduction", new String[]{"Reduces fire damage.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + MAGIC_DAMAGE_REDUCTION = new DoubleStat("MAGIC_DAMAGE_REDUCTION", Material.POTION, "Magic Damage Reduction", new String[]{"Reduce magic damage dealt by potions.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + PVE_DAMAGE_REDUCTION = new DoubleStat("PVE_DAMAGE_REDUCTION", Material.PORKCHOP, "PvE Damage Reduction", new String[]{"Reduces damage dealt by mobs.", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + PVP_DAMAGE_REDUCTION = new DoubleStat("PVP_DAMAGE_REDUCTION", Material.SKELETON_SKULL, "PvP Damage Reduction", new String[]{"Reduces damage dealt by players", "In %."}).setCategory(StatCategories.DAMAGE_MITIGATION), + UNDEAD_DAMAGE = new DoubleStat("UNDEAD_DAMAGE", Material.SKELETON_SKULL, "Undead Damage", new String[]{"Deals additional damage to undead.", "In %."}).setCategory(StatCategories.OFFENSE), + LIFESTEAL = new DoubleStat("LIFESTEAL", Material.REDSTONE, "Lifesteal", new String[]{"Percentage of damage you gain back as", "health when inflicting weapon damage."}).setCategory(StatCategories.OFFENSE), + SPELL_VAMPIRISM = new DoubleStat("SPELL_VAMPIRISM", Material.REDSTONE, "Spell Vampirism", new String[]{"Percentage of damage you gain back as", "health when inflicting skill damage."}).setCategory(StatCategories.OFFENSE), // Extra Stats UNBREAKABLE = new Unbreakable(), @@ -116,10 +115,10 @@ public class ItemStats { ARMOR_TOUGHNESS = new ArmorToughness(), MAX_HEALTH = new MaxHealth(), UNSTACKABLE = new Unstackable(), - MAX_MANA = new DoubleStat("MAX_MANA", Material.LAPIS_LAZULI, "Max Mana", new String[]{"Adds mana to your max mana bar."}), + MAX_MANA = new DoubleStat("MAX_MANA", Material.LAPIS_LAZULI, "Max Mana", new String[]{"Adds mana to your max mana bar."}).setCategory(StatCategories.MISC_STATS), KNOCKBACK_RESISTANCE = new KnockbackResistance(), MOVEMENT_SPEED = new MovementSpeed(), - TWO_HANDED = new BooleanStat("TWO_HANDED", Material.IRON_INGOT, "Two Handed", new String[]{"If set to true, a player will be", "significantly slower if holding two", "items, one being Two Handed."}, new String[]{"handheld"}), + TWO_HANDED = new BooleanStat("TWO_HANDED", Material.IRON_INGOT, "Two Handed", new String[]{"If set to true, a player will be", "significantly slower if holding two", "items, one being Two Handed."}, new String[]{"handheld"}).setCategory(StatCategories.MISC), REQUIRED_BIOMES = new RequiredBiomes(), DROP_ON_DEATH = new DisableDeathDrop(), HIDE_DURABILITY_BAR = new HideDurabilityBar(), @@ -163,8 +162,8 @@ public class ItemStats { SOULBOUND_BREAK_CHANCE = new SoulbindingBreakChance(), SOULBOUND_LEVEL = new SoulboundLevel(), // AUTO_SOULBIND = new BooleanStat("AUTO_SOULBIND", VersionMaterial.ENDER_EYE.toMaterial(), "Auto-Soulbind", new String[]{"Automatically soulbinds this item to", "a player when he acquires it."}, new String[]{"!consumable", "all"}), - ITEM_COOLDOWN = new DoubleStat("ITEM_COOLDOWN", Material.COOKED_CHICKEN, "Item Cooldown", new String[]{"This cooldown applies for consumables", "as well as for item commands."}, new String[]{"!armor", "!gem_stone", "!block", "all"}), - COOLDOWN_REFERENCE = new StringStat("COOLDOWN_REFERENCE", Material.CHICKEN, "Cooldown Reference", new String[]{"Two items with the same cooldown reference", "will share their cooldowns. This is useful", "for health or mana pots for example."}, new String[]{"!armor", "!gem_stone", "!block", "all"}), + ITEM_COOLDOWN = new DoubleStat("ITEM_COOLDOWN", Material.COOKED_CHICKEN, "Item Cooldown", new String[]{"This cooldown applies for consumables", "as well as for item commands."}, new String[]{"!armor", "!gem_stone", "!block", "all"}).setCategory(StatCategories.ABILITIES), + COOLDOWN_REFERENCE = new StringStat("COOLDOWN_REFERENCE", Material.CHICKEN, "Cooldown Reference", new String[]{"Two items with the same cooldown reference", "will share their cooldowns. This is useful", "for health or mana pots for example."}, new String[]{"!armor", "!gem_stone", "!block", "all"}).setCategory(StatCategories.ABILITIES), VANILLA_EATING_ANIMATION = new VanillaEatingAnimation(), GEM_COLOR = new GemColor(), GEM_UPGRADE_SCALING = new GemUpgradeScaling(), @@ -178,17 +177,17 @@ public class ItemStats { //CRAFT_AMOUNT = new DoubleStat("CRAFTED_AMOUNT", Material.WOODEN_AXE, "Crafted Amount", new String[]{"The stack count for", "this item when crafted."}, new String[0]), // Unique Stats - AUTOSMELT = new BooleanStat("AUTOSMELT", Material.COAL, "Autosmelt", new String[]{"If set to true, your tool will", "automaticaly smelt mined ores."}, new String[]{"tool"}), - BOUNCING_CRACK = new BooleanStat("BOUNCING_CRACK", Material.COBBLESTONE_WALL, "Bouncing Crack", new String[]{"If set to true, your tool will", "also break nearby blocks."}, new String[]{"tool"}), + AUTOSMELT = new BooleanStat("AUTOSMELT", Material.COAL, "Autosmelt", new String[]{"If set to true, your tool will", "automaticaly smelt mined ores."}, new String[]{"tool"}).setCategory(StatCategories.TOOLS), + BOUNCING_CRACK = new BooleanStat("BOUNCING_CRACK", Material.COBBLESTONE_WALL, "Bouncing Crack", new String[]{"If set to true, your tool will", "also break nearby blocks."}, new String[]{"tool"}).setCategory(StatCategories.TOOLS), PICKAXE_POWER = new PickaxePower(), CUSTOM_SOUNDS = new CustomSounds(), - ELEMENTS = new Elements(), - COMMANDS = new Commands(), + ELEMENTS = new Elements(), + COMMANDS = new Commands(), // STAFF_SPIRIT = new StaffSpiritStat(), LUTE_ATTACK_SOUND = new LuteAttackSoundStat(), LUTE_ATTACK_EFFECT = new LuteAttackEffectStat(), - NOTE_WEIGHT = new DoubleStat("NOTE_WEIGHT", Material.MUSIC_DISC_MALL, "Note Weight", new String[]{"Defines how the projectile cast", "by your lute tilts downwards."}, new String[]{"lute"}), - REMOVE_ON_CRAFT = new BooleanStat("REMOVE_ON_CRAFT", Material.GLASS_BOTTLE, "Remove on Craft", new String[]{"If the item should be completely", "removed when used in a recipe,", "or if it should become an", "empty bottle or bucket."}, new String[0], Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.MILK_BUCKET, Material.LAVA_BUCKET, Material.WATER_BUCKET), + NOTE_WEIGHT = new DoubleStat("NOTE_WEIGHT", Material.MUSIC_DISC_MALL, "Note Weight", new String[]{"Defines how the projectile cast", "by your lute tilts downwards."}, new String[]{"lute"}).setCategory(StatCategories.RANGED_WEAPONS), + REMOVE_ON_CRAFT = new BooleanStat("REMOVE_ON_CRAFT", Material.GLASS_BOTTLE, "Remove on Craft", new String[]{"If the item should be completely", "removed when used in a recipe,", "or if it should become an", "empty bottle or bucket."}, new String[0], Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.MILK_BUCKET, Material.LAVA_BUCKET, Material.WATER_BUCKET).setCategory(StatCategories.MISC), COMPATIBLE_TYPES = new CompatibleTypes(), COMPATIBLE_IDS = new CompatibleIds(), COMPATIBLE_MATERIALS = new CompatibleMaterials(), @@ -198,19 +197,19 @@ public class ItemStats { REPAIR = new RepairPower(), REPAIR_PERCENT = new RepairPowerPercent(), REPAIR_TYPE = new RepairReference(), - INEDIBLE = new BooleanStat("INEDIBLE", Material.POISONOUS_POTATO, "Inedible", new String[]{"Players won't be able to right-click this consumable.", "", "No effects of it will take place."}, new String[]{"consumable"}), - DISABLE_RIGHT_CLICK_CONSUME = new DisableStat("RIGHT_CLICK_CONSUME", Material.BAKED_POTATO, "Infinite Consume", new String[]{"consumable"}, "Players will be able to right-click this consumable", "and benefit from its effects, but it won't be consumed."), - KNOCKBACK = new DoubleStat("KNOCKBACK", Material.IRON_HORSE_ARMOR, "Knockback", new String[]{"Using this musket will knock", "the user back if positive."}, new String[]{"musket", "gem_stone"}), - RECOIL = new DoubleStat("RECOIL", Material.IRON_HORSE_ARMOR, "Recoil", new String[]{"Corresponds to the shooting innacuracy."}, new String[]{"musket", "gem_stone"}), - HANDWORN = new BooleanStat("HANDWORN", Material.STRING, "Handworn", new String[]{"This item can be held along with a", "two-handed weapon in the other hand."}, new String[]{"catalyst", "off_catalyst", "main_catalyst"}), + INEDIBLE = new BooleanStat("INEDIBLE", Material.POISONOUS_POTATO, "Inedible", new String[]{"Players won't be able to right-click this consumable.", "", "No effects of it will take place."}, new String[]{"consumable"}).setCategory(StatCategories.CONSUMABLES), + DISABLE_RIGHT_CLICK_CONSUME = new DisableStat("RIGHT_CLICK_CONSUME", Material.BAKED_POTATO, "Infinite Consume", new String[]{"consumable"}, "Players will be able to right-click this consumable", "and benefit from its effects, but it won't be consumed.").setCategory(StatCategories.CONSUMABLES), + KNOCKBACK = new DoubleStat("KNOCKBACK", Material.IRON_HORSE_ARMOR, "Knockback", new String[]{"Using this musket will knock", "the user back if positive."}, new String[]{"musket", "gem_stone"}).setCategory(StatCategories.RANGED_WEAPONS), + RECOIL = new DoubleStat("RECOIL", Material.IRON_HORSE_ARMOR, "Recoil", new String[]{"Corresponds to the shooting innacuracy."}, new String[]{"musket", "gem_stone"}).setCategory(StatCategories.RANGED_WEAPONS), + HANDWORN = new BooleanStat("HANDWORN", Material.STRING, "Handworn", new String[]{"This item can be held along with a", "two-handed weapon in the other hand."}, new String[]{"catalyst", "off_catalyst", "main_catalyst"}).setCategory(StatCategories.MISC), AMPHIBIAN = new Amphibian(), // Abilities & Upgrading ABILITIES = new Abilities(), UPGRADE = new UpgradeStat(), - DOWNGRADE_ON_BREAK = new BooleanStat("BREAK_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade when Broken", new String[]{"If this item's durability reaches 0,", "it will be fully repaired but also", "downgraded by one level.", "", "&cIt will only break if it cannot be", "&cdowngraded further", "", "Requires to define an &6Upgrade Template", "Required to define &6Custom Durability"}, new String[]{"equipment"}), - DOWNGRADE_ON_DEATH = new BooleanStat("DEATH_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade on Death", new String[]{"If the wearer of this item dies, it may", "downgrade (based on &6Death Downgrade", "&6Chance &7stat)", "", "Required to define an &6Upgrade Template", "Requires keep-inventory gamerule. "}, new String[]{"equipment"}), - DOWNGRADE_ON_DEATH_CHANCE = new DoubleStat("DEATH_DOWNGRADE_CHANCE", Material.SKELETON_SKULL, "Death Downgrade Chance", new String[]{"Probability that an item with &cDowngrade ", "&con Death&7 will be downgraded when the", "player dies. ", "", "Exceeding 100% will for sure downgrade", "one item, and roll again to downgrade", "another (with the excess probability).", "&6The same item wont be downgraded twice."}, new String[]{"equipment"}, false), + DOWNGRADE_ON_BREAK = new BooleanStat("BREAK_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade when Broken", new String[]{"If this item's durability reaches 0,", "it will be fully repaired but also", "downgraded by one level.", "", "&cIt will only break if it cannot be", "&cdowngraded further", "", "Requires to define an &6Upgrade Template", "Required to define &6Custom Durability"}, new String[]{"equipment"}).setCategory(StatCategories.UPGRADING), + DOWNGRADE_ON_DEATH = new BooleanStat("DEATH_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade on Death", new String[]{"If the wearer of this item dies, it may", "downgrade (based on &6Death Downgrade", "&6Chance &7stat)", "", "Required to define an &6Upgrade Template", "Requires keep-inventory gamerule. "}, new String[]{"equipment"}).setCategory(StatCategories.UPGRADING), + DOWNGRADE_ON_DEATH_CHANCE = new DoubleStat("DEATH_DOWNGRADE_CHANCE", Material.SKELETON_SKULL, "Death Downgrade Chance", new String[]{"Probability that an item with &cDowngrade ", "&con Death&7 will be downgraded when the", "player dies. ", "", "Exceeding 100% will for sure downgrade", "one item, and roll again to downgrade", "another (with the excess probability).", "&6The same item wont be downgraded twice."}, new String[]{"equipment"}, false).setCategory(StatCategories.UPGRADING), // Unique Item Stats DYE_COLOR = new DyeColor(), @@ -231,10 +230,10 @@ public class ItemStats { BROWSER_DISPLAY_IDX = new BrowserDisplayIDX(); /** - * @deprecated Item damage is now {@link ItemDamage} and - * custom durability is now {@link CustomDurability} + * @see ItemDamage + * @see CustomDurability + * @deprecated */ @Deprecated - @DeprecatedStat public static final ItemStat DURABILITY = ITEM_DAMAGE; } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java index 62eaf659..8fb6f05e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java @@ -165,11 +165,12 @@ public class MMOItems extends MMOPlugin { // This needs to be before modifier registration (MMOCore) findRpgPlugins(); + statManager.reload(false); // Elemental stats must be loaded before sets + /* * After tiers, sets and upgrade templates are loaded, MI template data * can be fully loaded */ - statManager.loadElements(); // Why is this call made there? loreManager.reload(); tierManager = new TierManager(); setManager = new SetManager(); @@ -179,7 +180,6 @@ public class MMOItems extends MMOPlugin { dropTableManager = new DropTableManager(); worldGenManager = new WorldGenManager(); blockManager = new BlockManager(); - statManager.reload(false); PluginUtils.hookDependencyIfPresent("Vault", u -> vaultSupport = new VaultSupport()); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/StatCategories.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/StatCategories.java new file mode 100644 index 00000000..a60f73b6 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/StatCategories.java @@ -0,0 +1,41 @@ +package net.Indyuce.mmoitems; + +import net.Indyuce.mmoitems.stat.category.StatCategory; + +public class StatCategories { + public static final StatCategory + NONE = new StatCategory("NONE", "Anything Else!", "No Category"), + MISC = new StatCategory("MISC", "Miscellaneous", "Miscellaneous"), + RARITY = new StatCategory("RARITY", "Rarity", "Rarity"), + TEMPLATE_OPTION = new StatCategory("TEMPLATE_OPTION", "Template Options", "Template Option"), + SOULBOUND = new StatCategory("SOULBOUND", "Soulbound", "Soulbound"), + ELEMENTS = new StatCategory("ELEMENTS", "Elements", "Elements", true), + TOOLS = new StatCategory("TOOLS", "Tools", "Tools"), + VANILLA_ATTRIBUTE = new StatCategory("VANILLA_ATTRIBUTE", "Vanilla Attributes", "Vanilla Attribute"), + OFFENSE = new StatCategory("OFFENSE", "Offense", "Offense"), + MISC_STATS = new StatCategory("MISC_STATS", "Misc Stats", "Misc Stats"), + RANGED_WEAPONS = new StatCategory("RANGED_WEAPONS", "Ranged Weapons", "Ranged Weapons"), + CUSTOM = new StatCategory("CUSTOM", "Custom Stat", "Custom Stat"), + BLOCKS = new StatCategory("BLOCKS", "Blocks", "Blocks"), + RESOURCES = new StatCategory("RESOURCES", "Resources", "Resources"), + DAMAGE_MITIGATION = new StatCategory("DAMAGE_MITIGATION", "Damage Mitigation", "Damage Mitigation"), + REQUIREMENT = new StatCategory("REQUIREMENT", "Item Requirements", "Item Requirement"), + USE_COST = new StatCategory("USE_COST", "Item Costs", "Use Cost"), + UPGRADING = new StatCategory("UPGRADING", "Upgrading", "Upgrading"), + DURABILITY = new StatCategory("DURABILITY", "Durability", "Durability"), + CONSUMABLES = new StatCategory("CONSUMABLES", "Consumables", "Consumables"), + GEM_STONES = new StatCategory("GEM_STONES", "Gem Stones", "Gem Stones"), + SKINS = new StatCategory("SKINS", "Item Skins", "Skins"), + ABILITIES = new StatCategory("ABILITIES", "Actions, Scripts & Abilities", "Actions & Abilities"), + TOOLTIP = new StatCategory("TOOLTIP", "Tooltips", "Tooltips"), + GENERAL = new StatCategory("GENERAL", "General", "General"), + SPECIAL = new StatCategory("SPECIAL", "Special", "Special"), + TOGGLES = new StatCategory("TOGGLES", "Toggles", "Toggles"), + MMOCORE_PROFESSIONS = new StatCategory("MMOCORE_PROFESSIONS", "MMOCore Professions", "MMOCore Professions", true), + MMOCORE_ATTRIBUTES = new StatCategory("MMOCORE_ATTRIBUTES", "MMOCore Attributes", "MMOCore Attributes", true), + ITEM = new StatCategory("ITEM", "Item & Texture", "Item & Texture"); + + /* NONE = new StatCategory("NONE", "Anything Else!", "No Category"), + NONE = new StatCategory("NONE", "Anything Else!", "No Category"), + NONE = new StatCategory("NONE", "Anything Else!", "No Category");*/ +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java index aa8aa796..04674e18 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java @@ -8,6 +8,7 @@ import io.lumine.mythic.lib.player.modifier.ModifierSource; import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.util.PostLoadAction; import io.lumine.mythic.lib.util.PreloadedObject; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.interaction.*; import net.Indyuce.mmoitems.api.interaction.weapon.Weapon; @@ -26,12 +27,10 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.function.BiFunction; -@SuppressWarnings("unused") +// TODO remove most of premade types. Add type categories for applicable stats. public class Type implements CooldownObject, PreloadedObject { // Slashing @@ -108,7 +107,7 @@ public class Type implements CooldownObject, PreloadedObject { /** * Cached list of stats which can be applied onto an item with this type */ - private final List available = new ArrayList<>(); + private final List> statCache = new ArrayList<>(); private final PostLoadAction postLoadAction = new PostLoadAction(true, config -> { onLeftClick = config.contains("on-left-click") ? MythicLib.plugin.getSkills().loadSkillHandler(config.get("on-left-click")) : null; @@ -269,8 +268,8 @@ public class Type implements CooldownObject, PreloadedObject { * specific item type. This list is cached when types are being * loaded and is a PRETTY GOOD performance improvement. */ - public List getAvailableStats() { - return available; + public List> getAvailableStats() { + return statCache; } /** @@ -396,5 +395,12 @@ public class Type implements CooldownObject, PreloadedObject { return getId(); } + @BackwardsCompatibility(version = "6.10.1") + public Collection LEGACY_TYPES = Arrays.asList( + + + + ); + //endregion } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/MMOItemTemplate.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/MMOItemTemplate.java index 22e7a195..98462d7d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/MMOItemTemplate.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/MMOItemTemplate.java @@ -75,11 +75,15 @@ public class MMOItemTemplate implements ItemReference, PreloadedObject { for (String key : config.getConfigurationSection("base").getKeys(false)) try { final String id = UtilityMethods.enumName(key); - final ItemStat stat = MMOItems.plugin.getStats().get(id); + final ItemStat stat = MMOItems.plugin.getStats().get(id); + + // Adapt legacy configs + if (stat == null && MMOItems.plugin.getStats().adaptLegacyConfig(base, key, k -> config.get("base." + k))) + continue; + Validate.notNull(stat, FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), "Could not find stat with ID '$i{0}$b'", id)); - RandomStatData data = stat.whenInitialized(config.get("base." + key)); - if (data != null) - base.put(stat, data); + RandomStatData data = stat.whenInitialized(config.get("base." + key)); + if (data != null) base.put(stat, data); } catch (IllegalArgumentException exception) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/ModifierNode.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/ModifierNode.java index b127d2ed..0f2d96dc 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/ModifierNode.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/template/ModifierNode.java @@ -66,6 +66,10 @@ public class ModifierNode implements PreloadedObject { try { final String statId = UtilityMethods.enumName(key); final ItemStat stat = MMOItems.plugin.getStats().get(statId); + + // Adapt legacy configs + if (stat == null && MMOItems.plugin.getStats().adaptLegacyConfig(ModifierNode.this.data, key, statSection::get)) continue; + Validate.notNull(stat, "Could not find stat with ID '" + statId + "'"); ModifierNode.this.data.put(stat, stat.whenInitialized(statSection.get(key))); } catch (IllegalArgumentException exception) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantmentsHook.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantmentsHook.java index fbf3af27..58e68eaa 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantmentsHook.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantmentsHook.java @@ -2,8 +2,10 @@ package net.Indyuce.mmoitems.comp.enchants.advanced_enchants; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.NBTItem; +import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.event.MMOItemReforgeEvent; import net.Indyuce.mmoitems.comp.enchants.DisableAdvancedEnchantments; +import net.Indyuce.mmoitems.stat.category.StatCategory; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.advancedplugins.ae.api.EnchantApplyEvent; @@ -11,8 +13,14 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public class AdvancedEnchantmentsHook implements Listener { - public static final ItemStat ADVANCED_ENCHANTMENTS = new AdvancedEnchantsStat(); - public static final ItemStat DISABLE_ADVANCED_ENCHANTMENTS = new DisableAdvancedEnchantments(); + public static final StatCategory STAT_CATEGORY = new StatCategory("AE", "Advanced Enchants", "Advanced Enchants"); + + public static final ItemStat ADVANCED_ENCHANTMENTS = new AdvancedEnchantsStat().setCategory(STAT_CATEGORY); + public static final ItemStat DISABLE_ADVANCED_ENCHANTMENTS = new DisableAdvancedEnchantments().setCategory(STAT_CATEGORY); + + public AdvancedEnchantmentsHook() { + MMOItems.plugin.getStats().registerCategory(STAT_CATEGORY); + } @EventHandler public void onEnchantApply(EnchantApplyEvent event) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java index 88ff1be6..62dc14ec 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java @@ -6,7 +6,6 @@ import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; -import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.experience.source.RepairItemExperienceSource; @@ -16,12 +15,11 @@ import net.Indyuce.mmoitems.api.event.item.ItemCustomRepairEvent; import net.Indyuce.mmoitems.api.event.item.RepairItemEvent; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.RPGPlayer; +import net.Indyuce.mmoitems.comp.mmocore.stat.AdditionalProfessionExp; import net.Indyuce.mmoitems.comp.mmocore.stat.ExtraAttribute; import net.Indyuce.mmoitems.comp.mmocore.stat.RequiredAttribute; import net.Indyuce.mmoitems.comp.mmocore.stat.RequiredProfession; import net.Indyuce.mmoitems.comp.rpg.RPGHandler; -import net.Indyuce.mmoitems.stat.type.DoubleStat; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -29,8 +27,6 @@ import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; -import java.util.Locale; - public class MMOCoreHook implements RPGHandler, Listener { /** @@ -48,10 +44,7 @@ public class MMOCoreHook implements RPGHandler, Listener { for (Profession profession : MMOCore.plugin.professionManager.getAll()) { // Adds profession specific Additional Experience stats. - MMOItems.plugin.getStats().register(new DoubleStat((StatType.ADDITIONAL_EXPERIENCE.name() + '_' + profession.getId()) - .replace('-', '_').replace(' ', '_').toUpperCase(Locale.ROOT), - Material.EXPERIENCE_BOTTLE, profession.getName() + ' ' + "Additional Experience (MMOCore)" - , new String[]{"Additional MMOCore profession " + profession.getName() + " experience in %."}, new String[]{"!block", "all"})); + MMOItems.plugin.getStats().register(new AdditionalProfessionExp(profession)); MMOItems.plugin.getStats().register(new RequiredProfession(profession)); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java index 9a314fc6..cc8827cf 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java @@ -12,6 +12,7 @@ import net.Indyuce.mmocore.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.loot.chest.condition.Condition; import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem; import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.StatCategories; import net.Indyuce.mmoitems.api.block.CustomBlock; import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay; import net.Indyuce.mmoitems.comp.mmocore.crafting.AttributeCondition; @@ -28,19 +29,19 @@ import java.util.Optional; public class MMOCoreMMOLoader extends MMOLoader { - private static final ItemStat HEALTH_REGENERATION = new DoubleStat("HEALTH_REGENERATION", Material.BREAD, "Health Regeneration", new String[]{"Amount of health pts regenerated every second."}); - private static final ItemStat MAX_HEALTH_REGENERATION = new DoubleStat("MAX_HEALTH_REGENERATION", Material.BREAD, "Max Health Regeneration", new String[]{"Percentage of max health regenerated every second."}); - private static final ItemStat MANA_REGENERATION = new DoubleStat("MANA_REGENERATION", Material.LAPIS_LAZULI, "Mana Regeneration", new String[]{"Amount of mana pts regenerated every second."}); - private static final ItemStat MAX_MANA_REGENERATION = new DoubleStat("MAX_MANA_REGENERATION", Material.LAPIS_LAZULI, "Max Mana Regeneration", new String[]{"Percentage of max mana regenerated every second."}); - private static final ItemStat STAMINA_REGENERATION = new DoubleStat("STAMINA_REGENERATION", Material.LIGHT_BLUE_DYE, "Stamina Regeneration", new String[]{"Amount of stamina pts regenerated every second."}); - private static final ItemStat MAX_STAMINA_REGENERATION = new DoubleStat("MAX_STAMINA_REGENERATION", Material.LIGHT_BLUE_DYE, "Max Stamina Regeneration", new String[]{"Percentage of max stamina regenerated every second."}); + private static final ItemStat HEALTH_REGENERATION = new DoubleStat("HEALTH_REGENERATION", Material.BREAD, "Health Regeneration", new String[]{"Amount of health pts regenerated every second."}).setCategory(StatCategories.RESOURCES); + private static final ItemStat MAX_HEALTH_REGENERATION = new DoubleStat("MAX_HEALTH_REGENERATION", Material.BREAD, "Max Health Regeneration", new String[]{"Percentage of max health regenerated every second."}).setCategory(StatCategories.RESOURCES); + private static final ItemStat MANA_REGENERATION = new DoubleStat("MANA_REGENERATION", Material.LAPIS_LAZULI, "Mana Regeneration", new String[]{"Amount of mana pts regenerated every second."}).setCategory(StatCategories.RESOURCES); + private static final ItemStat MAX_MANA_REGENERATION = new DoubleStat("MAX_MANA_REGENERATION", Material.LAPIS_LAZULI, "Max Mana Regeneration", new String[]{"Percentage of max mana regenerated every second."}).setCategory(StatCategories.RESOURCES); + private static final ItemStat STAMINA_REGENERATION = new DoubleStat("STAMINA_REGENERATION", Material.LIGHT_BLUE_DYE, "Stamina Regeneration", new String[]{"Amount of stamina pts regenerated every second."}).setCategory(StatCategories.RESOURCES); + private static final ItemStat MAX_STAMINA_REGENERATION = new DoubleStat("MAX_STAMINA_REGENERATION", Material.LIGHT_BLUE_DYE, "Max Stamina Regeneration", new String[]{"Percentage of max stamina regenerated every second."}).setCategory(StatCategories.RESOURCES); private static final ItemStat MAX_STAMINA = new DoubleStat("MAX_STAMINA", Material.LIGHT_BLUE_DYE, "Max Stamina", - new String[]{"Adds stamina to your max stamina bar."}); + new String[]{"Adds stamina to your max stamina bar."}).setCategory(StatCategories.RESOURCES); private static final ItemStat MAX_STELLIUM = new DoubleStat("MAX_STELLIUM", Material.ENDER_EYE, "Max Stellium", - new String[]{"Additional maximum stellium."}); + new String[]{"Additional maximum stellium."}).setCategory(StatCategories.RESOURCES); private static final ItemStat ADDITIONAL_EXPERIENCE = new DoubleStat("ADDITIONAL_EXPERIENCE", Material.EXPERIENCE_BOTTLE, - "Additional Experience", new String[]{"Additional MMOCore main class experience in %."}); + "Additional Experience", new String[]{"Additional MMOCore main class experience in %."}).setCategory(StatCategories.MISC_STATS); /* * Called when MMOItems loads diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/AdditionalProfessionExp.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/AdditionalProfessionExp.java new file mode 100644 index 00000000..f11ae690 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/AdditionalProfessionExp.java @@ -0,0 +1,21 @@ +package net.Indyuce.mmoitems.comp.mmocore.stat; + +import net.Indyuce.mmocore.api.player.stats.StatType; +import net.Indyuce.mmocore.experience.Profession; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.type.DoubleStat; +import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; + +import java.util.Locale; + +@HasCategory(cat = "mmocore_professions") +public class AdditionalProfessionExp extends DoubleStat { + public AdditionalProfessionExp(@NotNull Profession profession) { + super((StatType.ADDITIONAL_EXPERIENCE.name() + '_' + profession.getId()).replace('-', '_').replace(' ', '_').toUpperCase(Locale.ROOT), + Material.EXPERIENCE_BOTTLE, + profession.getName() + " Additional Experience", + new String[]{"Additional MMOCore profession " + profession.getName() + " experience in %."}, + new String[]{"!block", "all"}); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/ExtraAttribute.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/ExtraAttribute.java index c86cc8ce..2842999c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/ExtraAttribute.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/ExtraAttribute.java @@ -2,11 +2,13 @@ package net.Indyuce.mmoitems.comp.mmocore.stat; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "mmocore_attributes") public class ExtraAttribute extends DoubleStat { public ExtraAttribute(PlayerAttribute attribute) { super("ADDITIONAL_" + attribute.getId().toUpperCase().replace("-", "_"), Material.LIME_DYE, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredAttribute.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredAttribute.java index 94e857c3..dadaf3e6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredAttribute.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredAttribute.java @@ -6,11 +6,13 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.RequiredLevelStat; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; +@HasCategory(cat = "mmocore_attributes") public class RequiredAttribute extends RequiredLevelStat { private final PlayerAttribute attribute; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredProfession.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredProfession.java index d90e011c..d7c60e2f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredProfession.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmocore/stat/RequiredProfession.java @@ -6,11 +6,13 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.RequiredLevelStat; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; +@HasCategory(cat = "mmocore_professions") public class RequiredProfession extends RequiredLevelStat { private final Profession profession; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java index f976c11b..b9b6c72b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java @@ -5,6 +5,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; @@ -12,6 +13,7 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "misc") public class AccessorySet extends StringStat implements GemStoneStat { public AccessorySet() { super("ACCESSORY_SET", Material.OAK_SIGN, "Accessory Set (MMOInventory)", new String[] { "Used with MMOInventory's unique", "restriction to only allow one", "accessory to be equipped per set." }, new String[] { "!block", "all" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java index aaba2380..b0973810 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java @@ -16,9 +16,11 @@ import io.lumine.mythic.lib.damage.AttackMetadata; import io.lumine.mythic.lib.damage.DamageMetadata; import io.lumine.mythic.lib.damage.DamageType; import net.Indyuce.mmoitems.ItemStats; +import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.category.StatCategory; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.ItemRestriction; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -43,11 +45,15 @@ import java.util.Set; public class HeroesHook implements RPGHandler, Listener, AttackHandler { private final Map damages = new HashMap<>(); - public static final ItemStat MAX_STAMINA = new DoubleStat("MAX_STAMINA", Material.EMERALD, "Max Stamina", new String[]{"Adds stamina to your max stamina bar"}), REQUIRED_SECONDARY_HERO_LEVEL = new RequiredSecondaryLevel(); + public static final StatCategory STAT_CATEGORY = new StatCategory("HEROES", "Heroes", "Heroes"); + + public static final ItemStat MAX_STAMINA = new DoubleStat("MAX_STAMINA", Material.EMERALD, "Max Stamina", new String[]{"Adds stamina to your max stamina bar"}).setCategory(STAT_CATEGORY), + REQUIRED_SECONDARY_HERO_LEVEL = new RequiredSecondaryLevel().setCategory(STAT_CATEGORY); public HeroesHook() { MythicLib.plugin.getDamage().registerHandler(this); + MMOItems.plugin.getStats().registerCategory(STAT_CATEGORY); damages.put(SkillType.ABILITY_PROPERTY_PHYSICAL, DamageType.PHYSICAL); damages.put(SkillType.ABILITY_PROPERTY_MAGICAL, DamageType.MAGIC); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/McMMOHook.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/McMMOHook.java index 9b6d73ef..94499374 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/McMMOHook.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/McMMOHook.java @@ -1,22 +1,23 @@ package net.Indyuce.mmoitems.comp.rpg; -import net.Indyuce.mmoitems.MMOItems; -import org.bukkit.Material; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - import com.gmail.nossr50.api.ExperienceAPI; import com.gmail.nossr50.api.exceptions.McMMOPlayerNotFoundException; import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent; import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; - +import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.RPGPlayer; +import net.Indyuce.mmoitems.stat.category.StatCategory; import net.Indyuce.mmoitems.stat.type.DisableStat; import net.Indyuce.mmoitems.stat.type.ItemStat; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; public class McMMOHook implements RPGHandler, Listener { + public static final StatCategory STAT_CATEGORY = new StatCategory("MCMMO", "mcMMO", "mcMMO"); + /** * McMMO is a special plugin, it can be used along with other RPG plugins * like MMOCore. That stat must be registered even if McMMO is not the main @@ -24,7 +25,11 @@ public class McMMOHook implements RPGHandler, Listener { * not in the constructor of that class */ public static final ItemStat disableMcMMORepair = new DisableStat("MCMMO_REPAIR", Material.IRON_BLOCK, "Disable McMMO Repair", - "Players can't repair this with McMMO."); + "Players can't repair this with McMMO.").setCategory(STAT_CATEGORY); + + public McMMOHook() { + MMOItems.plugin.getStats().registerCategory(STAT_CATEGORY); + } @EventHandler(ignoreCancelled = true) public void a(McMMOPlayerLevelUpEvent event) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java index d38553a9..a14ab5e6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java @@ -6,11 +6,14 @@ import io.lumine.mythic.lib.element.Element; import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.StatCategories; import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.Type; -import net.Indyuce.mmoitems.stat.annotation.DeprecatedStat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.category.StatCategory; +import net.Indyuce.mmoitems.stat.data.random.RandomStatData; +import net.Indyuce.mmoitems.stat.legacy.LegacyConfigAdapter; +import net.Indyuce.mmoitems.stat.legacy.LegacyConfigAdapters; import net.Indyuce.mmoitems.stat.type.*; import net.Indyuce.mmoitems.util.ElementStatType; import org.apache.commons.lang.Validate; @@ -23,6 +26,8 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; import java.util.logging.Level; public class StatManager { @@ -37,6 +42,9 @@ public class StatManager { @BackwardsCompatibility(version = "not_specified") private final Map> legacyAliases = new HashMap<>(); + @BackwardsCompatibility(version = "6.10.1") + private final Map legacyConfigAdapters = new HashMap<>(); + /* * These lists are sets of stats collected when the stats are registered for * the first time to make their access easier. Check the classes @@ -54,33 +62,38 @@ public class StatManager { public void loadBuiltins() { // Builtin categories - for (Field field : StatCategory.class.getFields()) - try { - if (Modifier.isStatic(field.getModifiers()) - && Modifier.isFinal(field.getModifiers()) - && field.get(null) instanceof StatCategory) - registerCategory((StatCategory) field.get(null)); - } catch (IllegalArgumentException | IllegalAccessException exception) { - MMOItems.plugin.getLogger().log(Level.SEVERE, String.format("Couldn't register category called '%s': %s", field.getName(), exception.getMessage())); - } + forEachField(StatCategories.class, StatCategory.class, this::registerCategory, "Couldn't register category called '%s': %s"); + + // Load builtin config adapters + forEachField(LegacyConfigAdapters.class, LegacyConfigAdapter.class, this::registerLegacyConfigAdapter, "Internal error '%s': %s"); // Load builtin stats - for (Field field : ItemStats.class.getFields()) - try { - if (Modifier.isStatic(field.getModifiers()) - && Modifier.isFinal(field.getModifiers()) - && field.get(null) instanceof ItemStat - && field.getAnnotation(DeprecatedStat.class) == null) - register((ItemStat) field.get(null)); - } catch (IllegalArgumentException | IllegalAccessException exception) { - MMOItems.plugin.getLogger().log(Level.SEVERE, String.format("Couldn't register stat called '%s': %s", field.getName(), exception.getMessage())); - } + forEachField(ItemStats.class, ItemStat.class, this::register, "Couldn't register stat called '%s': %s"); // Custom stats loadCustomStats(); } - // TODO refactor with stat categories + private void forEachField(@NotNull Class builtinRegistry, + @NotNull Class objectClass, + @NotNull Consumer action, + @NotNull String errorMessage) { + for (Field field : builtinRegistry.getFields()) + try { + Object fieldValue; + if (Modifier.isStatic(field.getModifiers()) + // Modifier is static final + && Modifier.isFinal(field.getModifiers()) + // Is instance of object class + && objectClass.isInstance(fieldValue = field.get(null)) + // Not deprecated + && field.getAnnotation(Deprecated.class) == null) + action.accept((T) fieldValue); + } catch (Exception exception) { + MMOItems.plugin.getLogger().log(Level.SEVERE, String.format(errorMessage, field.getName(), exception.getMessage())); + } + } + public void reload(boolean cleanFirst) { // Clean fictive numeric stats before @@ -88,20 +101,24 @@ public class StatManager { numericStats.removeIf(stat -> stat instanceof FakeElementalStat); // temporary fix, this is for elements TODO improve // Register elemental stats - loadElements(); + registerElementStats(); // Load stat translation objects (nothing to do with stats) final ConfigurationSection statOptions = new ConfigFile("/language", "stats").getConfig(); for (ItemStat stat : getAll()) try { - @Nullable Object object = statOptions.get(stat.getPath()); - if (object == null) object = statOptions.get(stat.getLegacyTranslationPath()); - stat.loadConfiguration(statOptions, object != null ? object : ""); + stat.readTranslationFile(statOptions); } catch (RuntimeException exception) { MMOItems.plugin.getLogger().log(Level.SEVERE, "Could not load translation info for stat '" + stat.getId() + "': " + exception.getMessage()); } } + private void registerElementStats() { + for (ElementStatType type : ElementStatType.values()) + for (Element element : MythicLib.plugin.getElements().getAll()) + numericStats.add(new FakeElementalStat(element, type)); + } + /** * Load custom stats */ @@ -110,24 +127,32 @@ public class StatManager { ConfigFile config = new ConfigFile("custom-stats"); ConfigurationSection section = config.getConfig().getConfigurationSection("custom-stats"); Validate.notNull(section, "Custom stats section is null"); - section.getKeys(true).stream().filter(section::isConfigurationSection).map(section::getConfigurationSection).filter(Objects::nonNull).forEach(this::registerCustomStat); - } - - /** - * Register all MythicLib elements as stats - *

- * TODO refactor with stat categories - */ - public void loadElements() { - for (ElementStatType type : ElementStatType.values()) - for (Element element : MythicLib.plugin.getElements().getAll()) - numericStats.add(new FakeElementalStat(element, type)); + section.getKeys(true).stream() + .filter(section::isConfigurationSection) + .map(section::getConfigurationSection) + .filter(Objects::nonNull) + .forEach(this::registerCustomStat); } public void registerCategory(@NotNull StatCategory category) { + Validate.isTrue(!categories.containsKey(category.getId()), "A category with ID '" + category.getId() + "' already exists"); categories.put(category.getId(), category); } + public void registerLegacyConfigAdapter(@NotNull LegacyConfigAdapter adapter) { + legacyConfigAdapters.put(adapter.getKey(), adapter); + } + + @BackwardsCompatibility(version = "6.10.1") + public boolean adaptLegacyConfig(@NotNull Map data, + @NotNull String configKey, + @NotNull Function supplier) { + final LegacyConfigAdapter adapter = legacyConfigAdapters.get(UtilityMethods.enumName(configKey).toLowerCase()); // Snake case + final boolean result = adapter != null; + if (result) adapter.adapt(data, supplier.apply(configKey)); + return result; + } + @NotNull public StatCategory getCategory(@NotNull String id) { return Objects.requireNonNull(categories.get(id), "No stat category found with ID '" + id + "'"); @@ -187,7 +212,7 @@ public class StatManager { ItemStat stat = stats.get(id); if (stat != null) return stat; - // Numeric registry (see to-do) + // Numeric registry TODO remove this useless registry once elements are properly implemented stat = numericStats.stream().filter(doubleStat -> doubleStat.getId().equals(id)).findFirst().orElse(null); if (stat != null) return stat; @@ -231,6 +256,9 @@ public class StatManager { HasCategory statCatAnnot = stat.getClass().getAnnotation(HasCategory.class); if (statCatAnnot != null) stat.setCategory(getCategory(UtilityMethods.enumName(statCatAnnot.cat()))); + if (stat.getCategory() == null) + MMOItems.plugin.getLogger().log(Level.WARNING, "Registered stat " + stat.getName() + " with no category"); + /* * Cache stat for every type which may have this stat. Really important * otherwise the stat will NOT be used anywhere in the plugin. This @@ -238,8 +266,32 @@ public class StatManager { * but since stats can be registered after types are loaded, we must * take it into account */ - if (MMOItems.plugin.getTypes() != null) - MMOItems.plugin.getTypes().getAll().stream().filter(stat::isCompatible).forEach(type -> type.getAvailableStats().add(stat)); + if (MMOItems.plugin.getTypes() != null) for (Type itemType : MMOItems.plugin.getTypes().getAll()) + if (stat.isCompatible(itemType)) itemType.getAvailableStats().add(stat); + } + + /** + * This method does NOT + * + * @param stat + */ + private void unregister(@NotNull ItemStat stat) { + + // Unregister from main stat registry + stats.remove(stat.getId()); + + // Unregister aliases + for (String alias : stat.getAliases()) legacyAliases.remove(alias); + + // Unregister other registries + numericStats.remove(stat); + itemRestrictions.remove(stat); + consumableActions.remove(stat); + playerConsumables.remove(stat); + + // Remove stat from all type stat caches + for (Type itemType : MMOItems.plugin.getTypes().getAll()) + itemType.getAvailableStats().remove(stat); } private void registerCustomStat(@NotNull ConfigurationSection section) { @@ -278,6 +330,7 @@ public class StatManager { // Create a new stat instance try { ItemStat stat = statClass.getConstructor(String.class, Material.class, String.class, String[].class, String[].class, Material[].class).newInstance(statId, Material.PAPER, name, lore, new String[]{"!miscellaneous", "!block", "all"}, new Material[0]); + stat.setCategory(StatCategories.CUSTOM); register(stat); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { @@ -302,4 +355,9 @@ public class StatManager { public void loadInternalStats() { loadBuiltins(); } + + @Deprecated + public void loadElements() { + registerElementStats(); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java index d937d813..8b775a2d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java @@ -60,9 +60,10 @@ public class TypeManager { } /* - * caches all the stats which the type can have to reduce future - * both item generation (and GUI) calculations. probably the thing - * which takes the most time when loading item types. + * Caches all the stats which the type can have to reduce future + * both item generation (and GUI) calculations. This is a great + * optimisation when loading items, it is less important when + * displaying the item editor UI */ type.getAvailableStats().clear(); MMOItems.plugin.getStats().getAll().stream().filter(stat -> stat.isCompatible(type)).forEach(stat -> type.getAvailableStats().add(stat)); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java index 11c723eb..33d69711 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java @@ -16,6 +16,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula.FormulaSaveOption; import net.Indyuce.mmoitems.gui.edition.AbilityListEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.skill.RegisteredSkill; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityListData; import net.Indyuce.mmoitems.stat.data.random.RandomAbilityData; @@ -33,6 +34,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "abilities") public class Abilities extends ItemStat { public Abilities() { super("ABILITY", Material.BLAZE_POWDER, "Item Abilities", @@ -57,30 +59,33 @@ public class Abilities extends ItemStat @BackwardsCompatibility(version = "6.10") @Override - public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { + public void readTranslationFile(@NotNull ConfigurationSection translationFile) { + Object configObject = translationFile.get("ability"); - // COMPATIBILITY CODE FOR MI <6.10 - if (!(configObject instanceof ConfigurationSection)) { - generalFormat = legacyLanguageFile.getString("ability-format"); - modifierIfAny = "\n"; - modifierNewLine = "\n"; - modifierForEach = legacyLanguageFile.getString("ability-modifier"); - modifierSplitter = ""; - abilitySplitter = legacyLanguageFile.getString("ability-splitter"); - useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty(); - modifiersPerLine = 1; - return; + // Up to date code + if (configObject instanceof ConfigurationSection) { + final ConfigurationSection config = (ConfigurationSection) configObject; + generalFormat = config.getString("general-format"); + modifierIfAny = config.getString("modifier-if-any", ""); // Backwards compatibility + modifierNewLine = "\n" + config.getString("modifier-new-line", ""); // Backwards compatibility + modifierForEach = config.getString("modifier-foreach"); + modifierSplitter = config.getString("modifier-splitter"); + abilitySplitter = config.getString("ability-splitter.format"); + useAbilitySplitter = config.getBoolean("ability-splitter.enabled"); + modifiersPerLine = config.getInt("modifiers-per-line"); } - final ConfigurationSection config = (ConfigurationSection) configObject; - generalFormat = config.getString("general-format"); - modifierIfAny = config.getString("modifier-if-any", ""); // Backwards compatibility - modifierNewLine = "\n" + config.getString("modifier-new-line", ""); // Backwards compatibility - modifierForEach = config.getString("modifier-foreach"); - modifierSplitter = config.getString("modifier-splitter"); - abilitySplitter = config.getString("ability-splitter.format"); - useAbilitySplitter = config.getBoolean("ability-splitter.enabled"); - modifiersPerLine = config.getInt("modifiers-per-line"); + // COMPATIBILITY CODE FOR MI <6.10 + else { + generalFormat = translationFile.getString("ability-format"); + modifierIfAny = "\n"; + modifierNewLine = "\n"; + modifierForEach = translationFile.getString("ability-modifier"); + modifierSplitter = ""; + abilitySplitter = translationFile.getString("ability-splitter"); + useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty(); + modifiersPerLine = 1; + } } @Override @@ -126,11 +131,6 @@ public class Abilities extends ItemStat item.addItemTag(getAppliedNBT(data)); } - @Override - public String getLegacyTranslationPath() { - return "ability-format"; - } - @NotNull @Override public ArrayList getAppliedNBT(@NotNull AbilityListData data) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionLeftClick.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionLeftClick.java index 7ec14c1a..4838e531 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionLeftClick.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionLeftClick.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; @@ -15,6 +16,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +@HasCategory(cat = "abilities") public class ActionLeftClick extends StringStat { public ActionLeftClick() { super("ON_LEFT_CLICK", Material.COMMAND_BLOCK_MINECART, "Left Click Action", new String[]{"ID of skill ran when left clicking. When used,", "The item will naturally apply item costs like", "mana, stamina, cooldown. This option overrides the", "script provided by the item type."}, new String[]{"weapon"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionRightClick.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionRightClick.java index 46da4883..4198ec45 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionRightClick.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ActionRightClick.java @@ -6,11 +6,13 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "abilities") public class ActionRightClick extends StringStat { public ActionRightClick() { super("ON_RIGHT_CLICK", Material.COMMAND_BLOCK_MINECART, "Right Click Action", new String[]{"ID of skill ran when right clicking. When used,", "The item will naturally apply item costs like", "mana, stamina, cooldown. This option overrides the", "script provided by the item type."}, new String[]{"weapon"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java index 494eb7d2..62c585ba 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java @@ -5,6 +5,7 @@ import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import net.Indyuce.mmoitems.api.player.RPGPlayer; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -21,6 +22,7 @@ import java.util.ArrayList; /** * @author Gunging */ +@HasCategory(cat = "requirement") public class Amphibian extends ChooseStat implements ItemRestriction, GemStoneStat { public static final StatChoice NORMAL = new StatChoice("NORMAL", "No liquids dependency"), diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java index 33de506f..6cad020d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java @@ -13,6 +13,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.ArrowParticlesEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ArrowParticlesData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -30,6 +31,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "misc") public class ArrowParticles extends ItemStat { public ArrowParticles() { super("ARROW_PARTICLES", Material.SPECTRAL_ARROW, "Arrow Particles", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java index 71fb26a5..afd83038 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java @@ -14,6 +14,7 @@ import net.Indyuce.mmoitems.api.interaction.projectile.ArrowPotionEffectArrayIte import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.PotionEffectData; import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; @@ -33,6 +34,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; +@HasCategory(cat = "misc") public class ArrowPotionEffects extends ItemStat { public ArrowPotionEffects() { super("ARROW_POTION_EFFECTS", Material.TIPPED_ARROW, "Arrow Potion Effects", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/BrowserDisplayIDX.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/BrowserDisplayIDX.java index 23812b60..0538094a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/BrowserDisplayIDX.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/BrowserDisplayIDX.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; +import net.Indyuce.mmoitems.stat.type.TemplateOption; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,19 +19,15 @@ import java.util.HashMap; import java.util.Map; @HasCategory(cat = "template_option") -public class BrowserDisplayIDX extends DoubleStat { +public class BrowserDisplayIDX extends DoubleStat implements TemplateOption { public BrowserDisplayIDX() { - super("BROWSER_IDX", Material.GHAST_TEAR, "Browser Index", new String[] {"Used to display similar items together,", "neatly in the GUI \u00a7a/mmoitems browse", "", "Items with the same index are grouped."}, new String[0]); + super("BROWSER_IDX", + Material.GHAST_TEAR, + "Browser Index", + new String[]{"Used to display similar items together,", "neatly in the GUI \u00a7a/mmoitems browse", "", "Items with the same index are grouped."}, + null); } - @Override - public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) { - // Does not participate in actual items - } - - @Override - public void whenLoaded(@NotNull ReadMMOItem mmoitem) { } - /** * They will be ordered. * diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanBreak.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanBreak.java index 7563ba1e..bdc2e209 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanBreak.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanBreak.java @@ -12,6 +12,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; @@ -29,6 +30,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +@HasCategory(cat = "misc") @VersionDependant(version = {1, 20, 6}) public class CanBreak extends ItemStat { public CanBreak() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java index 5f1a19d0..6f134084 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import java.util.List; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -23,6 +24,7 @@ import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import io.lumine.mythic.lib.api.item.NBTItem; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "consumables") public class CanDeconstruct extends BooleanStat implements ConsumableItemInteraction { public CanDeconstruct() { super("CAN_DECONSTRUCT", Material.PAPER, "Can Deconstruct?", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java index 52893f71..33c05041 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java @@ -14,6 +14,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.SkullTextureData; import net.Indyuce.mmoitems.stat.type.BooleanStat; @@ -32,6 +33,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Objects; import java.util.logging.Level; +@HasCategory(cat = "consumables") public class CanDeskin extends BooleanStat implements ConsumableItemInteraction { public CanDeskin() { super("CAN_DESKIN", Material.LEATHER, "Can Deskin?", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java index 71eb5d8d..bfe3a963 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -19,6 +20,7 @@ import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import io.lumine.mythic.lib.api.item.NBTItem; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "consumables") public class CanIdentify extends BooleanStat implements ConsumableItemInteraction { public CanIdentify() { super("CAN_IDENTIFY", Material.PAPER, "Can Identify?", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java index 2332de71..a41f25f7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmoitems.ItemStats; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.interaction.Consumable; @@ -29,6 +30,7 @@ import java.util.List; * * @author Gunging */ +@HasCategory(cat = "consumables") public class CanUnsocket extends BooleanStat implements ConsumableItemInteraction { public CanUnsocket() { super("CAN_UNSOCKET", Material.PAPER, "Can Unsocket?", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java index b0c4353e..af6d3d26 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.CommandListEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.CommandData; import net.Indyuce.mmoitems.stat.data.CommandListData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -25,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "abilities") public class Commands extends ItemStat { private static final int MAXIMUM_COMMANDS = 15; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java index 492f9948..8bf98217 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java @@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -26,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "skins") public class CompatibleIds extends ItemStat { public CompatibleIds() { super("COMPATIBLE_IDS", Material.COMMAND_BLOCK, "Compatible IDs", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java index 5d6fb894..75cf2275 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java @@ -12,6 +12,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -27,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "skins") public class CompatibleMaterials extends ItemStat { public CompatibleMaterials() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java index 38d23ad6..6c0508b1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java @@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -26,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "skins") public class CompatibleTypes extends ItemStat { public CompatibleTypes() { super("COMPATIBLE_TYPES", Material.COMMAND_BLOCK, "Compatible Types", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Crafting.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Crafting.java index e02a34ca..d352d990 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Crafting.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Crafting.java @@ -14,10 +14,12 @@ import net.Indyuce.mmoitems.gui.edition.recipe.RecipeTypeListGUI; import net.Indyuce.mmoitems.gui.edition.recipe.button.RecipeButtonAction; import net.Indyuce.mmoitems.gui.edition.recipe.gui.RecipeEditorGUI; import net.Indyuce.mmoitems.gui.edition.recipe.interpreter.RMG_RecipeInterpreter; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; +import net.Indyuce.mmoitems.stat.type.TemplateOption; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -30,7 +32,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -public class Crafting extends ItemStat, StatData> { +@HasCategory(cat = "misc") +public class Crafting extends ItemStat, StatData> implements TemplateOption { public Crafting() { super("CRAFTING", Material.CRAFTING_TABLE, "Crafting", new String[] { "The crafting recipes of your item.", "Changing a recipe requires &o/mi reload recipes&7." }, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java index 83a18f8b..6d27a159 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java @@ -1,14 +1,19 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import net.Indyuce.mmoitems.stat.type.TemplateOption; import org.bukkit.Material; +@HasCategory(cat = "template_option") public class CraftingPermission extends StringStat implements TemplateOption, GemStoneStat { public CraftingPermission() { - super("CRAFT_PERMISSION", Material.OAK_SIGN, "Crafting Recipe Permission", + super("CRAFT_PERMISSION", + Material.OAK_SIGN, + "Crafting Recipe Permission", new String[]{"The permission needed to craft this item.", "Changing this value requires &o/mi reload recipes&7."}, - new String[0]); + null); } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java index 79abb178..76a86be5 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.DoubleStat; @@ -21,6 +22,7 @@ import org.jetbrains.annotations.NotNull; * * @author indyuce */ +@HasCategory(cat = "durability") public class CustomDurability extends DoubleStat implements InternalStat { public CustomDurability() { super("DURABILITY", Material.SHEARS, "Custom Durability", new String[0], new String[]{"!block", "all"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java index 2e192145..f14ff8f2 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; @@ -16,6 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +@HasCategory(cat = "item") public class CustomModelData extends DoubleStat implements GemStoneStat { public CustomModelData() { super("CUSTOM_MODEL_DATA", Material.PAINTING, "Custom Model Data", new String[] { "Your 1.14+ model data." }, new String[] { "!block", "all" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java index b83ba64d..eff088b8 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java @@ -6,6 +6,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.CustomSound; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -33,6 +34,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "misc") public class CustomSounds extends ItemStat implements GemStoneStat, PlayerConsumable { public CustomSounds() { super("SOUNDS", Material.JUKEBOX, "Custom Sounds", new String[]{"The custom sounds your item will use."}, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisableDeathDrop.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisableDeathDrop.java index cf1679e0..a593ed16 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisableDeathDrop.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisableDeathDrop.java @@ -1,8 +1,10 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.BooleanStat; import org.bukkit.Material; +@HasCategory(cat = "toggles") public class DisableDeathDrop extends BooleanStat { public DisableDeathDrop() { super("DISABLE_DEATH_DROP", Material.BONE, "Disable Drop On Death", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java index 55fc3975..0f7229df 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.ItemTier; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.NameData; @@ -21,6 +22,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +@HasCategory(cat = "tooltip") public class DisplayName extends StringStat implements GemStoneStat { public DisplayName() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java index 31b604a0..bd2085af 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java @@ -1,11 +1,17 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; +@HasCategory(cat = "tooltip") public class DisplayedType extends StringStat implements GemStoneStat { public DisplayedType() { - super("DISPLAYED_TYPE", Material.OAK_SIGN, "Displayed Type", new String[]{"This option will only affect the", "type displayed on the item lore."}, new String[0]); + super("DISPLAYED_TYPE", + Material.OAK_SIGN, + "Displayed Type", + new String[]{"This option will only affect the", "type displayed on the item lore."}, + null); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java index 7b9d1c58..ad198a64 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ColorData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -26,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "item") public class DyeColor extends ItemStat { public DyeColor() { super("DYE_COLOR", Material.RED_DYE, "Dye Color", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java index c34b3dcf..a204e1c3 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java @@ -16,6 +16,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.PotionEffectData; import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; @@ -37,6 +38,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; +@HasCategory(cat = "consumables") public class Effects extends ItemStat implements PlayerConsumable { public Effects() { super("EFFECTS", Material.POTION, "Effects", new String[]{"The potion effects your", "consumable item grants."}, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java index 31b94e0b..ed4c6c5a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java @@ -4,15 +4,14 @@ import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; -import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.element.Element; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.ElementsEdition; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ElementListData; import net.Indyuce.mmoitems.stat.data.random.RandomElementListData; import net.Indyuce.mmoitems.stat.data.type.StatData; @@ -22,7 +21,6 @@ import net.Indyuce.mmoitems.stat.type.Previewable; import net.Indyuce.mmoitems.util.ElementStatType; import net.Indyuce.mmoitems.util.Pair; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -33,6 +31,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; +@HasCategory(cat = "elements") public class Elements extends ItemStat implements Previewable { public Elements() { super("ELEMENT", Material.SLIME_BALL, "Elements", new String[]{"The elements of your item."}, @@ -105,27 +104,21 @@ public class Elements extends ItemStat i private Map statFormat = new HashMap<>(); @Override - public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { - - // LEGACY CODE - if (configObject instanceof String) { - for (ElementStatType statType : ElementStatType.values()) - statFormat.put(statType, legacyLanguageFile.getString("elemental-" + statType.lowerCaseName(), "")); - } + public void readTranslationFile(@NotNull ConfigurationSection translationFile) { // Up-to-date code - else { - Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section"); + Object configObject = translationFile.get("element"); + if (configObject instanceof ConfigurationSection) { final ConfigurationSection config = (ConfigurationSection) configObject; for (ElementStatType statType : ElementStatType.values()) statFormat.put(statType, config.getString(statType.lowerCaseName(), "")); } - } - @Override - public String getLegacyTranslationPath() { - // Arbitrary - return "elemental-damage"; + // LEGACY CODE + else { + for (ElementStatType statType : ElementStatType.values()) + statFormat.put(statType, translationFile.getString("elemental-" + statType.lowerCaseName(), "")); + } } @NotNull diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Enchants.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Enchants.java index 19a4ae4b..cad650bc 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Enchants.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Enchants.java @@ -18,6 +18,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.comp.enchants.EnchantPlugin; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.EnchantListData; import net.Indyuce.mmoitems.stat.data.random.RandomEnchantListData; import net.Indyuce.mmoitems.stat.data.type.StatData; @@ -41,6 +42,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; +@HasCategory(cat = "item") public class Enchants extends ItemStat implements Upgradable { public Enchants() { super("ENCHANTS", Material.ENCHANTED_BOOK, "Enchantments", new String[]{"The item enchants."}, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/FallDamageMultiplier.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/FallDamageMultiplier.java index c166a2ac..0596622e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/FallDamageMultiplier.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/FallDamageMultiplier.java @@ -1,10 +1,12 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; @VersionDependant(version = {1, 20, 5}) +@HasCategory(cat = "vanilla_attribute") public class FallDamageMultiplier extends DoubleStat { public FallDamageMultiplier() { super("FALL_DAMAGE_MULTIPLIER", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java index 3b644e58..8eb571e4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java @@ -2,12 +2,14 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "gem_stones") public class GemColor extends StringStat implements GemStoneStat { public GemColor() { super("GEM_COLOR", Material.LIGHT_BLUE_DYE, "Gem Color", new String[] { "Defines the color of the socket in", "which the gem can be applied." }, new String[] { "gem_stone" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java index 552e0055..30acb2a6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java @@ -13,6 +13,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.GemSocketsData; import net.Indyuce.mmoitems.stat.data.GemstoneData; import net.Indyuce.mmoitems.stat.data.type.StatData; @@ -30,6 +31,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "gem_stones") public class GemSockets extends ItemStat { public GemSockets() { super("GEM_SOCKETS", Material.EMERALD, "Gem Sockets", new String[]{"The amount of gem", "sockets your weapon has."}, @@ -46,26 +48,21 @@ public class GemSockets extends ItemStat { private String emptyGemSocketFormat, filledGemSocketFormat; @Override - public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { - - // LEGACY CODE - if (configObject instanceof String) { - emptyGemSocketFormat = legacyLanguageFile.getString("empty-gem-socket"); - filledGemSocketFormat = legacyLanguageFile.getString("filled-gem-socket"); - } + public void readTranslationFile(@NotNull ConfigurationSection translationFile) { // Up-to-date code - else { - Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section"); + Object configObject = translationFile.get("gem-sockets"); + if (configObject instanceof ConfigurationSection) { final ConfigurationSection config = (ConfigurationSection) configObject; emptyGemSocketFormat = config.getString("empty"); filledGemSocketFormat = config.getString("filled"); } - } - @Override - public String getLegacyTranslationPath() { - return "empty-gem-socket"; + // LEGACY CODE + else { + emptyGemSocketFormat = translationFile.getString("empty-gem-socket"); + filledGemSocketFormat = translationFile.getString("filled-gem-socket"); + } } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java index 9c25fc24..bb41231e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -10,6 +11,7 @@ import org.jetbrains.annotations.NotNull; /** * Defines how gem stats will scale when the item they are put on upgrades. */ +@HasCategory(cat = "gem_stones") public class GemUpgradeScaling extends ChooseStat implements GemStoneStat { public static final StatChoice NEVER = new StatChoice("NEVER", "Gem stats are never scaled by upgrading the item."), diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java index 5591e35e..2c0f045d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java @@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringListStat; @@ -20,10 +21,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "misc") public class GrantedPermissions extends StringListStat implements GemStoneStat { public GrantedPermissions() { - super("GRANTED_PERMISSIONS", Material.NAME_TAG, "Granted Permissions", - new String[] { "A list of permissions that will,", "be granted by the item." }, new String[0]); + super("GRANTED_PERMISSIONS", + Material.NAME_TAG, + "Granted Permissions", + new String[]{"A list of permissions that will,", "be granted by the item."}, + new String[0]); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDurabilityBar.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDurabilityBar.java index 42518226..3b535592 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDurabilityBar.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDurabilityBar.java @@ -1,11 +1,13 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.BooleanStat; import org.bukkit.Material; +@HasCategory(cat = "tooltip") public class HideDurabilityBar extends BooleanStat { public HideDurabilityBar() { super("DURABILITY_BAR", Material.DAMAGED_ANVIL, "Hide Durability Bar", - new String[] { "Enable this to have the green bar", "hidden when using &ncustom&7 durability.", "Does not work when using vanilla durability." }, new String[] { "!block", "all"}); + new String[]{"Enable this to have the green bar", "hidden when using &ncustom&7 durability.", "Does not work when using vanilla durability."}, new String[]{"!block", "all"}); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDye.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDye.java index 7fc0c412..b86682ad 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDye.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideDye.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.BooleanData; import net.Indyuce.mmoitems.stat.type.BooleanStat; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; @@ -19,6 +20,7 @@ import java.util.ArrayList; */ @Deprecated @VersionDependant(version = {1, 16, 3}) +@HasCategory(cat = "tooltip") public class HideDye extends BooleanStat { public HideDye() { super("HIDE_DYE", Material.CYAN_DYE, "Hide Dyed", new String[] { "Enable to hide the 'Dyed' tag from the item." }, new String[0], diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideEnchants.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideEnchants.java index 644b309f..3ceb17b2 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideEnchants.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideEnchants.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.BooleanData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.BooleanStat; @@ -18,6 +19,7 @@ import java.util.ArrayList; * @deprecated Merge with other Hide- stats */ @Deprecated +@HasCategory(cat = "tooltip") public class HideEnchants extends BooleanStat { public HideEnchants() { super("HIDE_ENCHANTS", Material.BOOK, "Hide Enchantments", new String[] { "Enable to completely hide your item", "enchants. You can still see the glowing effect." }, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HidePotionEffects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HidePotionEffects.java index 05a68b38..d7bd6d0c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HidePotionEffects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HidePotionEffects.java @@ -6,6 +6,7 @@ import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.BooleanData; import net.Indyuce.mmoitems.stat.type.BooleanStat; import org.bukkit.Material; @@ -19,6 +20,7 @@ import java.util.Arrays; /** * @deprecated Merge with other Hide- stats */ +@HasCategory(cat = "tooltip") @Deprecated public class HidePotionEffects extends BooleanStat { public HidePotionEffects() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideTrim.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideTrim.java index a891be82..2b8cee28 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideTrim.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/HideTrim.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.BooleanData; import net.Indyuce.mmoitems.stat.type.BooleanStat; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; @@ -19,6 +20,7 @@ import java.util.ArrayList; */ @Deprecated @VersionDependant(version = {1, 20}) +@HasCategory(cat = "tooltip") public class HideTrim extends BooleanStat { public HideTrim() { super("HIDE_ARMOR_TRIM", Material.LEATHER_CHESTPLATE, "Hide Armor Trim", new String[]{"Hides armor trim from item lore."}, new String[]{"armor", "skin"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java index cb568e93..3a759781 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java @@ -5,6 +5,7 @@ import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -24,6 +25,7 @@ import java.util.ArrayList; * @implNote Due to 1.20.5+ modifying the location of many vanilla tags, * all version-friendly implementations must use ItemMeta methods. */ +@HasCategory(cat = "durability") public class ItemDamage extends DoubleStat implements GemStoneStat { public ItemDamage() { super("ITEM_DAMAGE", Material.FISHING_ROD, "Base Item Damage", @@ -73,6 +75,7 @@ public class ItemDamage extends DoubleStat implements GemStoneStat { @Override public String getLegacyTranslationPath() { + // Should be useless return "durability"; } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java index d898b6fd..4ba765c6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java @@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.InternalStat; @@ -20,13 +21,16 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -public class ItemLevel extends ItemStat implements InternalStat { +@HasCategory(cat = "rarity") +public class ItemLevel extends ItemStat implements InternalStat { public ItemLevel() { super("ITEM_LEVEL", Material.EXPERIENCE_BOTTLE, "Item Level", new String[] { "The item level" }, new String[0]); } @Override - public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) { item.addItemTag(getAppliedNBT(data)); } + public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) { + item.addItemTag(getAppliedNBT(data)); + } @Nullable @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java index 5e8f7dad..f22d583f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java @@ -13,6 +13,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.ParticlesEdition; import net.Indyuce.mmoitems.particle.api.ParticleType; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -31,10 +32,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "misc") public class ItemParticles extends ItemStat { public ItemParticles() { super("ITEM_PARTICLES", Material.PINK_STAINED_GLASS, "Item Particles", new String[] { "The particles displayed when", - "holding/wearing your item.", "", ChatColor.BLUE + "A tutorial is available on the wiki." }, new String[] { "all", "!block" }); + "holding/wearing your item.", "Please refer to the wiki for further info." }, new String[] { "all", "!block" }); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java index d4c02342..f56b29c4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java @@ -5,6 +5,7 @@ import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.ItemSet; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; @@ -17,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +@HasCategory(cat = "rarity") public class ItemSetStat extends StringStat implements GemStoneStat { public ItemSetStat() { super("SET", Material.LEATHER_CHESTPLATE, "Item Set", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java index 1dba0742..bb8b051e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import org.apache.commons.lang.Validate; @@ -14,6 +15,7 @@ import net.Indyuce.mmoitems.stat.type.StringStat; import io.lumine.mythic.lib.api.item.ItemTag; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "rarity") public class ItemTierStat extends StringStat implements GemStoneStat { public ItemTierStat() { super("TIER", Material.DIAMOND, "Item Tier", new String[] { "The tier defines how rare your item is", "and what item is dropped when your", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTypeRestriction.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTypeRestriction.java index 539217ff..1183bd17 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTypeRestriction.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTypeRestriction.java @@ -7,6 +7,7 @@ import java.util.Optional; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.Validate; @@ -30,6 +31,7 @@ import io.lumine.mythic.lib.api.util.AltChar; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +@HasCategory(cat = "gem_stones") public class ItemTypeRestriction extends ItemStat { public ItemTypeRestriction() { super("ITEM_TYPE_RESTRICTION", Material.EMERALD, "Item Type Restriction", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java index 1ec6ed91..95edd7c7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java @@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringListStat; @@ -21,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "tooltip") public class Lore extends StringListStat implements GemStoneStat { public Lore() { super("LORE", Material.WRITABLE_BOOK, "Lore", new String[]{"The item lore."}, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java index 3508ad4b..13c3d821 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java @@ -1,40 +1,41 @@ package net.Indyuce.mmoitems.stat; -import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.data.StringListData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; -import org.apache.commons.lang.Validate; -import org.bukkit.Material; - +import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; -import net.Indyuce.mmoitems.stat.data.type.StatData; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.data.StringData; +import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; -import io.lumine.mythic.lib.api.item.ItemTag; +import org.apache.commons.lang.Validate; +import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "tooltip") public class LoreFormat extends StringStat implements GemStoneStat { - public LoreFormat() { - super("LORE_FORMAT", Material.MAP, "Lore Format", new String[] { "The lore format decides", - "where each stat goes.", "&9Formats can be configured in", "&9the lore-formats folder" }, - new String[0]); - } + public LoreFormat() { + super("LORE_FORMAT", + Material.MAP, + "Lore Format", + new String[]{"The lore format decides where each", "stat goes. Formats can be configured", "in the lore-formats folder"}, + new String[0]); + } - @Override - public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) { - String path = data.toString(); - Validate.isTrue(MMOItems.plugin.getLore().hasFormat(path), "Could not find lore format with ID '" + path + "'"); + @Override + public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) { + String path = data.toString(); + Validate.isTrue(MMOItems.plugin.getLore().hasFormat(path), "Could not find lore format with ID '" + path + "'"); - item.addItemTag(new ItemTag(getNBTPath(), path)); - } + item.addItemTag(new ItemTag(getNBTPath(), path)); + } - @Override - public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { - Validate.isTrue(MMOItems.plugin.getLore().hasFormat(message), "Couldn't find lore format with ID '" + message + "'."); + @Override + public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { + Validate.isTrue(MMOItems.plugin.getLore().hasFormat(message), "Couldn't find lore format with ID '" + message + "'."); - inv.getEditedSection().set(getPath(), message); - inv.registerTemplateEdition(); - inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Lore Format successfully changed to " + message + "."); - } + inv.getEditedSection().set(getPath(), message); + inv.registerTemplateEdition(); + inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Lore Format successfully changed to " + message + "."); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LostWhenBroken.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LostWhenBroken.java index 5bb4216f..df4bc99e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LostWhenBroken.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LostWhenBroken.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Material; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -9,6 +10,7 @@ import net.Indyuce.mmoitems.stat.type.BooleanStat; import io.lumine.mythic.lib.api.item.ItemTag; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "durability") public class LostWhenBroken extends BooleanStat { public LostWhenBroken() { super("WILL_BREAK", Material.SHEARS, "Lost when Broken?", new String[] { "If set to true, the item will be lost", "once it reaches 0 durability." }, new String[] { "!block", "all" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java index a564c5d3..674bc5fb 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute.*; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; @@ -18,6 +19,11 @@ import org.jetbrains.annotations.NotNull; import java.util.Objects; +/** + * @deprecated To be removed + */ +@Deprecated +@HasCategory(cat = "abilities") public class LuteAttackEffectStat extends StringStat implements GemStoneStat { public LuteAttackEffectStat() { super("LUTE_ATTACK_EFFECT", Material.DIAMOND_HORSE_ARMOR, "Lute Attack Effect", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java index 308c06b7..077c5b10 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java @@ -2,12 +2,18 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +/** + * @deprecated To be removed + */ +@Deprecated +@HasCategory(cat = "abilities") public class LuteAttackSoundStat extends StringStat implements GemStoneStat { public LuteAttackSoundStat() { super("LUTE_ATTACK_SOUND", Material.GOLDEN_HORSE_ARMOR, "Lute Attack Sound", new String[] { "The sound played when", "basic attacking with this lute." }, new String[] { "lute" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java index bd851201..befe2432 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java @@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.ItemRestriction; @@ -21,13 +22,13 @@ import org.jetbrains.annotations.NotNull; * @author Roch Blondiaux * @date 24/10/2022 */ +@HasCategory(cat = "use_cost") public class ManaCost extends DoubleStat implements ItemRestriction, PlayerConsumable { public ManaCost() { super("MANA_COST", Material.LAPIS_LAZULI, "Mana Cost", new String[]{"Mana spent by your weapon to be used."}, new String[]{"weapon"}); } - @Override public boolean canUse(RPGPlayer player, NBTItem item, boolean message) { // No data no service diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java index e7ecb2c2..67fe26a7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java @@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.MaterialData; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.md_5.bungee.api.ChatColor; @@ -27,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "item") public class MaterialStat extends ItemStat { public MaterialStat() { super("MATERIAL", VMaterial.GRASS_BLOCK.get(), "Material", new String[] { "Your item material." }, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxConsume.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxConsume.java index 38de3ad2..62d02f76 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxConsume.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxConsume.java @@ -3,11 +3,14 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; +import org.checkerframework.checker.index.qual.HasSubsequence; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "consumables") public class MaxConsume extends DoubleStat { public MaxConsume() { super("MAX_CONSUME", Material.BLAZE_POWDER, "Max Consume", new String[]{"Max amount of usage before", "item disappears."}, new String[]{"consumable"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java index ad4cbad6..7464c407 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @VersionDependant(version = {1, 20, 5}) +@HasCategory(cat = "durability") public class MaxItemDamage extends DoubleStat implements GemStoneStat { public MaxItemDamage() { super("MAX_ITEM_DAMAGE", Material.DAMAGED_ANVIL, "Maximum Vanilla Durability", new String[]{"Only available in 1.20.5+", "Maximum amount of durability on your item.", "This works using vanilla durability and is", "much more stable than Custom Durability."}, new String[]{"all"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java index 358956f3..4df688bb 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.MaterialData; import net.Indyuce.mmoitems.stat.type.DoubleStat; @@ -25,6 +26,7 @@ import org.jetbrains.annotations.NotNull; * * @author indyuce */ +@HasCategory(cat = "durability") public class MaximumDurability extends DoubleStat implements ItemRestriction, GemStoneStat, Upgradable { public MaximumDurability() { super("MAX_DURABILITY", Material.SHEARS, "Maximum Custom Durability", new String[]{"The amount of uses before your", "item becomes unusable/breaks."}, new String[]{"!block", "all"}); @@ -36,9 +38,8 @@ public class MaximumDurability extends DoubleStat implements ItemRestriction, Ge } @Override - public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { - generalStatFormat = legacyLanguageFile.getString("item-damage"); - if (generalStatFormat == null) generalStatFormat = legacyLanguageFile.getString("durability"); + public void readTranslationFile(@NotNull ConfigurationSection legacyLanguageFile) { + generalStatFormat = legacyLanguageFile.getString("durability"); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java index e4113adb..4889d08f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java @@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.type.StringListStat; import org.apache.commons.lang.Validate; @@ -21,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Optional; +@HasCategory(cat = "misc") public class NBTTags extends StringListStat { public NBTTags() { super("CUSTOM_NBT", Material.NAME_TAG, "NBT Tags", new String[] { "Custom NBT Tags." }, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java index a26b97d0..360815f0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java @@ -15,6 +15,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.PotionEffectData; import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; @@ -37,10 +38,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; -/** - * This class has not been updated for the item generation update!!! The potion - * amplifier and duration are not numeric formulas but flat values.... TODO - */ +@HasCategory(cat = "misc") public class PermanentEffects extends ItemStat { public PermanentEffects() { super("PERM_EFFECTS", Material.POTION, "Permanent Effects", new String[]{"The potion effects your", "item grants to the holder."}, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java index a6d2e7a0..4b7b0d56 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java @@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemRestriction; @@ -29,6 +30,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +@HasCategory(cat = "requirement") public class Permission extends StringListStat implements ItemRestriction { public Permission() { super("PERMISSION", Material.OAK_SIGN, "Permission", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PickaxePower.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PickaxePower.java index 0fe46efe..03362ee4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PickaxePower.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PickaxePower.java @@ -3,12 +3,14 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "tools") public class PickaxePower extends DoubleStat { public PickaxePower() { super("PICKAXE_POWER", Material.IRON_PICKAXE, "Pickaxe Power", new String[]{"The breaking strength of the", "item when mining custom blocks."}, new String[]{"tool"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java index 39610204..f3ceb4b2 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java @@ -8,6 +8,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ColorData; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.NotImplementedException; @@ -25,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +@HasCategory(cat = "item") public class PotionColor extends ItemStat { public PotionColor() { super("POTION_COLOR", Material.POTION, "Potion Color", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionEffects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionEffects.java index 7a97d31e..5ddea86e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionEffects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionEffects.java @@ -5,6 +5,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.util.AltChar; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -34,6 +35,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; +@HasCategory(cat = "consumables") public class PotionEffects extends ItemStat { public PotionEffects() { super("POTION_EFFECT", Material.POTION, "Potion Effects", new String[] { "The effects of your potion.", "(May have an impact on color).", "Does NOT support tipped arrows." }, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java index 7203f6ba..295591bc 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java @@ -12,6 +12,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -34,7 +35,7 @@ import java.util.Optional; * * @author Kasprr */ - +@HasCategory(cat = "misc") public class ProjectileParticles extends ItemStat { public ProjectileParticles() { super("PROJECTILE_PARTICLES", Material.LIME_STAINED_GLASS, "Projectile Particles", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java index a371e777..e925a31a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java @@ -12,6 +12,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.GemSocketsData; import net.Indyuce.mmoitems.stat.data.GemstoneData; @@ -39,6 +40,7 @@ import java.util.logging.Level; * * @author Gunging */ +@HasCategory(cat = "consumables") public class RandomUnsocket extends DoubleStat implements ConsumableItemInteraction { public RandomUnsocket() { super("RANDOM_UNSOCKET", Material.BOWL, "Random Unsocket", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java index 1ddf3285..e791c401 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.listener.CustomSoundListener; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.util.MMOUtils; @@ -23,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Function; +@HasCategory(cat = "consumables") public class RepairPower extends DoubleStat implements ConsumableItemInteraction { public RepairPower() { super("REPAIR", Material.ANVIL, "Repair Power", new String[]{"The flat amount of durability your item", "can repair when set an item."}, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java index a8e657f7..792925a8 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java @@ -5,6 +5,7 @@ import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.player.PlayerData; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; @@ -12,6 +13,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +@HasCategory(cat = "consumables") public class RepairPowerPercent extends DoubleStat implements ConsumableItemInteraction { public RepairPowerPercent() { super("REPAIR_PERCENT", Material.DAMAGED_ANVIL, "Repair Percentage", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java index 06e4fc4d..0031aa55 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java @@ -1,9 +1,11 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; +@HasCategory(cat = "consumables") public class RepairReference extends StringStat implements GemStoneStat { public RepairReference() { super("REPAIR_TYPE", Material.ANVIL, "Repair Reference", new String[]{"A repair consumable may only be used onto", "an item with the same repair reference."}, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java index 4ec579e5..fce3aebd 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java @@ -5,6 +5,7 @@ import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.player.RPGPlayer; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -17,6 +18,7 @@ import java.util.ArrayList; /** * @author Gunging */ +@HasCategory(cat = "requirement") public class RequiredBiomes extends StringListStat implements ItemRestriction, GemStoneStat { public RequiredBiomes() { super("REQUIRED_BIOMES", Material.JUNGLE_SAPLING, "Required Biomes", new String[] { "The biome the player must be within", "for this item to activate." }, new String[] { "!block", "all" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java index 12c120ca..c75e0376 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java @@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -30,6 +31,7 @@ import java.util.List; import java.util.Optional; import java.util.regex.Pattern; +@HasCategory(cat = "requirement") public class RequiredClass extends StringListStat implements ItemRestriction, GemStoneStat { public RequiredClass() { super("REQUIRED_CLASS", Material.WRITABLE_BOOK, "Required Class", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredLevel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredLevel.java index b00d4112..cf081ea0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredLevel.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredLevel.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.RequiredLevelData; import net.Indyuce.mmoitems.stat.type.RequiredLevelStat; import org.bukkit.ChatColor; @@ -11,6 +12,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "requirement") public class RequiredLevel extends RequiredLevelStat { /** diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java index 4364e231..a455cd58 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.PlayerConsumable; @@ -18,9 +19,14 @@ import org.jetbrains.annotations.NotNull; * * @author Gunging */ +@HasCategory(cat = "consumables") public class RestoreFood extends DoubleStat implements PlayerConsumable { public RestoreFood() { - super("RESTORE_FOOD", Material.PORKCHOP, "Food Restoration", new String[]{"Food units given when consumed."}, new String[]{"consumable"}); + super("RESTORE_FOOD", + Material.PORKCHOP, + "Food Restoration", + new String[]{"Food units given when consumed."}, + new String[]{"consumable"}); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java index 31c21f25..a896e737 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.PlayerConsumable; @@ -15,6 +16,7 @@ import org.jetbrains.annotations.NotNull; * * @author Gunging */ +@HasCategory(cat = "consumables") public class RestoreHealth extends DoubleStat implements PlayerConsumable { public RestoreHealth() { super("RESTORE_HEALTH", Material.RED_DYE, "Health Restoration", new String[]{"Health given when consumed."}, new String[]{"consumable"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java index d40c158d..4b34941a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java @@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.player.PlayerData; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.PlayerConsumable; @@ -15,6 +16,7 @@ import org.jetbrains.annotations.NotNull; * * @author Gunging */ +@HasCategory(cat = "consumables") public class RestoreMana extends DoubleStat implements PlayerConsumable { public RestoreMana() { super("RESTORE_MANA", Material.LAPIS_LAZULI, "Restore Mana", new String[]{"The amount of mana", "your consumable restores."}, new String[]{"consumable"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java index dee3a405..441fb095 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.ItemStats; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.stat.data.DoubleData; @@ -17,6 +18,7 @@ import org.jetbrains.annotations.NotNull; * * @author Gunging */ +@HasCategory(cat = "consumables") public class RestoreSaturation extends DoubleStat implements PlayerConsumable { public RestoreSaturation() { super("RESTORE_SATURATION", Material.GOLDEN_CARROT, "Saturation Restoration", new String[]{"Saturation given when consumed."}, new String[]{"consumable"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java index 190069b0..ac92ec2c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java @@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.player.PlayerData; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.PlayerConsumable; @@ -15,6 +16,7 @@ import org.jetbrains.annotations.NotNull; * * @author Gunging */ +@HasCategory(cat = "consumables") public class RestoreStamina extends DoubleStat implements PlayerConsumable { public RestoreStamina() { super("RESTORE_STAMINA", Material.LIGHT_GRAY_DYE, "Restore Stamina", new String[]{"The amount of stamina/power", "your consumable restores."}, new String[]{"consumable"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java index 30b107b4..5665a96c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.util.MMOItemReforger; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.RevisionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -24,15 +25,19 @@ import java.util.Optional; /** * Regarding the auto updating of items + * * @see RevisionInventory * @see MMOItemReforger */ +@HasCategory(cat = "general") public class RevisionID extends ItemStat implements GemStoneStat { - public RevisionID() { - super("REVISION_ID", Material.ITEM_FRAME, "Revision ID", new String[] { "The Revision ID is used to determine", - "if an item is outdated or not. You", "should increase this whenever", "you make changes to your item!", "", "\u00a76The updater is smart and will apply", "\u00a76changes to the base stats of the item,", "\u00a76keeping gemstones intact (for example)."}, - new String[0]); - } + public RevisionID() { + super("REVISION_ID", + Material.ITEM_FRAME, + "Revision ID", + new String[]{"The Revision ID is used to determine", "if an item is outdated or not. You", "should increase this whenever", "you make changes to your item!", "", "\u00a76The updater is smart and will apply", "\u00a76changes to the base stats of the item,", "\u00a76keeping gemstones intact (for example)."}, + new String[0]); + } @Override public NumericStatFormula whenInitialized(Object object) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ShieldPatternStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ShieldPatternStat.java index 70436499..749fc013 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ShieldPatternStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ShieldPatternStat.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ShieldPatternData; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.Validate; @@ -31,6 +32,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; +@HasCategory(cat = "item") public class ShieldPatternStat extends ItemStat { public ShieldPatternStat() { super("SHIELD_PATTERN", Material.SHIELD, "Shield Pattern", new String[] { "The color & patterns", "of your shield." }, diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SkullTextureStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SkullTextureStat.java index b1e7b9c0..375f3ca5 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SkullTextureStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SkullTextureStat.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.SkullTextureData; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.Validate; @@ -27,6 +28,7 @@ import java.util.List; import java.util.Optional; import java.util.UUID; +@HasCategory(cat = "item") public class SkullTextureStat extends ItemStat { public SkullTextureStat() { super("SKULL_TEXTURE", Material.PLAYER_HEAD, "Skull Texture", new String[]{ diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java index c8a93e15..0fb9409b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java @@ -5,6 +5,7 @@ import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StoredTagsData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -25,6 +26,7 @@ import java.util.Optional; * the NBT tags from the previous item are transferred towards * the new item. */ +@HasCategory(cat = "misc") public class StoredTags extends ItemStat, StoredTagsData> implements InternalStat, GemStoneStat { public StoredTags() { super("STORED_TAGS", Material.OAK_SIGN, "Stored Tags", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java index 13c3c957..f56ad94e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java @@ -1,18 +1,22 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Material; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat; +@HasCategory(cat = "gem_stones") public class SuccessRate extends DoubleStat implements GemStoneStat { - /** - * in a different class because Success Rate is meant to be a proper stat - */ - public SuccessRate() { - super("SUCCESS_RATE", Material.EMERALD, "Success Rate", new String[] { "The chance of your gem/skin to successfully", - "apply onto an item. This value is 100%", "by default. If it is not successfully", "applied, the gem/skin will be lost." }, - new String[] { "gem_stone", "skin" }); - } + /** + * in a different class because Success Rate is meant to be a proper stat + */ + public SuccessRate() { + super("SUCCESS_RATE", + Material.EMERALD, + "Success Rate", + new String[]{"The chance of your gem/skin to successfully", "apply onto an item. This value is 100%", "by default. If it is not successfully", "applied, the gem/skin will be lost."}, + new String[]{"gem_stone", "skin"}); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java index 7ce39cca..3dd26c88 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.tooltip.TooltipTexture; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.data.StringData; @@ -13,10 +14,14 @@ import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "tooltip") public class TooltipStat extends StringStat implements GemStoneStat { public TooltipStat() { - super("TOOLTIP", Material.BIRCH_SIGN, "Tooltip", new String[]{"The identifier of the custom tooltip texture", "you'd like to use. Check the wiki for usage!", - "&9Tooltips are setup in the tooltips.yml file"}, new String[0]); + super("TOOLTIP", + Material.BIRCH_SIGN, + "Tooltip", + new String[]{"The identifier of the custom tooltip texture", "you'd like to use. Check the wiki for usage!", "Tooltips are setup in the tooltips.yml file"}, + new String[0]); } @Override @@ -24,7 +29,7 @@ public class TooltipStat extends StringStat implements GemStoneStat { final String format = UtilityMethods.enumName(data.toString()); final TooltipTexture texture = MMOItems.plugin.getLore().getTooltip(format); Validate.notNull(texture, "Could not find tooltip with ID '" + format + "'"); - item.addItemTag(new ItemTag("MMOITEMS_TOOLTIP", texture.getId())); + item.addItemTag(new ItemTag(getNBTPath(), texture.getId())); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java index 435683a5..79eef996 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -20,6 +21,7 @@ import org.jetbrains.annotations.Nullable; /** * @author Jules */ +@HasCategory(cat = "item") @VersionDependant(version = {1, 20}) public class TrimMaterialStat extends ChooseStat implements GemStoneStat { public TrimMaterialStat() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java index f29b8557..1e478d3f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat; @@ -20,6 +21,7 @@ import org.jetbrains.annotations.Nullable; /** * @author Jules */ +@HasCategory(cat = "item") @VersionDependant(version = {1, 20}) public class TrimPatternStat extends ChooseStat implements GemStoneStat { public TrimPatternStat() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unbreakable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unbreakable.java index 1966ccaf..b838f14e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unbreakable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unbreakable.java @@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.BooleanData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.BooleanStat; @@ -14,6 +15,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +@HasCategory(cat = "durability") public class Unbreakable extends BooleanStat { public Unbreakable() { super("UNBREAKABLE", Material.ANVIL, "Unbreakable", new String[]{"Infinite durability if set to true."}, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unstackable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unstackable.java index da7c4b6a..79975ef6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unstackable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Unstackable.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat; import java.util.UUID; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Material; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -11,6 +12,7 @@ import net.Indyuce.mmoitems.stat.type.BooleanStat; import io.lumine.mythic.lib.api.item.ItemTag; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "item") public class Unstackable extends BooleanStat { public Unstackable() { super("UNSTACKABLE", Material.CHEST_MINECART, "Unstackable", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java index 7f2d6d6b..44ce7f81 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java @@ -20,6 +20,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.UpgradingEdition; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.UpgradeData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; @@ -42,6 +43,7 @@ import java.util.List; import java.util.Optional; import java.util.Random; +@HasCategory(cat = "upgrading") public class UpgradeStat extends ItemStat implements ConsumableItemInteraction { private static final Random RANDOM = new Random(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/VanillaEatingAnimation.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/VanillaEatingAnimation.java index 6cb4a197..1053347d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/VanillaEatingAnimation.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/VanillaEatingAnimation.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Material; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -9,9 +10,14 @@ import net.Indyuce.mmoitems.stat.type.BooleanStat; import io.lumine.mythic.lib.api.item.ItemTag; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "consumables") public class VanillaEatingAnimation extends BooleanStat { public VanillaEatingAnimation() { - super("VANILLA_EATING", Material.COOKED_BEEF, "Vanilla Eating Animation", new String[] { "When enabled, players have to wait", "for the vanilla eating animation", "in order to eat the consumable.", "", "Only works on items that", "can normally be eaten."}, new String[] { "consumable" }); + super("VANILLA_EATING", + Material.COOKED_BEEF, + "Vanilla Eating Animation", + new String[]{"When enabled, players have to wait", "for the vanilla eating animation", "in order to eat the consumable.", "", "Only works on items that", "can normally be eaten."}, + new String[]{"consumable"}); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/DeprecatedStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/DeprecatedStat.java deleted file mode 100644 index 7c13b162..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/DeprecatedStat.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.Indyuce.mmoitems.stat.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface DeprecatedStat { -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/BlockID.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/BlockID.java index d8578d0d..f1efe0ef 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/BlockID.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/BlockID.java @@ -2,11 +2,13 @@ package net.Indyuce.mmoitems.stat.block; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +@HasCategory(cat = "blocks") public class BlockID extends DoubleStat { public BlockID() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/GenTemplate.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/GenTemplate.java index 02cdba69..78c66e7a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/GenTemplate.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/GenTemplate.java @@ -1,8 +1,10 @@ package net.Indyuce.mmoitems.stat.block; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; +@HasCategory(cat = "blocks") public class GenTemplate extends StringStat { public GenTemplate() { super("GEN_TEMPLATE", Material.PAPER, "Gen Template", new String[] { "Can be set to any template", "from gen-templates.yml." }, new String[] { "block" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MaxXP.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MaxXP.java index e2e4150d..ea75d661 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MaxXP.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MaxXP.java @@ -1,8 +1,10 @@ package net.Indyuce.mmoitems.stat.block; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; +@HasCategory(cat = "blocks") public class MaxXP extends DoubleStat { public MaxXP() { super("MAX_XP", Material.EXPERIENCE_BOTTLE, "Maximum XP", new String[] { "The maximum xp you will receive", "for breaking this custom block." }, new String[] { "block" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MinXP.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MinXP.java index 8e09f610..b278f1b1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MinXP.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/MinXP.java @@ -1,8 +1,10 @@ package net.Indyuce.mmoitems.stat.block; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; +@HasCategory(cat = "blocks") public class MinXP extends DoubleStat { public MinXP() { super("MIN_XP", Material.EXPERIENCE_BOTTLE, "Minimum XP", new String[] { "The minimum xp you will receive", "for breaking this custom block." }, new String[] { "block" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequirePowerToBreak.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequirePowerToBreak.java index fa5e6631..33c7a0f0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequirePowerToBreak.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequirePowerToBreak.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat.block; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.BooleanStat; import org.bukkit.Material; @@ -12,6 +13,7 @@ import org.bukkit.Material; * This option: * When toggled on, the block simply won't break/drop */ +@HasCategory(cat = "blocks") public class RequirePowerToBreak extends BooleanStat { public RequirePowerToBreak() { super("REQUIRE_POWER_TO_BREAK", Material.BEDROCK, "Require Power to Break", new String[]{"When enabled, the block will NOT break", "if the player doesn't have enough pickaxe", "power, unlike vanilla block behaviour."}, new String[]{"block"}); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequiredPower.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequiredPower.java index 5795f43f..d1abaa64 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequiredPower.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/block/RequiredPower.java @@ -1,8 +1,10 @@ package net.Indyuce.mmoitems.stat.block; +import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; +@HasCategory(cat = "blocks") public class RequiredPower extends DoubleStat { public RequiredPower() { super("REQUIRED_POWER", Material.IRON_PICKAXE, "Required Pickaxe Power", new String[] { "The required pickaxe power", "needed to break this custom block." }, new String[] { "block" }); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/category/StatCategory.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/category/StatCategory.java index 8ac16fc9..1132fa1b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/category/StatCategory.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/category/StatCategory.java @@ -1,19 +1,41 @@ package net.Indyuce.mmoitems.stat.category; +import net.Indyuce.mmoitems.stat.type.ItemStat; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + public class StatCategory { private final String id, name, loreTag; + /** + * When set to true, this stat category will have its own edition UI. + * This is useful for categories containing many stats, which quickly + * becomes ugly when browsing through the item editor UI. + */ + private final boolean specificUi; + + /** + * Just like stats + */ + private final List> statCache = new ArrayList<>(); + + public StatCategory(String id, String name, String loreTag) { + this(id, name, loreTag, false); + } + /** * @param id Internal identifier of stat category. Must be unique * @param name Name used to identify the category in the item browser * @param loreTag Lore tag added to stats with the given category */ - public StatCategory(String id, String name, String loreTag) { + public StatCategory(String id, String name, String loreTag, boolean specificUi) { this.id = id; this.name = name; this.loreTag = loreTag; + this.specificUi = specificUi; } @NotNull @@ -31,11 +53,25 @@ public class StatCategory { return loreTag; } - public static final StatCategory - TEMPLATE_OPTION = new StatCategory("TEMPLATE_OPTION", "Template Option, Misc", "Template Option"), - SOULBOUND = new StatCategory("SOULBOUND", "Soulbound", "Soulbound"), - ELEMENTAL = new StatCategory("ELEMENTAL", "Elements", "Elements"), - VANILLA_ATTRIBUTE = new StatCategory("VANILLA_ATTRIBUTE", "Vanilla Attributes", "Vanilla Attribute"), - REQUIREMENT = new StatCategory("REQUIREMENT", "Item Requirements", "Item Requirement"), - USE_COST = new StatCategory("USE_COST", "Item Costs", "Use Cost"); + public boolean hasSpecificUi() { + return specificUi; + } + + @NotNull + public List> getStatCache() { + return statCache; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StatCategory category = (StatCategory) o; + return Objects.equals(id, category.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java new file mode 100644 index 00000000..e7a7c8e1 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java @@ -0,0 +1,14 @@ +package net.Indyuce.mmoitems.stat.component; + + +public class DoubleComponent extends StatComponent implements Mergeable { + private double value; + + public DoubleComponent() { + } + + @Override + public void merge(DoubleComponent component) { + value += component.value; + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java new file mode 100644 index 00000000..2a9b8fca --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java @@ -0,0 +1,14 @@ +package net.Indyuce.mmoitems.stat.component; + + +public class IntegerComponent extends StatComponent implements Mergeable { + private int value; + + public IntegerComponent() { + } + + @Override + public void merge(IntegerComponent component) { + value += component.value; + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java index 50adbd7c..dd002ad1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java @@ -1,9 +1,7 @@ package net.Indyuce.mmoitems.stat.component; -/** - * @deprecated Not used yet - */ -@Deprecated +import io.lumine.mythic.lib.util.annotation.NotUsed; + public interface Mergeable { public void merge(T t); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java new file mode 100644 index 00000000..24a1b8af --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java @@ -0,0 +1,49 @@ +package net.Indyuce.mmoitems.stat.component; + +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +public class ObjectComponent extends StatComponent { + private final Map components = new HashMap<>(); + + public ObjectComponent() { + + } + + @Nullable + public StatComponent getComponent(String path) { + return components.get(path); + } + + public void forEachComponent(Consumer action) { + for (StatComponent component : components.values()) + action.accept(component); + } + + public Set getComponentKeys() { + return components.keySet(); + } + + /* + @Nullable + public StatComponent findComponent(String path) { + String[] split = path.split("\\."); + + ObjectComponent current = this; + int n = split.length - 1; + for (int i = 0; i < n; i++) { + StatComponent next = getComponent(split[i]); + if (next == null || !(next instanceof ObjectComponent)) + return null; + + current = (ObjectComponent) next; + } + + return current.getComponent(split[n]); + } + */ +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java index b4dfcf12..10866488 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java @@ -1,17 +1,5 @@ package net.Indyuce.mmoitems.stat.component; -/** - * @deprecated Not used yet - */ -@Deprecated public abstract class StatComponent { - private final String path; - public StatComponent(String path) { - this.path = path; - } - - public String getPath() { - return path; - } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java index b5abfaa9..e7b4a97f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Upgradable.java @@ -1,8 +1,8 @@ package net.Indyuce.mmoitems.stat.component; -/** - * @deprecated Not used yet - */ +import io.lumine.mythic.lib.util.annotation.NotUsed; + @Deprecated +@NotUsed public interface Upgradable { } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java deleted file mode 100644 index d8124d40..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/AbstractObjectComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.Indyuce.mmoitems.stat.component.type; - -import net.Indyuce.mmoitems.stat.component.StatComponent; -import org.jetbrains.annotations.Nullable; - -/** - * @deprecated Not used yet - */ -@Deprecated -public abstract class AbstractObjectComponent extends StatComponent { - public AbstractObjectComponent(String path) { - super(path); - } - - @Nullable - public StatComponent findComponent(String path) { - String[] split = path.split("\\."); - - AbstractObjectComponent current = this; - int n = split.length - 1; - for (int i = 0; i < n; i++) { - StatComponent next = getComponent(split[i]); - if (next == null || !(next instanceof AbstractObjectComponent)) - return null; - - current = (AbstractObjectComponent) next; - } - - return current.getComponent(split[n]); - } - - @Nullable - public abstract StatComponent getComponent(String path); - - -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java new file mode 100644 index 00000000..0ba2e362 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java @@ -0,0 +1,4 @@ +package net.Indyuce.mmoitems.stat.component.type; + +public class ComponentType { +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java deleted file mode 100644 index dc5f021d..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponent.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.Indyuce.mmoitems.stat.component.type; - -import net.Indyuce.mmoitems.stat.component.Mergeable; -import net.Indyuce.mmoitems.stat.component.StatComponent; -/** - * @deprecated Not used yet - */ -@Deprecated -public class DoubleComponent extends StatComponent implements Mergeable { - private double value; - - public DoubleComponent(String path) { - super(path); - } - - @Override - public void merge(DoubleComponent component) { - value += component.value; - } -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java new file mode 100644 index 00000000..b454631e --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java @@ -0,0 +1,11 @@ +package net.Indyuce.mmoitems.stat.component.type; + +public class DoubleComponentType extends ComponentType { + + /** + * Are higher values of this component better or worse? Debuff stats + * should set this to false, otherwise should be true by default for + * most stats. + */ + boolean moreIsBetter = true; +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java new file mode 100644 index 00000000..6814e3d5 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java @@ -0,0 +1,16 @@ +package net.Indyuce.mmoitems.stat.component.type; + +public class IntegerComponentType { + + /** + * Are higher values of this component better or worse? Debuff stats + * should set this to false, otherwise should be true by default for + * most stats. + */ + boolean moreIsBetter = true; + + /** + * Should components be displayed using roman integer format. + */ + boolean useRoman; +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java deleted file mode 100644 index 27260f79..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.Indyuce.mmoitems.stat.component.type; - -import net.Indyuce.mmoitems.stat.component.StatComponent; -import net.Indyuce.mmoitems.stat.component.Upgradable; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -/** - * @deprecated Not used yet - */ -@Deprecated -public class ObjectComponent extends AbstractObjectComponent implements Upgradable { - private final Map components = new HashMap<>(); - - public ObjectComponent(String path) { - super(path); - } - - @Override - @Nullable - public StatComponent getComponent(String path) { - return components.get(path); - } - - public void forEachComponent(Consumer action) { - for (StatComponent component : components.values()) - action.accept(component); - } - - public Set getComponentKeys() { - return components.keySet(); - } -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java new file mode 100644 index 00000000..1b0ee032 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java @@ -0,0 +1,16 @@ +package net.Indyuce.mmoitems.stat.component.type; + +public class ObjectComponentType { + + /** + * Are higher values of this component better or worse? Debuff stats + * should set this to false, otherwise should be true by default for + * most stats. + */ + boolean moreIsBetter = true; + + /** + * Should components be displayed using roman integer format. + */ + boolean useRoman; +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapter.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapter.java new file mode 100644 index 00000000..ea20e0e2 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapter.java @@ -0,0 +1,26 @@ +package net.Indyuce.mmoitems.stat.legacy; + +import net.Indyuce.mmoitems.stat.data.random.RandomStatData; +import net.Indyuce.mmoitems.stat.type.ItemStat; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; +import java.util.function.BiConsumer; + +public class LegacyConfigAdapter { + private final String key; + private final BiConsumer, Object> adapter; + + public LegacyConfigAdapter(String key, BiConsumer, Object> adapter) { + this.key = key; + this.adapter = adapter; + } + + public String getKey() { + return key; + } + + public void adapt(@NotNull Map template, @NotNull Object obj) { + adapter.accept(template, obj); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapters.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapters.java new file mode 100644 index 00000000..7f28d4ac --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/legacy/LegacyConfigAdapters.java @@ -0,0 +1,29 @@ +package net.Indyuce.mmoitems.stat.legacy; + +import io.lumine.mythic.lib.element.Element; +import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.type.ItemStat; +import net.Indyuce.mmoitems.util.ElementStatType; +import org.apache.commons.lang.Validate; +import org.bukkit.configuration.ConfigurationSection; + +public class LegacyConfigAdapters { + + public static final LegacyConfigAdapter ELEMENTS = new LegacyConfigAdapter("element", (baseData, obj) -> { + Validate.isTrue(obj instanceof ConfigurationSection, "Not a configuration section"); + + ConfigurationSection config = (ConfigurationSection) obj; + for (Element element : Element.values()) + for (ElementStatType statType : ElementStatType.values()) { + final String path = statType.getConcatenatedConfigPath(element); + if (config.contains(path)) { + NumericStatFormula formula = new NumericStatFormula(config.get(path)); + String statId = statType.getConcatenatedTagPath(element); + ItemStat stat = MMOItems.plugin.getStats().get(statId); + Validate.notNull(stat, "Could not find elemental stat with ID '" + statId + "'"); + baseData.put(stat, formula); + } + } + }); +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DisableStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DisableStat.java index 97221638..b2f35cbe 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DisableStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DisableStat.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat.type; +import net.Indyuce.mmoitems.StatCategories; import org.bukkit.Material; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; @@ -9,15 +10,21 @@ import io.lumine.mythic.lib.api.item.ItemTag; import org.jetbrains.annotations.NotNull; public class DisableStat extends BooleanStat { - public DisableStat(String id, Material material, String name, String... lore) { - super("DISABLE_" + id, material, name, lore, new String[0]); - } + public DisableStat(String id, Material material, String name, String... lore) { + super("DISABLE_" + id, material, name, lore, null); - public DisableStat(String id, Material material, String name, Material[] materials, String... lore) { - super("DISABLE_" + id, material, name, lore, new String[0], materials); - } + setCategory(StatCategories.TOGGLES); + } - public DisableStat(String id, Material material, String name, String[] types, String... lore) { - super("DISABLE_" + id, material, name, lore, types); - } + public DisableStat(String id, Material material, String name, Material[] materials, String... lore) { + super("DISABLE_" + id, material, name, lore, null, materials); + + setCategory(StatCategories.TOGGLES); + } + + public DisableStat(String id, Material material, String name, String[] types, String... lore) { + super("DISABLE_" + id, material, name, lore, types); + + setCategory(StatCategories.TOGGLES); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java index c1ef10be..9301d71b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java @@ -75,7 +75,8 @@ public class DoubleStat extends ItemStat impleme /** * Usually, a greater magnitude of stat benefits the player (more health, more attack damage). - *

However, its not impossible for a stat to be evil instead, who knows? + *

+ * However, it's not impossible for a stat to be evil instead, who knows? */ public boolean moreIsBetter() { return moreIsBetter; @@ -142,16 +143,6 @@ public class DoubleStat extends ItemStat impleme } } - @Deprecated - public static String formatPath(@NotNull String format, boolean moreIsBetter, double value) { - return formatPath("ATTACK_DAMAGE", format, moreIsBetter, value); - } - - @Deprecated - public static String formatPath(@NotNull String format, boolean moreIsBetter, double min, double max) { - return formatPath("ATTACK_DAMAGE", format, moreIsBetter, min, max); - } - @NotNull public static String formatPath(@NotNull String stat, @NotNull String format, boolean moreIsBetter, double value) { return formatPath(stat, format, moreIsBetter, true, value); @@ -159,6 +150,7 @@ public class DoubleStat extends ItemStat impleme @NotNull public static String formatPath(@NotNull String stat, @NotNull String format, boolean moreIsBetter, boolean displayPlus, double value) { + Validate.notNull(format, "Double format is null for " + stat); final String valueFormatted = StatManager.format(stat, value); final String colorPrefix = getColorPrefix(value < 0 && moreIsBetter); return format @@ -460,4 +452,14 @@ public class DoubleStat extends ItemStat impleme return pmp; } } + + @Deprecated + public static String formatPath(@NotNull String format, boolean moreIsBetter, double value) { + return formatPath("ATTACK_DAMAGE", format, moreIsBetter, value); + } + + @Deprecated + public static String formatPath(@NotNull String format, boolean moreIsBetter, double min, double max) { + return formatPath("ATTACK_DAMAGE", format, moreIsBetter, min, max); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java index 9a171d03..7f0cfd99 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java @@ -27,7 +27,7 @@ import java.util.Optional; * * @deprecated Definitely not a perfect implementation */ -@HasCategory(cat = "elemental") +@HasCategory(cat = "elements") @Deprecated public class FakeElementalStat extends DoubleStat implements InternalStat { public FakeElementalStat(Element el, ElementStatType type) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java index 2c431d8e..7c7b6361 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java @@ -1,9 +1,12 @@ package net.Indyuce.mmoitems.stat.type; +import net.Indyuce.mmoitems.stat.data.random.RandomStatData; +import net.Indyuce.mmoitems.stat.data.type.StatData; + /** * Internal stats can be used to store specific item data and cannot be * edited in the item edition GUI since they only exist once the item is * physically generated. */ -public interface InternalStat { +public interface InternalStat, S extends StatData> { } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java index ac584cdd..e7fcee9e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java @@ -8,10 +8,11 @@ import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import net.Indyuce.mmoitems.stat.category.StatCategory; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.annotation.VersionDependant; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryClickEvent; @@ -55,13 +56,13 @@ public abstract class ItemStat, S extends StatData> * @param types Compatible types. See {@link #isCompatible(Type)} * @param materials Materials compatible with the item stat (e.g Shield Pattern), any if empty */ - public ItemStat(@NotNull String id, @NotNull Material material, @NotNull String name, @Nullable String[] lore, @Nullable String[] types, Material... materials) { + public ItemStat(@NotNull String id, @NotNull Material material, @NotNull String name, @Nullable String[] lore, @Nullable String[] types, @Nullable Material... materials) { this.id = id; this.material = material; this.lore = lore == null ? new String[0] : lore; this.compatibleTypes = types == null ? new ArrayList<>() : Arrays.asList(types); this.name = name; - this.compatibleMaterials = Arrays.asList(materials); + this.compatibleMaterials = materials == null ? new ArrayList<>() : Arrays.asList(materials); this.configPath = id.toLowerCase().replace("_", "-"); this.nbtPath = "MMOITEMS_" + id; @@ -168,15 +169,17 @@ public abstract class ItemStat, S extends StatData> */ public abstract void whenDisplayed(List lore, Optional statData); + /** + * Not used in every stat TODO remove it from useless classes + */ protected String generalStatFormat; - @BackwardsCompatibility(version = "6.10") - public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) { - loadConfiguration(configObject); - } - - public void loadConfiguration(@NotNull Object configObject) { - generalStatFormat = configObject.toString(); + public void readTranslationFile(@NotNull ConfigurationSection translationFile) { + Bukkit.broadcastMessage("reading translation for " + getPath()); + String path = getPath(); + Object obj = translationFile.get(path); + if (obj == null) obj = translationFile.get(getLegacyTranslationPath()); + generalStatFormat = obj == null ? "" : String.valueOf(obj); } @BackwardsCompatibility(version = "6.10") @@ -193,8 +196,10 @@ public abstract class ItemStat, S extends StatData> return category; } - public void setCategory(@Nullable StatCategory category) { + @NotNull + public ItemStat setCategory(@Nullable StatCategory category) { this.category = category; + return this; } @NotNull @@ -323,7 +328,6 @@ public abstract class ItemStat, S extends StatData> } - @Override public int hashCode() { return Objects.hash(id); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/TemplateOption.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/TemplateOption.java index c839992e..f9b46ecf 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/TemplateOption.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/TemplateOption.java @@ -1,54 +1,13 @@ package net.Indyuce.mmoitems.stat.type; -import io.lumine.mythic.lib.api.item.ItemTag; -import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; -import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; -import net.Indyuce.mmoitems.stat.data.StringData; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; - /** - * Stats are marked externals when refering to item templates options: - * - {@link net.Indyuce.mmoitems.stat.BrowserDisplayIDX} + * Some stats are just options related to the template and not the item + * directly. Such stats are called item options since they do not provide + * anything to the holder, and do not store any data inside the item NBT. *

- * These stats do not save any information in the item NBT - * TODO Add a small API for template options distinct from item stat options. - * TODO Have it backwards compatible. - * - * @deprecated Not being used yet + * They can be edited just like a regular stat, but don't need to be loaded + * from the item when checking its NBT. */ -@Deprecated public interface TemplateOption { - /** - * This stat is not saved onto items. This method is empty. - */ - public default void whenLoaded(@NotNull ReadMMOItem mmoitem) { - // Cannot throw an exception since it will be called - } - - /** - * This stat is not saved onto items. This method always returns null - */ - @Nullable - public default StringData getLoadedNBT(@NotNull ArrayList storedTags) { - throw new RuntimeException("Not supported"); - } - - /** - * This stat is not saved onto items. This method is empty. - */ - public default void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) { - throw new RuntimeException("Not supported"); - } - - /** - * This stat is not saved onto items. This method returns an empty array. - */ - @NotNull - public default ArrayList getAppliedNBT(@NotNull StringData data) { - throw new RuntimeException("Not supported"); - } } diff --git a/MMOItems-Dist/src/main/resources/default/item-types.yml b/MMOItems-Dist/src/main/resources/default/item-types.yml index 634e3fbd..73a43abb 100644 --- a/MMOItems-Dist/src/main/resources/default/item-types.yml +++ b/MMOItems-Dist/src/main/resources/default/item-types.yml @@ -55,6 +55,7 @@ DAGGER: SPEAR: display: TRIDENT name: 'Spear' + parent: DAGGER unident-item: name: '&f#prefix#Unidentified Spear' lore: diff --git a/MMOItems-Dist/src/main/resources/default/language/stats.yml b/MMOItems-Dist/src/main/resources/default/language/stats.yml index e372b420..9c3ebaaa 100644 --- a/MMOItems-Dist/src/main/resources/default/language/stats.yml +++ b/MMOItems-Dist/src/main/resources/default/language/stats.yml @@ -30,7 +30,7 @@ physical-damage: '&3 &7â–  Physical Damage: &f{value}%' projectile-damage: '&3 &7â–  Projectile Damage: &f{value}%' faction-damage-undead: '&3 &7â–  Undead Faction Damage: &f{value}%' -# Abilities (changed in MI 6.9.5) +# Abilities (changed in MI 6.10) ability: general-format: "&8| &7{trigger} &8|&e|&8| &7&l{ability}" modifier-if-any: "\n" # Appended to general-format if the skill has at least one modifier From 09a592d5b08d9163b78065a52bd79e5332aae101 Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 26 Oct 2024 03:19:43 +0200 Subject: [PATCH 3/3] Basic component API stuff --- .../java/net/Indyuce/mmoitems/ItemStats.java | 6 +- .../event/item/ConsumableConsumedEvent.java | 2 +- .../mmoitems/api/interaction/Consumable.java | 4 +- .../mmoitems/api/interaction/GemStone.java | 2 +- .../mmoitems/api/player/RPGPlayer.java | 2 +- .../mmoitems/api/util/NumericStatFormula.java | 41 ++-- .../comp/enchants/CrazyEnchantsStat.java | 2 +- .../AdvancedEnchantsStat.java | 2 +- .../comp/mmoinventory/stat/AccessorySet.java | 2 +- .../Indyuce/mmoitems/comp/rpg/HeroesHook.java | 2 +- .../mmoitems/gui/edition/ItemEdition.java | 192 +++++++++++---- .../gui/edition/newedit/ItemFactory.java | 59 +++++ .../mmoitems/gui/listener/GuiListener.java | 1 + .../Indyuce/mmoitems/manager/StatManager.java | 7 + .../net/Indyuce/mmoitems/stat/Abilities.java | 21 +- .../net/Indyuce/mmoitems/stat/Amphibian.java | 4 +- .../Indyuce/mmoitems/stat/AttackDamage.java | 8 + .../Indyuce/mmoitems/stat/CanDeconstruct.java | 2 +- .../net/Indyuce/mmoitems/stat/CanDeskin.java | 2 +- .../Indyuce/mmoitems/stat/CanIdentify.java | 2 +- .../Indyuce/mmoitems/stat/CanUnsocket.java | 2 +- .../mmoitems/stat/CraftingPermission.java | 3 +- .../mmoitems/stat/CustomDurability.java | 3 +- .../mmoitems/stat/CustomModelData.java | 3 +- .../Indyuce/mmoitems/stat/CustomSounds.java | 4 +- .../Indyuce/mmoitems/stat/DisplayName.java | 2 +- .../Indyuce/mmoitems/stat/DisplayedType.java | 2 +- .../net/Indyuce/mmoitems/stat/DyeColor.java | 206 ++++++++-------- .../net/Indyuce/mmoitems/stat/Effects.java | 2 +- .../net/Indyuce/mmoitems/stat/Elements.java | 26 +- .../net/Indyuce/mmoitems/stat/GemColor.java | 2 +- .../mmoitems/stat/GemUpgradeScaling.java | 2 +- .../mmoitems/stat/GrantedPermissions.java | 2 +- .../net/Indyuce/mmoitems/stat/ItemDamage.java | 2 +- .../net/Indyuce/mmoitems/stat/ItemLevel.java | 2 +- .../Indyuce/mmoitems/stat/ItemSetStat.java | 2 +- .../Indyuce/mmoitems/stat/ItemTierStat.java | 3 +- .../java/net/Indyuce/mmoitems/stat/Lore.java | 2 +- .../net/Indyuce/mmoitems/stat/LoreFormat.java | 2 +- .../mmoitems/stat/LuteAttackEffectStat.java | 2 +- .../mmoitems/stat/LuteAttackSoundStat.java | 2 +- .../net/Indyuce/mmoitems/stat/ManaCost.java | 4 +- .../Indyuce/mmoitems/stat/MaterialStat.java | 7 + .../Indyuce/mmoitems/stat/MaxItemDamage.java | 2 +- .../Indyuce/mmoitems/stat/MaxStackSize.java | 2 +- .../mmoitems/stat/MaximumDurability.java | 4 +- .../net/Indyuce/mmoitems/stat/Permission.java | 2 +- .../Indyuce/mmoitems/stat/PotionColor.java | 143 +++++------ .../Indyuce/mmoitems/stat/RandomUnsocket.java | 3 +- .../Indyuce/mmoitems/stat/RepairPower.java | 2 +- .../mmoitems/stat/RepairPowerPercent.java | 2 +- .../mmoitems/stat/RepairReference.java | 2 +- .../Indyuce/mmoitems/stat/RequiredBiomes.java | 6 +- .../Indyuce/mmoitems/stat/RequiredClass.java | 4 +- .../Indyuce/mmoitems/stat/RestoreFood.java | 2 +- .../Indyuce/mmoitems/stat/RestoreHealth.java | 2 +- .../Indyuce/mmoitems/stat/RestoreMana.java | 2 +- .../mmoitems/stat/RestoreSaturation.java | 2 +- .../Indyuce/mmoitems/stat/RestoreStamina.java | 2 +- .../net/Indyuce/mmoitems/stat/RevisionID.java | 2 +- .../mmoitems/stat/SoulbindingBreakChance.java | 2 +- .../mmoitems/stat/SoulbindingChance.java | 2 +- .../net/Indyuce/mmoitems/stat/Soulbound.java | 4 +- .../net/Indyuce/mmoitems/stat/StoredTags.java | 4 +- .../Indyuce/mmoitems/stat/SuccessRate.java | 2 +- .../Indyuce/mmoitems/stat/TooltipStat.java | 2 +- .../mmoitems/stat/TrimMaterialStat.java | 2 +- .../mmoitems/stat/TrimPatternStat.java | 2 +- .../Indyuce/mmoitems/stat/UpgradeStat.java | 2 +- .../TerminalComponentException.java | 8 + .../ConsumableItemInteraction.java | 2 +- .../{type => behaviour}/GemStoneStat.java | 5 +- .../{type => behaviour}/InternalStat.java | 2 +- .../stat/behaviour/ItemRestriction.java | 39 +++ .../{type => behaviour}/PlayerConsumable.java | 10 +- .../stat/component/DoubleComponent.java | 14 -- .../stat/component/IntegerComponent.java | 14 -- .../mmoitems/stat/component/LoreWrapper.java | 27 +++ .../mmoitems/stat/component/Mergeable.java | 6 +- .../stat/component/ObjectComponent.java | 49 ---- .../stat/component/StatComponent.java | 25 ++ .../component/builtin/AbilityComponent.java | 61 +++++ .../component/builtin/ArrayComponent.java | 28 +++ .../component/builtin/BooleanComponent.java | 37 +++ .../component/builtin/DoubleComponent.java | 28 +++ .../component/builtin/IntegerComponent.java | 33 +++ .../builtin/ItemAbilityComponent.java | 225 +++++++++++++++++ .../component/builtin/MaterialComponent.java | 68 ++++++ .../component/builtin/ObjectComponent.java | 38 +++ .../builtin/ObjectComponentImpl.java | 36 +++ .../component/builtin/StringComponent.java | 32 +++ .../mmoitems/stat/component/model/Model.java | 23 ++ .../component/model/builtin/ArrayModel.java | 24 ++ .../component/model/builtin/BooleanModel.java | 49 ++++ .../component/model/builtin/DoubleModel.java | 27 +++ .../component/model/builtin/IntegerModel.java | 25 ++ .../component/model/builtin/ObjectModel.java | 36 +++ .../stat/component/type/ComponentType.java | 195 ++++++++++++++- .../component/type/DoubleComponentType.java | 11 - .../component/type/IntegerComponentType.java | 16 -- .../component/type/ObjectComponentType.java | 16 -- .../type/builtin/ArrayComponentType.java | 94 ++++++++ .../type/builtin/BooleanComponentType.java | 59 +++++ .../type/builtin/DoubleComponentType.java | 79 ++++++ .../type/builtin/IntegerComponentType.java | 82 +++++++ .../type/builtin/ObjectComponentType.java | 112 +++++++++ .../type/builtin/StringComponentType.java | 38 +++ .../mmoitems/stat/data/AbilityData.java | 1 + .../mmoitems/stat/data/DoubleData.java | 1 + .../stat/data/dynamic/DynamicStatData.java | 16 +- .../stat/data/random/RandomAbilityData.java | 4 + .../data/random/RandomAbilityListData.java | 4 + .../data/random/RandomElementListData.java | 4 + .../data/random/RandomEnchantListData.java | 4 + .../data/random/RandomPotionEffectData.java | 4 + .../random/RandomPotionEffectListData.java | 4 + .../data/random/RandomRequiredLevelData.java | 3 + .../stat/data/random/RandomRestoreData.java | 43 ++-- .../stat/data/random/RandomStatData.java | 3 +- .../mmoitems/stat/type/BooleanStat.java | 227 +++++++++--------- .../mmoitems/stat/type/DoubleStat.java | 34 ++- .../mmoitems/stat/type/FakeElementalStat.java | 1 + .../mmoitems/stat/type/ItemRestriction.java | 38 --- .../Indyuce/mmoitems/stat/type/ItemStat.java | 43 +++- .../mmoitems/stat/type/RequiredLevelStat.java | 2 + .../mmoitems/stat/type/StringStat.java | 16 +- .../net/Indyuce/mmoitems/util/MMOUtils.java | 33 ++- .../java/net/Indyuce/mmoitems/util/Pair.java | 8 +- .../mmoitems/util/VersionDependant.java | 15 -- .../listener/reforging/RFGKeepGems.java | 2 +- pom.xml | 2 + 131 files changed, 2372 insertions(+), 669 deletions(-) create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/newedit/ItemFactory.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/TerminalComponentException.java rename MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/{type => behaviour}/ConsumableItemInteraction.java (96%) rename MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/{type => behaviour}/GemStoneStat.java (73%) rename MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/{type => behaviour}/InternalStat.java (89%) create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ItemRestriction.java rename MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/{type => behaviour}/PlayerConsumable.java (68%) delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/LoreWrapper.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/AbilityComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ArrayComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/BooleanComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/DoubleComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/IntegerComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ItemAbilityComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/MaterialComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponentImpl.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/StringComponent.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/Model.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ArrayModel.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/BooleanModel.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/DoubleModel.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/IntegerModel.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ObjectModel.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ArrayComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/BooleanComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/DoubleComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/IntegerComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ObjectComponentType.java create mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/StringComponentType.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemRestriction.java delete mode 100644 MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/VersionDependant.java diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java index 8344a93c..bada2889 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/ItemStats.java @@ -181,8 +181,8 @@ public class ItemStats { BOUNCING_CRACK = new BooleanStat("BOUNCING_CRACK", Material.COBBLESTONE_WALL, "Bouncing Crack", new String[]{"If set to true, your tool will", "also break nearby blocks."}, new String[]{"tool"}).setCategory(StatCategories.TOOLS), PICKAXE_POWER = new PickaxePower(), CUSTOM_SOUNDS = new CustomSounds(), - ELEMENTS = new Elements(), - COMMANDS = new Commands(), + ELEMENTS = new Elements(), + COMMANDS = new Commands(), // STAFF_SPIRIT = new StaffSpiritStat(), LUTE_ATTACK_SOUND = new LuteAttackSoundStat(), LUTE_ATTACK_EFFECT = new LuteAttackEffectStat(), @@ -209,7 +209,7 @@ public class ItemStats { UPGRADE = new UpgradeStat(), DOWNGRADE_ON_BREAK = new BooleanStat("BREAK_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade when Broken", new String[]{"If this item's durability reaches 0,", "it will be fully repaired but also", "downgraded by one level.", "", "&cIt will only break if it cannot be", "&cdowngraded further", "", "Requires to define an &6Upgrade Template", "Required to define &6Custom Durability"}, new String[]{"equipment"}).setCategory(StatCategories.UPGRADING), DOWNGRADE_ON_DEATH = new BooleanStat("DEATH_DOWNGRADE", Material.DAMAGED_ANVIL, "Downgrade on Death", new String[]{"If the wearer of this item dies, it may", "downgrade (based on &6Death Downgrade", "&6Chance &7stat)", "", "Required to define an &6Upgrade Template", "Requires keep-inventory gamerule. "}, new String[]{"equipment"}).setCategory(StatCategories.UPGRADING), - DOWNGRADE_ON_DEATH_CHANCE = new DoubleStat("DEATH_DOWNGRADE_CHANCE", Material.SKELETON_SKULL, "Death Downgrade Chance", new String[]{"Probability that an item with &cDowngrade ", "&con Death&7 will be downgraded when the", "player dies. ", "", "Exceeding 100% will for sure downgrade", "one item, and roll again to downgrade", "another (with the excess probability).", "&6The same item wont be downgraded twice."}, new String[]{"equipment"}, false).setCategory(StatCategories.UPGRADING), + DOWNGRADE_ON_DEATH_CHANCE = new DoubleStat("DEATH_DOWNGRADE_CHANCE", Material.SKELETON_SKULL, "Death Downgrade Chance", "Probability that an item with &cDowngrade on Death &7will be downgraded when the player dies.\n\n Exceeding 100% will for sure downgrade one item, and roll again to downgrade another (with the excess probability). The same item won't be downgraded twice.", new String[]{"equipment"}, false).setCategory(StatCategories.UPGRADING), // Unique Item Stats DYE_COLOR = new DyeColor(), diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/ConsumableConsumedEvent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/ConsumableConsumedEvent.java index e7f0c5f1..5555bb6b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/ConsumableConsumedEvent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/ConsumableConsumedEvent.java @@ -4,7 +4,7 @@ import net.Indyuce.mmoitems.api.event.PlayerDataEvent; import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.player.PlayerData; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java index 7fc3945f..229cd3ef 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java @@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.api.event.item.ConsumableConsumedEvent; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.item.util.LoreUpdate; import net.Indyuce.mmoitems.api.player.PlayerData; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java index 09606dbb..17fee81a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java @@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.stat.data.GemSocketsData; import net.Indyuce.mmoitems.stat.data.GemstoneData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.StatHistory; import net.Indyuce.mmoitems.util.MMOUtils; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/player/RPGPlayer.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/player/RPGPlayer.java index b246ecd1..aee82bb6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/player/RPGPlayer.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/player/RPGPlayer.java @@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.api.player; import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.util.message.Message; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.ChatColor; import org.bukkit.Sound; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java index 51167e6c..d2711d6e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/util/NumericStatFormula.java @@ -1,6 +1,9 @@ package net.Indyuce.mmoitems.api.util; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.builtin.DoubleComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.random.UpdatableRandomStatData; @@ -167,7 +170,7 @@ public class NumericStatFormula implements RandomStatData, Updatable /** * @return When the item has a certain level or tier, this is how much each level shifts - * the peak, so that it is centered at {@code base + scale*level} + * the peak, so that it is centered at {@code base + scale*level} * @see #getBase() */ public double getScale() { @@ -183,15 +186,15 @@ public class NumericStatFormula implements RandomStatData, Updatable /** * @return For gaussian distributions, there always is that INSANELY SMALL - * chance of getting an INSANELY LARGE number. - *

- * For example: At base atk dmg 10, and standard deviation 1: - *

68% of rolls will fall between 9 and 11; - *

95% of rolls will fall between 8 and 12; - *

99.7% of rolls will fall between 7 and 13; - *

10E-42 of a roll that will give you an epic 300 dmg sword - *

- * Whatever, this constrains to a minimum and maximum of output. + * chance of getting an INSANELY LARGE number. + *

+ * For example: At base atk dmg 10, and standard deviation 1: + *

68% of rolls will fall between 9 and 11; + *

95% of rolls will fall between 8 and 12; + *

99.7% of rolls will fall between 7 and 13; + *

10E-42 of a roll that will give you an epic 300 dmg sword + *

+ * Whatever, this constrains to a minimum and maximum of output. */ public double getMaxSpread() { return maxSpread; @@ -226,15 +229,15 @@ public class NumericStatFormula implements RandomStatData, Updatable * the formula is base + (scale*level). * This is the level * @return Legacy formula: ???
- * Let A = {base} + {scale} * lvl, then the returned value is a - * random value taken in respect to a gaussian distribution - * centered on A, with average spread of {spread}%, and with a - * maximum offset of {maxSpread}% (relative to average value) - *

- * Formula: Spread = Standard Deviation - * The mean, the peak is located at {base} + {scale}*lvl.
- * The 'spread' is the standard deviation of the distribution.
- * 'Max Spread' constrains the result of this operation at {mean}±{max spread} + * Let A = {base} + {scale} * lvl, then the returned value is a + * random value taken in respect to a gaussian distribution + * centered on A, with average spread of {spread}%, and with a + * maximum offset of {maxSpread}% (relative to average value) + *

+ * Formula: Spread = Standard Deviation + * The mean, the peak is located at {base} + {scale}*lvl.
+ * The 'spread' is the standard deviation of the distribution.
+ * 'Max Spread' constrains the result of this operation at {mean}±{max spread} */ public double calculate(double scaleFactor) { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsStat.java index 254f01a3..ebbde29d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/CrazyEnchantsStat.java @@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; -import net.Indyuce.mmoitems.stat.type.InternalStat; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.NotImplementedException; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantsStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantsStat.java index df4a1c61..a5d3ce30 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantsStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/enchants/advanced_enchants/AdvancedEnchantsStat.java @@ -6,7 +6,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; -import net.Indyuce.mmoitems.stat.type.InternalStat; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.advancedplugins.ae.api.AEAPI; import org.apache.commons.lang.Validate; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java index b9b6c72b..9fa9e188 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/mmoinventory/stat/AccessorySet.java @@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java index b0973810..be777079 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/rpg/HeroesHook.java @@ -22,7 +22,7 @@ import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.category.StatCategory; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.RequiredLevelStat; import org.apache.commons.lang.Validate; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/ItemEdition.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/ItemEdition.java index be5eb1ca..65c3cd60 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/ItemEdition.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/ItemEdition.java @@ -1,10 +1,23 @@ package net.Indyuce.mmoitems.gui.edition; import io.lumine.mythic.lib.MythicLib; +import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.util.Lazy; import io.lumine.mythic.lib.version.VersionUtils; +import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; -import net.Indyuce.mmoitems.stat.type.InternalStat; +import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.gui.edition.newedit.ItemFactory; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; +import net.Indyuce.mmoitems.stat.category.StatCategory; +import net.Indyuce.mmoitems.stat.component.LoreWrapper; +import net.Indyuce.mmoitems.stat.component.builtin.MaterialComponent; +import net.Indyuce.mmoitems.stat.component.builtin.StringComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import net.Indyuce.mmoitems.stat.component.model.builtin.ArrayModel; +import net.Indyuce.mmoitems.stat.component.model.builtin.DoubleModel; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.ChatColor; @@ -16,18 +29,26 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; +import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; public class ItemEdition extends EditionInventory { - private static final int[] slots = {19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43}; - private static final NamespacedKey STAT_ID_KEY = new NamespacedKey(MMOItems.plugin, "StatId"); + private static final int[] SLOTS = {19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52}; + private static final NamespacedKey COMPONENT_KEY = new NamespacedKey(MMOItems.plugin, "component_key"); + + private Stack explored = new Stack<>(); + Map, Model> sampleItem = new HashMap<>(); public ItemEdition(Player player, MMOItemTemplate template) { - super(player, template); + super(player, template, false); + + // TODO replace by getting info from the item + sampleItem.put(ItemStats.ATTACK_DAMAGE, new DoubleModel(new NumericStatFormula(10))); + sampleItem.put(ItemStats.MATERIAL, new MaterialComponent(Material.IRON_SWORD)); + sampleItem.put(ItemStats.NAME, new StringComponent("Super Duper Item")); + sampleItem.put(ItemStats.LORE, new ArrayModel<>()); } @Override @@ -35,71 +56,120 @@ public class ItemEdition extends EditionInventory { return "Item Edition: " + getEdited().getId(); } + private static class Entry { + final String key; + final StatCategory category; + final ComponentType ctype; + final Model model; + + private Entry(String key, StatCategory category, ComponentType ctype, Model model) { + this.key = key; + this.category = category; + this.ctype = ctype; + this.model = model; + } + } + @Override + @SuppressWarnings({"unchecked"}) public void arrangeInventory() { - int min = (page - 1) * slots.length; - int max = page * slots.length; - int n = 0; - /* - * it has to determine what stats can be applied first because otherwise - * the for loop will just let some slots empty - */ - List appliable = new ArrayList<>(getEdited().getType().getAvailableStats()).stream() - .filter(stat -> stat.hasValidMaterial(getCachedItem()) && !(stat instanceof InternalStat)).collect(Collectors.toList()); + Entry topmost = explored.isEmpty() ? null : explored.peek(); - for (int j = min; j < Math.min(appliable.size(), max); j++) { - ItemStat stat = appliable.get(j); - ItemStack item = new ItemStack(stat.getDisplayMaterial()); + // TODO define visiting object/array. and let some of these visit() impls throw RuntimeExcption + List entries = topmost != null ? + + // Explore current component + ((ComponentType) topmost.ctype).getSubcomponents().stream() + .map(pair -> new Entry(pair.getKey(), null, pair.getValue(), topmost.model == null ? null : topmost.model.getModel(pair.getKey()))) + .collect(Collectors.toList()) : + + // Explore stats + new ArrayList<>(getEdited().getType().getAvailableStats()).stream() + .filter(stat -> stat.getComponentType() != null) + .filter(stat -> stat.hasValidMaterial(getCachedItem()) && !(stat instanceof InternalStat)) + // TODO sample item + .map(stat -> new Entry(stat.getId().toLowerCase(), stat.getCategory(), stat.getComponentType(), sampleItem.get(stat))) + .collect(Collectors.toList()); + + // Bounds and counter + int min = (page - 1) * SLOTS.length; + int max = Math.min(page * SLOTS.length, entries.size()); + int slotc = 0; + + for (int j = min; j < max; j++) { + Entry entry = entries.get(j); + + ItemStack item = entry.ctype.provideIcon(entry.model); ItemMeta meta = item.getItemMeta(); meta.addItemFlags(ItemFlag.values()); VersionUtils.addEmptyAttributeModifier(meta); - meta.setDisplayName(ChatColor.GREEN + stat.getName()); - List lore = MythicLib.plugin.parseColors(Arrays.stream(stat.getLore()).map(s -> ChatColor.GRAY + s).collect(Collectors.toList())); - lore.add(""); - if (stat.getCategory() != null) { + meta.setDisplayName(ChatColor.GREEN + entry.ctype.provideName(entry.model)); + List lore = new ArrayList<>(); + + // Display stat category + if (entry.category != null) { lore.add(0, ""); - lore.add(0, ChatColor.BLUE + stat.getCategory().getLoreTag()); + lore.add(0, ChatColor.BLUE + entry.category.getLoreTag()); } - stat.whenDisplayed(lore, getEventualStatData(stat)); + // Display component type lore + List statDesc = (List) entry.ctype.provideDescription(entry.model); + if (statDesc != null) { + lore.addAll(MythicLib.plugin.parseColors(statDesc.stream().map(s -> ChatColor.GRAY + s).collect(Collectors.toList()))); + lore.add(""); + } + + // Display current value of main stat component + try { + entry.ctype.editionUiDisplay(new LoreWrapper(lore), entry.model); + lore.add(""); + } catch (Exception ignored) { + // Pass + } + + // Lore action tags + for (String loreActionTag : (List) entry.ctype.getActionLoreTags()) + lore.add(ChatColor.YELLOW + AltChar.listDash + " " + loreActionTag); + + // Set NBT tag for exploration and edition + meta.getPersistentDataContainer().set(COMPONENT_KEY, PersistentDataType.STRING, entry.key); - meta.getPersistentDataContainer().set(STAT_ID_KEY, PersistentDataType.STRING, stat.getId()); meta.setLore(lore); item.setItemMeta(meta); - inventory.setItem(slots[n++], item); + inventory.setItem(SLOTS[slotc++], item); } - ItemStack glass = new ItemStack(Material.GRAY_STAINED_GLASS_PANE); - ItemMeta glassMeta = glass.getItemMeta(); - glassMeta.setDisplayName(ChatColor.RED + "- No Item Stat -"); - glass.setItemMeta(glassMeta); - - ItemStack next = new ItemStack(Material.ARROW); - ItemMeta nextMeta = next.getItemMeta(); - nextMeta.setDisplayName(ChatColor.GREEN + "Next Page"); - next.setItemMeta(nextMeta); - - ItemStack previous = new ItemStack(Material.ARROW); - ItemMeta previousMeta = previous.getItemMeta(); - previousMeta.setDisplayName(ChatColor.GREEN + "Previous Page"); - previous.setItemMeta(previousMeta); - - while (n < slots.length) - inventory.setItem(slots[n++], glass); - inventory.setItem(27, page > 1 ? previous : null); - inventory.setItem(35, appliable.size() > max ? next : null); + while (slotc < SLOTS.length) inventory.setItem(SLOTS[slotc++], NO_COMPONENT.get()); + inventory.setItem(6, topmost != null ? BACK.get() : null); + inventory.setItem(27, page > 1 ? PREVIOUS_PAGE.get() : null); + inventory.setItem(35, entries.size() > max ? NEXT_PAGE.get() : null); } + private static Lazy + PREVIOUS_PAGE = Lazy.of(() -> ItemFactory.of(Material.ARROW).name("&aPrevious Page").build()), + NEXT_PAGE = Lazy.of(() -> ItemFactory.of(Material.ARROW).name("&aNext Page").build()), + BACK = Lazy.of(() -> ItemFactory.of(Material.BARRIER).name("&aBack").build()), + NO_COMPONENT = Lazy.of(() -> ItemFactory.of(Material.GRAY_STAINED_GLASS_PANE).name("&c- No Item Stat").build()); + + /* + private String pathSoFar() { + StringBuilder s = new StringBuilder(); + for (TypedComponent comp : this.explored) { + if (!s.isEmpty()) s.append("."); + s.append(comp.path); + } + return s.toString(); + } + */ + @Override public void whenClicked(InventoryClickEvent event) { event.setCancelled(true); - if (event.getInventory() != event.getClickedInventory()) - return; + if (event.getInventory() != event.getClickedInventory()) return; ItemStack item = event.getCurrentItem(); - if (!MMOUtils.isMetaItem(item, false) || event.getInventory().getItem(4) == null) - return; + if (!MMOUtils.isMetaItem(item, false) || event.getInventory().getItem(4) == null) return; if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Next Page")) { page++; @@ -111,9 +181,25 @@ public class ItemEdition extends EditionInventory { refreshInventory(); } - final String tag = item.getItemMeta().getPersistentDataContainer().get(STAT_ID_KEY, PersistentDataType.STRING); - if (tag == null || tag.isEmpty()) return; + if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Back")) { + explored.pop(); + refreshInventory(); + } + // Check tag + final String tag = item.getItemMeta().getPersistentDataContainer().get(COMPONENT_KEY, PersistentDataType.STRING); + if (tag == null) return; + + // Explore stat + if (explored.isEmpty()) { + ItemStat stat = Objects.requireNonNull(MMOItems.plugin.getStats().get(tag.toUpperCase()), "No stat found with ID '" + tag + "'"); + @Nullable Model model = sampleItem.get(stat); + //Validate.notNull(component, "Component is null"); // TODO exception handling + explored.push(new Entry(stat.getId().toLowerCase(), null, stat.getComponentType(), model)); + refreshInventory(); + } + + /* // Check for OP stats final ItemStat edited = MMOItems.plugin.getStats().get(tag); if (MMOItems.plugin.hasPermissions() && MMOItems.plugin.getLanguage().opStatsEnabled @@ -123,7 +209,9 @@ public class ItemEdition extends EditionInventory { return; } + edited.whenClicked(this, event); + */ } @Deprecated diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/newedit/ItemFactory.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/newedit/ItemFactory.java new file mode 100644 index 00000000..5e084a71 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/edition/newedit/ItemFactory.java @@ -0,0 +1,59 @@ +package net.Indyuce.mmoitems.gui.edition.newedit; + +import io.lumine.mythic.lib.MythicLib; +import org.apache.commons.lang.Validate; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Arrays; +import java.util.List; + +public class ItemFactory { + private ItemStack item; + private ItemMeta meta; + + /** + * @see #of(Material) + */ + private ItemFactory() { + // Private constructor + } + + public ItemFactory material(Material material) { + this.item = new ItemStack(material); + this.meta = item.getItemMeta(); + return this; + } + + private void validateMaterial() { + Validate.notNull(meta, "No material or invalid material"); + } + + public ItemFactory name(String name) { + validateMaterial(); + meta.setDisplayName(MythicLib.plugin.parseColors(name)); + return this; + } + + public ItemFactory lore(String... lore) { + return lore(Arrays.asList(lore)); + } + + public ItemFactory lore(List lore) { + validateMaterial(); + meta.setLore(lore); + return this; + } + + + public ItemStack build() { + validateMaterial(); + item.setItemMeta(meta); + return item; + } + + public static ItemFactory of(Material mat) { + return new ItemFactory().material(mat); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/listener/GuiListener.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/listener/GuiListener.java index fefd5cd1..8c8ce0f7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/listener/GuiListener.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/listener/GuiListener.java @@ -19,6 +19,7 @@ import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; +// TODO implement navigators public class GuiListener implements Listener { @EventHandler diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java index a14ab5e6..e6c52471 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/StatManager.java @@ -9,7 +9,12 @@ import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.StatCategories; import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.Type; +import net.Indyuce.mmoitems.stat.Elements; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import net.Indyuce.mmoitems.stat.category.StatCategory; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.legacy.LegacyConfigAdapter; @@ -103,6 +108,8 @@ public class StatManager { // Register elemental stats registerElementStats(); + Elements.updateComponentType(); + // Load stat translation objects (nothing to do with stats) final ConfigurationSection statOptions = new ConfigFile("/language", "stats").getConfig(); for (ItemStat stat : getAll()) diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java index 33d69711..aaa3b11f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java @@ -17,6 +17,9 @@ import net.Indyuce.mmoitems.gui.edition.AbilityListEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.skill.RegisteredSkill; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.component.builtin.AbilityComponent; +import net.Indyuce.mmoitems.stat.component.type.builtin.ArrayComponentType; +import net.Indyuce.mmoitems.stat.component.type.builtin.ObjectComponentType; import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityListData; import net.Indyuce.mmoitems.stat.data.random.RandomAbilityData; @@ -37,10 +40,22 @@ import java.util.Optional; @HasCategory(cat = "abilities") public class Abilities extends ItemStat { public Abilities() { - super("ABILITY", Material.BLAZE_POWDER, "Item Abilities", - new String[]{"Make your item cast amazing abilities", "to kill monsters or buff yourself."}, new String[]{"!block", "all"}); - } + super("ABILITY", new String[]{"!block", "all"}); +/* + ObjectComponentType abilityType = ObjectComponentType.object() + .addField("ability", AbilityComponent.type().build()) + .addField("modifiers", ObjectComponentType.object().build()) + .setFlattened(true) + .build(); + setComponentType(ArrayComponentType.arrayOf(abilityType) + .setActionLoreTags("Left click to edit abilities.", "Right click to remove all abilities.") + .setIcon(Material.FIRE_CHARGE) + .setName("Abilities") + .setLoreTrimmed("Make your item cast amazing abilities to kill monsters or buff yourself. Abilities can be actively cast, set on a timer or triggered by specific world events. Custom abilities can be created using MythicLib, MythicMobs, Fabled...") + .build()); + */ + } @Override public RandomAbilityListData whenInitialized(Object object) { Validate.isTrue(object instanceof ConfigurationSection, "Must specify a valid config section"); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java index 62c585ba..ac6d4589 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Amphibian.java @@ -8,8 +8,8 @@ import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.util.StatChoice; import org.bukkit.Material; import org.bukkit.block.Block; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/AttackDamage.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/AttackDamage.java index a546d37b..331210ca 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/AttackDamage.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/AttackDamage.java @@ -1,6 +1,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.component.type.builtin.DoubleComponentType; import net.Indyuce.mmoitems.stat.type.AttackWeaponStat; import org.bukkit.Material; import org.bukkit.attribute.Attribute; @@ -13,5 +14,12 @@ public class AttackDamage extends AttackWeaponStat { "Attack Damage", new String[]{"The amount of damage your weapon deals."}, Attribute.GENERIC_ATTACK_DAMAGE); + + setComponentType(DoubleComponentType.numeric() + .moreIsBetter(true) + .setIcon(Material.IRON_SWORD) + .setName("Attack Damage") + .trimLore("The amount of damage dealt by melee or ranged weapon attacks.") + .build()); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java index 6f134084..f29e6555 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeconstruct.java @@ -20,7 +20,7 @@ import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.type.BooleanStat; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import io.lumine.mythic.lib.api.item.NBTItem; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java index 33c05041..567e1728 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java @@ -18,7 +18,7 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.SkullTextureData; import net.Indyuce.mmoitems.stat.type.BooleanStat; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java index bfe3a963..cf621bc3 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanIdentify.java @@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.api.item.util.identify.IdentifiedItem; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.type.BooleanStat; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import io.lumine.mythic.lib.api.item.NBTItem; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java index a41f25f7..1912aaf3 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanUnsocket.java @@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.data.GemSocketsData; import net.Indyuce.mmoitems.stat.data.GemstoneData; import net.Indyuce.mmoitems.stat.type.BooleanStat; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.util.Pair; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java index 6d27a159..7b9b82e8 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CraftingPermission.java @@ -1,8 +1,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; -import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import net.Indyuce.mmoitems.stat.type.TemplateOption; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java index 76a86be5..fae3c6c7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomDurability.java @@ -4,9 +4,8 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; -import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.InternalStat; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java index f14ff8f2..0f793653 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomModelData.java @@ -6,10 +6,9 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; -import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import io.lumine.mythic.lib.api.item.ItemTag; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java index eff088b8..3eb877c5 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CustomSounds.java @@ -16,9 +16,9 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.SoundsEdition; import net.Indyuce.mmoitems.stat.data.SoundData; import net.Indyuce.mmoitems.stat.data.SoundListData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.ItemStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java index 0f7229df..f3e27550 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayName.java @@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.NameData; import net.Indyuce.mmoitems.stat.type.StatHistory; import net.Indyuce.mmoitems.stat.type.StringStat; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java index bd2085af..d4cc5541 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DisplayedType.java @@ -1,7 +1,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java index ad198a64..46972264 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/DyeColor.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.component.type.builtin.ObjectComponentType; import net.Indyuce.mmoitems.stat.data.ColorData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; @@ -29,128 +30,135 @@ import java.util.Optional; @HasCategory(cat = "item") public class DyeColor extends ItemStat { - public DyeColor() { - super("DYE_COLOR", Material.RED_DYE, "Dye Color", - new String[] { "The color of your item", "(for dyeable items).", "In RGB." }, new String[0], Material.LEATHER_HELMET, - Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Material.LEATHER_HORSE_ARMOR); - } + public DyeColor() { + super("DYE_COLOR", + null, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Material.LEATHER_HORSE_ARMOR); - @Override - public ColorData whenInitialized(Object object) { - Validate.isTrue(object instanceof String, "Must specify a string"); - return new ColorData((String) object); - } + setComponentType(ObjectComponentType.color() + .setIcon(Material.RED_DYE) + .setName("Dye Color") + .trimLore("Sets the dye color of leather player armor and leather horse armor, in RGB (red, green, blue) format.") + .build()); + } - @Override - public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { - if (event.getAction() == InventoryAction.PICKUP_ALL) - new StatEdition(inv, ItemStats.DYE_COLOR).enable("Write in the chat the RGB color you want.", - ChatColor.AQUA + "Format: {Red} {Green} {Blue}"); + @Override + public ColorData whenInitialized(Object object) { + Validate.isTrue(object instanceof String, "Must specify a string"); + return new ColorData((String) object); + } - if (event.getAction() == InventoryAction.PICKUP_HALF) { - inv.getEditedSection().set("dye-color", null); - inv.registerTemplateEdition(); - inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed Dye Color."); - } - } + @Override + public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { + if (event.getAction() == InventoryAction.PICKUP_ALL) + new StatEdition(inv, ItemStats.DYE_COLOR).enable("Write in the chat the RGB color you want.", + ChatColor.AQUA + "Format: {Red} {Green} {Blue}"); - @Override - public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { - String[] split = message.split(" "); - Validate.isTrue(split.length == 3, "Use this format: {Red} {Green} {Blue}."); - for (String str : split) { - int k = Integer.parseInt(str); - Validate.isTrue(k >= 0 && k < 256, "Color must be between 0 and 255"); - } + if (event.getAction() == InventoryAction.PICKUP_HALF) { + inv.getEditedSection().set("dye-color", null); + inv.registerTemplateEdition(); + inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed Dye Color."); + } + } - inv.getEditedSection().set("dye-color", message); - inv.registerTemplateEdition(); - inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Dye Color successfully changed to " + message + "."); - } + @Override + public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { + String[] split = message.split(" "); + Validate.isTrue(split.length == 3, "Use this format: {Red} {Green} {Blue}."); + for (String str : split) { + int k = Integer.parseInt(str); + Validate.isTrue(k >= 0 && k < 256, "Color must be between 0 and 255"); + } - @Override - public void whenDisplayed(List lore, Optional statData) { - lore.add(ChatColor.GRAY + "Current Value: " + (statData.isPresent() ? ChatColor.GREEN + statData.get().toString() : ChatColor.RED + "None")); - lore.add(""); - lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); - lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the dye color."); - } + inv.getEditedSection().set("dye-color", message); + inv.registerTemplateEdition(); + inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Dye Color successfully changed to " + message + "."); + } - @NotNull - @Override - public ColorData getClearStatData() { - return new ColorData(0, 0, 0); - } + @Override + public void whenDisplayed(List lore, Optional statData) { + lore.add(ChatColor.GRAY + "Current Value: " + (statData.isPresent() ? ChatColor.GREEN + statData.get().toString() : ChatColor.RED + "None")); + lore.add(""); + lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); + lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the dye color."); + } - @Override - public void whenLoaded(@NotNull ReadMMOItem mmoitem) { + @NotNull + @Override + public ColorData getClearStatData() { + return new ColorData(0, 0, 0); + } - // Actually ignore the NBT item altogether, we're looking at its colour this time - ItemMeta iMeta = mmoitem.getNBT().getItem().getItemMeta(); + @Override + public void whenLoaded(@NotNull ReadMMOItem mmoitem) { - if (iMeta instanceof LeatherArmorMeta) { + // Actually ignore the NBT item altogether, we're looking at its colour this time + ItemMeta iMeta = mmoitem.getNBT().getItem().getItemMeta(); - // Make a tag with thay colour property - ArrayList relevantTags = new ArrayList<>(); + if (iMeta instanceof LeatherArmorMeta) { - // Kreate and Add - relevantTags.add(new ItemTag(getNBTPath(), ((LeatherArmorMeta) iMeta).getColor())); + // Make a tag with thay colour property + ArrayList relevantTags = new ArrayList<>(); - // Cook - StatData data = getLoadedNBT(relevantTags); + // Kreate and Add + relevantTags.add(new ItemTag(getNBTPath(), ((LeatherArmorMeta) iMeta).getColor())); - // Put if nonull - if (data != null) { mmoitem.setData(this, data); } - } - } + // Cook + StatData data = getLoadedNBT(relevantTags); - /** - * For this specific stat, the NBT is not saved as a custom item, but as the color itself of the dyed item. - *

- * Just pass into here a unique ItemTag of path {@link #getNBTPath()} and of value {@link org.bukkit.Color}, - * which is unique because - */ - @Nullable - @Override - public ColorData getLoadedNBT(@NotNull ArrayList storedTags) { + // Put if nonull + if (data != null) { + mmoitem.setData(this, data); + } + } + } - // Find tag - ItemTag dyedColour = ItemTag.getTagAtPath(getNBTPath(), storedTags); + /** + * For this specific stat, the NBT is not saved as a custom item, but as the color itself of the dyed item. + *

+ * Just pass into here a unique ItemTag of path {@link #getNBTPath()} and of value {@link org.bukkit.Color}, + * which is unique because + */ + @Nullable + @Override + public ColorData getLoadedNBT(@NotNull ArrayList storedTags) { - // Found? - if (dyedColour != null) { + // Find tag + ItemTag dyedColour = ItemTag.getTagAtPath(getNBTPath(), storedTags); - // Get that colour - Color c = (Color) dyedColour.getValue(); + // Found? + if (dyedColour != null) { - // Make and return thay colour data - return new ColorData(c); - } + // Get that colour + Color c = (Color) dyedColour.getValue(); - return null; - } + // Make and return thay colour data + return new ColorData(c); + } - @Override - public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ColorData data) { + return null; + } - // Only does anything if it is a colourable meta - if (item.getMeta() instanceof LeatherArmorMeta) { + @Override + public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ColorData data) { - // Just set the colour - ((LeatherArmorMeta) item.getMeta()).setColor(((ColorData) data).getColor()); - } - } + // Only does anything if it is a colourable meta + if (item.getMeta() instanceof LeatherArmorMeta) { - /** - * For this specific stat, the StatData is not saved as a custom NBT tag, but as the color itself of the dyed item. - *

- * Alas, this array will be empty. Check the colour of the item as a {@link LeatherArmorMeta} to read the value. - */ - @NotNull - @Override - public ArrayList getAppliedNBT(@NotNull ColorData data) { + // Just set the colour + ((LeatherArmorMeta) item.getMeta()).setColor(((ColorData) data).getColor()); + } + } - // No tags are added - return new ArrayList<>(); - } + /** + * For this specific stat, the StatData is not saved as a custom NBT tag, but as the color itself of the dyed item. + *

+ * Alas, this array will be empty. Check the colour of the item as a {@link LeatherArmorMeta} to read the value. + */ + @NotNull + @Override + public ArrayList getAppliedNBT(@NotNull ColorData data) { + + // No tags are added + return new ArrayList<>(); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java index a204e1c3..0043459b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java @@ -23,7 +23,7 @@ import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java index ed4c6c5a..ec01f458 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Elements.java @@ -1,5 +1,6 @@ package net.Indyuce.mmoitems.stat; +import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; @@ -12,6 +13,8 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.ElementsEdition; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.component.type.builtin.DoubleComponentType; +import net.Indyuce.mmoitems.stat.component.type.builtin.ObjectComponentType; import net.Indyuce.mmoitems.stat.data.ElementListData; import net.Indyuce.mmoitems.stat.data.random.RandomElementListData; import net.Indyuce.mmoitems.stat.data.type.StatData; @@ -34,10 +37,31 @@ import java.util.*; @HasCategory(cat = "elements") public class Elements extends ItemStat implements Previewable { public Elements() { - super("ELEMENT", Material.SLIME_BALL, "Elements", new String[]{"The elements of your item."}, + super("ELEMENT", new String[]{"equipment", "ornament", "gem_stone"}); } + @Deprecated + public static void updateComponentType() { + + ItemStat stat = MMOItems.plugin.getStats().get("ELEMENT"); + + + ObjectComponentType.Builder builder = ObjectComponentType.object(); + for (Element element : MythicLib.plugin.getElements().getAll()) + for (ElementStatType statType : ElementStatType.values()) + builder.addField(statType.getConcatenatedTagPath(element).toLowerCase(), DoubleComponentType.numeric() + .setIcon(element.getIcon()) + .setName(element.getName() + " " + statType.getName()) + .build()); + stat.setComponentType(builder + .setIcon(Material.MAGMA_CREAM) + .setName("Elemental Stats") + .trimLore("Have the weapon deal on-hit elemental damage, reduce or increase incoming elemental damage.") + .setActionLoreTags("Click to edit elemental stats.", "Right click to reset elements") + .build()); + } + @Override public RandomElementListData whenInitialized(Object object) { Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section"); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java index 8eb571e4..05a31acc 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemColor.java @@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java index bb41231e..4d4c3555 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemUpgradeScaling.java @@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.util.StatChoice; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java index 2c0f045d..662009a6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java @@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringListStat; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java index 3a759781..efd88631 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemDamage.java @@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import org.bukkit.Material; import org.bukkit.inventory.meta.Damageable; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java index 4ba765c6..d3b4525d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java @@ -9,7 +9,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.InternalStat; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.NotImplementedException; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java index f56b29c4..e9827441 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemSetStat.java @@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java index bb8b051e..3231e3e4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemTierStat.java @@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import org.apache.commons.lang.Validate; import org.bukkit.Material; @@ -10,7 +10,6 @@ import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.ItemTier; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; -import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.StringStat; import io.lumine.mythic.lib.api.item.ItemTag; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java index 95edd7c7..466df8c7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Lore.java @@ -9,7 +9,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringListStat; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java index 13c3d821..80b8d003 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LoreFormat.java @@ -6,7 +6,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.apache.commons.lang.Validate; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java index 674bc5fb..2c5dfff6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackEffectStat.java @@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; import org.bukkit.event.inventory.InventoryAction; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java index 077c5b10..3b828f2a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/LuteAttackSoundStat.java @@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.item.ItemTag; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java index befe2432..729959a4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ManaCost.java @@ -9,8 +9,8 @@ import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java index 67fe26a7..70417e83 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaterialStat.java @@ -12,6 +12,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.component.builtin.MaterialComponent; import net.Indyuce.mmoitems.stat.data.MaterialData; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.md_5.bungee.api.ChatColor; @@ -32,6 +33,12 @@ import java.util.Optional; public class MaterialStat extends ItemStat { public MaterialStat() { super("MATERIAL", VMaterial.GRASS_BLOCK.get(), "Material", new String[] { "Your item material." }, new String[0]); + + setComponentType(MaterialComponent.Type.init() + .setIcon(org.bukkit.Material.GRASS_BLOCK) + .setName("Item Material") + .trimLore("The material of your item. This option determines quite a lot of properties of your item, like durability, interactions with blocks etc. Therefore, you should use a material that makes sense with your item use case.") + .build()); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java index 7464c407..5f1236b4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxItemDamage.java @@ -9,7 +9,7 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import org.apache.commons.lang.Validate; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxStackSize.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxStackSize.java index 056f55eb..8abb42a7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxStackSize.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaxStackSize.java @@ -9,7 +9,7 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java index 4df688bb..e62d0dbc 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/MaximumDurability.java @@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.MaterialData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.type.Upgradable; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java index 4b7b0d56..dad40c08 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Permission.java @@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.type.StringListStat; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java index f3ceb4b2..35fbaa78 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PotionColor.java @@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.component.type.builtin.ObjectComponentType; import net.Indyuce.mmoitems.stat.data.ColorData; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.NotImplementedException; @@ -28,87 +29,93 @@ import java.util.Optional; @HasCategory(cat = "item") public class PotionColor extends ItemStat { - public PotionColor() { - super("POTION_COLOR", Material.POTION, "Potion Color", - new String[] { "The color of your potion.", "(Doesn't impact the effects)." }, new String[0], Material.POTION, - Material.SPLASH_POTION, Material.LINGERING_POTION, Material.TIPPED_ARROW); - } + public PotionColor() { + super("POTION_COLOR", + new String[0], + Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.TIPPED_ARROW); - @Override - public ColorData whenInitialized(Object object) { - Validate.isTrue(object instanceof String, "Must specify a string"); - return new ColorData((String) object); - } + setComponentType(ObjectComponentType.color() + .setName("Potion Color") + .setIcon(Material.POTION) + .trimLore("The potion of your color. It is purely a cosmetic option and has no effect whatsoever on the potion effects.") + .build()); + } - @Override - public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { - if (event.getAction() == InventoryAction.PICKUP_ALL) - new StatEdition(inv, ItemStats.POTION_COLOR).enable("Write in the chat the RGB color you want.", - ChatColor.AQUA + "Format: {Red} {Green} {Blue}"); + @Override + public ColorData whenInitialized(Object object) { + Validate.isTrue(object instanceof String, "Must specify a string"); + return new ColorData((String) object); + } - if (event.getAction() == InventoryAction.PICKUP_HALF) { - inv.getEditedSection().set("potion-color", null); - inv.registerTemplateEdition(); - inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed Potion Color."); - } - } + @Override + public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { + if (event.getAction() == InventoryAction.PICKUP_ALL) + new StatEdition(inv, ItemStats.POTION_COLOR).enable("Write in the chat the RGB color you want.", + ChatColor.AQUA + "Format: {Red} {Green} {Blue}"); - @Override - public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { - String[] split = message.split(" "); - Validate.isTrue(split.length == 3, "Use this format: {Red} {Green} {Blue}. Example: '75 0 130' stands for Purple."); + if (event.getAction() == InventoryAction.PICKUP_HALF) { + inv.getEditedSection().set("potion-color", null); + inv.registerTemplateEdition(); + inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed Potion Color."); + } + } - for (String str : split) { - int k = Integer.parseInt(str); - Validate.isTrue(k >= 0 && k < 256, "Color must be between 0 and 255"); - } + @Override + public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { + String[] split = message.split(" "); + Validate.isTrue(split.length == 3, "Use this format: {Red} {Green} {Blue}. Example: '75 0 130' stands for Purple."); - inv.getEditedSection().set("potion-color", message); - inv.registerTemplateEdition(); - inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Potion Color successfully changed to " + message + "."); - } + for (String str : split) { + int k = Integer.parseInt(str); + Validate.isTrue(k >= 0 && k < 256, "Color must be between 0 and 255"); + } - @Override - public void whenLoaded(@NotNull ReadMMOItem mmoitem) { - if (!(mmoitem.getNBT().getItem().getItemMeta() instanceof PotionMeta)) - return; + inv.getEditedSection().set("potion-color", message); + inv.registerTemplateEdition(); + inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Potion Color successfully changed to " + message + "."); + } - final Color color = ((PotionMeta) mmoitem.getNBT().getItem().getItemMeta()).getColor(); - if (color != null) - mmoitem.setData(this, new ColorData(color)); - } + @Override + public void whenLoaded(@NotNull ReadMMOItem mmoitem) { + if (!(mmoitem.getNBT().getItem().getItemMeta() instanceof PotionMeta)) + return; - @Nullable - @Override - public ColorData getLoadedNBT(@NotNull ArrayList storedTags) { - throw new NotImplementedException(); - } + final Color color = ((PotionMeta) mmoitem.getNBT().getItem().getItemMeta()).getColor(); + if (color != null) + mmoitem.setData(this, new ColorData(color)); + } - @Override - public void whenDisplayed(List lore, Optional statData) { + @Nullable + @Override + public ColorData getLoadedNBT(@NotNull ArrayList storedTags) { + throw new NotImplementedException(); + } - lore.add(statData.isPresent() ? ChatColor.GREEN + statData.get().toString() : ChatColor.RED + "Uncolored"); + @Override + public void whenDisplayed(List lore, Optional statData) { - lore.add(""); - lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); - lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the potion color."); - } + lore.add(statData.isPresent() ? ChatColor.GREEN + statData.get().toString() : ChatColor.RED + "Uncolored"); - @NotNull - @Override - public ColorData getClearStatData() { - return new ColorData(0,0,0); - } + lore.add(""); + lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); + lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the potion color."); + } - @Override - public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ColorData data) { - if (item.getItemStack().getType().name().contains("POTION") || item.getItemStack().getType() == Material.TIPPED_ARROW) - ((PotionMeta) item.getMeta()).setColor(data.getColor()); - } + @NotNull + @Override + public ColorData getClearStatData() { + return new ColorData(0, 0, 0); + } - @NotNull - @Override - public ArrayList getAppliedNBT(@NotNull ColorData data) { - throw new NotImplementedException(); - } + @Override + public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ColorData data) { + if (item.getItemStack().getType().name().contains("POTION") || item.getItemStack().getType() == Material.TIPPED_ARROW) + ((PotionMeta) item.getMeta()).setColor(data.getColor()); + } + + @NotNull + @Override + public ArrayList getAppliedNBT(@NotNull ColorData data) { + throw new NotImplementedException(); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java index e925a31a..76baf2d0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RandomUnsocket.java @@ -16,9 +16,8 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.GemSocketsData; import net.Indyuce.mmoitems.stat.data.GemstoneData; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.StatHistory; import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.util.Pair; import org.bukkit.Bukkit; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java index e791c401..fdeb1ea8 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPower.java @@ -10,7 +10,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.listener.CustomSoundListener; import net.Indyuce.mmoitems.stat.annotation.HasCategory; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.util.RepairUtils; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java index 792925a8..6ab65bcd 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairPowerPercent.java @@ -6,7 +6,7 @@ import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.stat.annotation.HasCategory; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; import org.bukkit.Material; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java index 0031aa55..f6c299df 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RepairReference.java @@ -1,7 +1,7 @@ package net.Indyuce.mmoitems.stat; import net.Indyuce.mmoitems.stat.annotation.HasCategory; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java index fce3aebd..a7ed541d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredBiomes.java @@ -3,13 +3,11 @@ package net.Indyuce.mmoitems.stat; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; -import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; -import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.type.StringListStat; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java index c75e0376..4d7d5ef6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RequiredClass.java @@ -14,8 +14,8 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.type.StringListStat; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java index a455cd58..331d859d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreFood.java @@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java index a896e737..de02df17 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreHealth.java @@ -5,7 +5,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java index 4b34941a..dc9a0f15 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreMana.java @@ -6,7 +6,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.bukkit.Material; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java index 441fb095..b860748f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreSaturation.java @@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java index ac92ec2c..dac70f4d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RestoreStamina.java @@ -6,7 +6,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.PlayerConsumable; +import net.Indyuce.mmoitems.stat.behaviour.PlayerConsumable; import org.bukkit.Material; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java index 5665a96c..e7b7a1b1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/RevisionID.java @@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.RevisionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.DoubleData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingBreakChance.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingBreakChance.java index 5a2264c3..aa6918cc 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingBreakChance.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingBreakChance.java @@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.SoulboundData; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Bukkit; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingChance.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingChance.java index 2e53d1f3..b897f87c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingChance.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SoulbindingChance.java @@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.SoulboundData; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Bukkit; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java index ee934d71..6b5f517e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java @@ -16,8 +16,8 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.SoulboundData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.InternalStat; -import net.Indyuce.mmoitems.stat.type.ItemRestriction; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.NotImplementedException; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java index 0fb9409b..3454a0cd 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/StoredTags.java @@ -8,8 +8,8 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StoredTagsData; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; -import net.Indyuce.mmoitems.stat.type.InternalStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import org.apache.commons.lang.NotImplementedException; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java index f56ad94e..1d0f9a7e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/SuccessRate.java @@ -4,7 +4,7 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import org.bukkit.Material; import net.Indyuce.mmoitems.stat.type.DoubleStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; @HasCategory(cat = "gem_stones") public class SuccessRate extends DoubleStat implements GemStoneStat { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java index 3dd26c88..1eee917d 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TooltipStat.java @@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.tooltip.TooltipTexture; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.data.StringData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringStat; import org.apache.commons.lang.Validate; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java index 79eef996..f487048f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimMaterialStat.java @@ -5,7 +5,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.util.StatChoice; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java index 1e478d3f..a25be758 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/TrimPatternStat.java @@ -5,7 +5,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.type.ChooseStat; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.util.StatChoice; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java index 44ce7f81..3703a624 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java @@ -23,7 +23,7 @@ import net.Indyuce.mmoitems.gui.edition.UpgradingEdition; import net.Indyuce.mmoitems.stat.annotation.HasCategory; import net.Indyuce.mmoitems.stat.data.UpgradeData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; +import net.Indyuce.mmoitems.stat.behaviour.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.Validate; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/TerminalComponentException.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/TerminalComponentException.java new file mode 100644 index 00000000..1222555f --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/annotation/TerminalComponentException.java @@ -0,0 +1,8 @@ +package net.Indyuce.mmoitems.stat.annotation; + +public class TerminalComponentException extends RuntimeException { + + public TerminalComponentException() { + super("Terminal component type"); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ConsumableItemInteraction.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ConsumableItemInteraction.java similarity index 96% rename from MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ConsumableItemInteraction.java rename to MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ConsumableItemInteraction.java index 4b58e000..a9ea4da4 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ConsumableItemInteraction.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ConsumableItemInteraction.java @@ -1,4 +1,4 @@ -package net.Indyuce.mmoitems.stat.type; +package net.Indyuce.mmoitems.stat.behaviour; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/GemStoneStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/GemStoneStat.java similarity index 73% rename from MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/GemStoneStat.java rename to MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/GemStoneStat.java index b6b15fb2..3cbcd3c9 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/GemStoneStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/GemStoneStat.java @@ -1,4 +1,4 @@ -package net.Indyuce.mmoitems.stat.type; +package net.Indyuce.mmoitems.stat.behaviour; /** * Statistics which must NOT be applied onto an item when socketing the gem @@ -7,4 +7,5 @@ package net.Indyuce.mmoitems.stat.type; * * @author indyuce */ -public interface GemStoneStat { } +public interface GemStoneStat { +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/InternalStat.java similarity index 89% rename from MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java rename to MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/InternalStat.java index 7c7b6361..6fc5c8ba 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/InternalStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/InternalStat.java @@ -1,4 +1,4 @@ -package net.Indyuce.mmoitems.stat.type; +package net.Indyuce.mmoitems.stat.behaviour; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ItemRestriction.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ItemRestriction.java new file mode 100644 index 00000000..dfbc2dfc --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/ItemRestriction.java @@ -0,0 +1,39 @@ +package net.Indyuce.mmoitems.stat.behaviour; + +import net.Indyuce.mmoitems.api.player.RPGPlayer; +import io.lumine.mythic.lib.api.item.NBTItem; + +/** + * Stats which implement an item restriction. They are automatically collected + * in a list when registered in the StatManager. Lets other plugins implement + * stats which rely on item restrictions without having to use Bukkit events! + * + * @author cympe + */ +public interface ItemRestriction { + + /** + * @param player Player trying to use an item + * @param item The item being checked + * @param message Difference between an active and a passive check: if the + * check is active (message boolean set to true), the plugin + * should send a message to the player if he can't use the + * item for eg when he tries to equip the item. If the check + * is passive, no message needs to be sent (when the plugin + * internally needs some similar check) + * @return False if the item cannot be used + */ + boolean canUse(RPGPlayer player, NBTItem item, boolean message); + + /** + * Usually, item restrictions are checked when equipping + * an item, and prevent the item being equipped if they fail that moment. + *

+ * Setting this to true will allow items equip anyway + * and check with every use that the conditions for their usage + * are met. + */ + default boolean isDynamic() { + return false; + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/PlayerConsumable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/PlayerConsumable.java similarity index 68% rename from MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/PlayerConsumable.java rename to MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/PlayerConsumable.java index f8619a24..a8966fc6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/PlayerConsumable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/behaviour/PlayerConsumable.java @@ -1,4 +1,4 @@ -package net.Indyuce.mmoitems.stat.type; +package net.Indyuce.mmoitems.stat.behaviour; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import org.bukkit.entity.Player; @@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull; *
* Any food is a self consumable, since you eat them to * restore hunger or health or whatever, while upgrading - * consumables are not self consumables, as the are used + * consumables are not self consumables, as they are used * on other items and cannot be consumed by themselves. * * @author Gunging @@ -21,9 +21,9 @@ public interface PlayerConsumable { * Called when the item is being consumed directly by a player. * * @since 6.7 You need to specify if the item is being eaten the vanilla - * way or not. This is used to fix an issue where when eating through the - * vanilla eating animation, the default food and saturation modifier is - * applied so MMOItems needs to apply some offset to food/saturation. + * way or not. This is used to fix an issue where when eating through the + * vanilla eating animation, the default food and saturation modifier is + * applied so MMOItems needs to apply some offset to food/saturation. */ void onConsume(@NotNull VolatileMMOItem mmo, @NotNull Player player, boolean vanillaEating); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java deleted file mode 100644 index e7a7c8e1..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/DoubleComponent.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.Indyuce.mmoitems.stat.component; - - -public class DoubleComponent extends StatComponent implements Mergeable { - private double value; - - public DoubleComponent() { - } - - @Override - public void merge(DoubleComponent component) { - value += component.value; - } -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java deleted file mode 100644 index 2a9b8fca..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/IntegerComponent.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.Indyuce.mmoitems.stat.component; - - -public class IntegerComponent extends StatComponent implements Mergeable { - private int value; - - public IntegerComponent() { - } - - @Override - public void merge(IntegerComponent component) { - value += component.value; - } -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/LoreWrapper.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/LoreWrapper.java new file mode 100644 index 00000000..9c269bbb --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/LoreWrapper.java @@ -0,0 +1,27 @@ +package net.Indyuce.mmoitems.stat.component; + +import org.bukkit.ChatColor; + +import java.util.List; + +public class LoreWrapper { + private final List lore; + private final String prefix = String.valueOf(ChatColor.GRAY); + + public LoreWrapper(List lore) { + this.lore = lore; + } + + @Deprecated + public void addLines(String... lines) { + for (String line : lines) addLine(line); + } + + public void addLine(String line) { + lore.add(prefix + ChatColor.translateAlternateColorCodes('&', line)); + } + + public void addLines(Iterable lines) { + for (String line : lines) addLine(line); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java index dd002ad1..7b8b96df 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/Mergeable.java @@ -1,8 +1,10 @@ package net.Indyuce.mmoitems.stat.component; import io.lumine.mythic.lib.util.annotation.NotUsed; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; -public interface Mergeable { +@NotUsed +public interface Mergeable, T extends StatComponent> { - public void merge(T t); + public void merge(C componentType, T t); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java deleted file mode 100644 index 24a1b8af..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/ObjectComponent.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.Indyuce.mmoitems.stat.component; - -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -public class ObjectComponent extends StatComponent { - private final Map components = new HashMap<>(); - - public ObjectComponent() { - - } - - @Nullable - public StatComponent getComponent(String path) { - return components.get(path); - } - - public void forEachComponent(Consumer action) { - for (StatComponent component : components.values()) - action.accept(component); - } - - public Set getComponentKeys() { - return components.keySet(); - } - - /* - @Nullable - public StatComponent findComponent(String path) { - String[] split = path.split("\\."); - - ObjectComponent current = this; - int n = split.length - 1; - for (int i = 0; i < n; i++) { - StatComponent next = getComponent(split[i]); - if (next == null || !(next instanceof ObjectComponent)) - return null; - - current = (ObjectComponent) next; - } - - return current.getComponent(split[n]); - } - */ -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java index 10866488..5c40e358 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/StatComponent.java @@ -1,5 +1,30 @@ package net.Indyuce.mmoitems.stat.component; +import net.Indyuce.mmoitems.stat.component.builtin.ObjectComponent; +import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + public abstract class StatComponent { + @Nullable + public StatComponent get(@NotNull String key) { + throw new RuntimeException("No subcomponent for " + getClass().getSimpleName()); + } + + @Nullable + @Deprecated + public StatComponent findComponent(String path) { + String[] split = path.split("\\."); + + ObjectComponent current = (ObjectComponent) this; + int n = split.length - 1; + for (int i = 0; i < n; i++) { + StatComponent next = current.get(split[i]); + Validate.notNull(next, "Could not find component " + path); + current = (ObjectComponent) next; + } + + return current.get(split[n]); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/AbilityComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/AbilityComponent.java new file mode 100644 index 00000000..4c1b7e6a --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/AbilityComponent.java @@ -0,0 +1,61 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.skill.RegisteredSkill; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.apache.commons.lang.NotImplementedException; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.List; + +public class AbilityComponent extends StatComponent implements Model { + private RegisteredSkill ability; + + @NotNull + public RegisteredSkill getValue() { + return ability; + } + + @NotNull + public static Type.Builder type() { + return new Type().new Builder(); + } + + @Override + public AbilityComponent randomizeComponent(MMOItemBuilder builder) { + return this; + } + + public static class Type extends ComponentType { + + @NotNull + @Override + public List editionUiFormat(AbilityComponent data) { + return Collections.singletonList(data.getValue().getName()); + /* + List format = new ArrayList<>(1 + data.getComponentKeys().size()); + format.add("Ability: " + data.getAbility().getName()); + data.forEachModifier((key, comp) -> format.add(key + ": " + comp.getValue())); + return format; + */ + } + + @Override + public AbilityComponent initialize(@NotNull Object object) { + throw new NotImplementedException(); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTagHint("ability"); + } + + public Type build() { + return (Type) super.build(); + } + } + } +} \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ArrayComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ArrayComponent.java new file mode 100644 index 00000000..9fb9351a --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ArrayComponent.java @@ -0,0 +1,28 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + +import net.Indyuce.mmoitems.stat.component.StatComponent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class ArrayComponent extends StatComponent { + private final List components = new ArrayList<>(); + + @Nullable + public C getComponent(int index) { + return components.get(index); + } + + public void forEachComponent(Consumer action) { + for (C component : components) + action.accept(component); + } + + @NotNull + public List getComponents() { + return components; + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/BooleanComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/BooleanComponent.java new file mode 100644 index 00000000..1fb227e0 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/BooleanComponent.java @@ -0,0 +1,37 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + + +import net.Indyuce.mmoitems.stat.component.Mergeable; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.type.builtin.BooleanComponentType; + +public class BooleanComponent extends StatComponent implements Mergeable { + private boolean value; + + public BooleanComponent(boolean value) { + this.value = value; + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } + + @Override + public void merge(BooleanComponentType componentType, BooleanComponent component) { + switch (componentType.mergeMecanism) { + case OR: + value |= component.value; + break; + case AND: + value &= component.value; + break; + case XOR: + value ^= component.value; + break; + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/DoubleComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/DoubleComponent.java new file mode 100644 index 00000000..80eaa823 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/DoubleComponent.java @@ -0,0 +1,28 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + + +import net.Indyuce.mmoitems.stat.component.Mergeable; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.type.builtin.DoubleComponentType; + +public class DoubleComponent extends StatComponent implements Mergeable { + private double value; + + public DoubleComponent(double value) { + this.value = value; + } + + public double getValue() { + return value; + } + + public void setValue(double value) { + this.value = value; + } + + @Override + public void merge(DoubleComponentType componentType, DoubleComponent component) { + value += component.value; + // TODO merge mecanisms + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/IntegerComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/IntegerComponent.java new file mode 100644 index 00000000..a383f40c --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/IntegerComponent.java @@ -0,0 +1,33 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + + +import net.Indyuce.mmoitems.stat.component.Mergeable; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.type.builtin.IntegerComponentType; + +public class IntegerComponent extends StatComponent implements Mergeable { + private int value; + + public IntegerComponent(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + @Override + public void merge(IntegerComponentType componentType, IntegerComponent component) { + switch (componentType.mergeMecanism) { + case SUM: + value += component.value; + break; + case HIGHEST: + value = Math.max(value, component.value); + break; + case LOWEST: + value = Math.min(value, component.value); + break; + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ItemAbilityComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ItemAbilityComponent.java new file mode 100644 index 00000000..ba6e6fcf --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ItemAbilityComponent.java @@ -0,0 +1,225 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + +import io.lumine.mythic.lib.util.annotation.NotUsed; +import net.Indyuce.mmoitems.skill.RegisteredSkill; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; + +@NotUsed +@Deprecated +public class ItemAbilityComponent extends ObjectComponent { + private AbilityComponent ability; + private Map modifiers; + + /* + public NewAbilityData(@NotNull JsonObject object) { + super(MMOUtils.backwardsCompatibleTriggerType(object.get("CastMode").getAsString())); + + ability = MMOItems.plugin.getSkills().getSkill(object.get("Id").getAsString()); + + JsonObject modifiers = object.getAsJsonObject("Modifiers"); + modifiers.entrySet().forEach(entry -> setModifier(entry.getKey(), entry.getValue().getAsDouble())); + } + + public NewAbilityData(@NotNull ConfigurationSection config) { + super(MMOUtils.backwardsCompatibleTriggerType(UtilityMethods.enumName(Objects.requireNonNull(config.getString("mode"), "Ability is missing mode")))); + + Validate.isTrue(config.contains("type"), "Ability is missing type"); + + String abilityFormat = UtilityMethods.enumName(config.getString("type")); + Validate.isTrue(MMOItems.plugin.getSkills().hasSkill(abilityFormat), "Could not find ability called '" + abilityFormat + "'"); + ability = MMOItems.plugin.getSkills().getSkill(abilityFormat); + + for (String key : config.getKeys(false)) + if (!key.equalsIgnoreCase("mode") && !key.equalsIgnoreCase("type") && ability.getHandler().getModifiers().contains(key)) + modifiers.put(key, config.getDouble(key)); + } + + public NewAbilityData(RegisteredSkill ability, TriggerType triggerType) { + super(triggerType); + + this.ability = ability; + } + */ + + @NotNull + public RegisteredSkill getAbility() { + return ability.getValue(); + } + + @NotNull + public Set getModifiers() { + return modifiers.keySet(); + } + + public void forEachModifier(BiConsumer action) { + modifiers.forEach(action); + } + + public void setModifier(String modifier, double value) { + modifiers.put(modifier, new DoubleComponent(value)); + } + + public boolean hasModifier(String modifier) { + return modifiers.containsKey(modifier); + } + + @Override + public void set(@NotNull String key, @NotNull StatComponent component) { + + } + + @Nullable + @Override + public StatComponent get(@NotNull String key) { + return null; + } + + @Override + public void forEachComponent(@NotNull BiConsumer action) { + + } + + @NotNull + @Override + public Collection getComponentKeys() { + return Arrays.asList("ability", "modifiers"); + } + + + /* + @Override + public boolean getResult(SkillMetadata meta) { + + PlayerData playerData = PlayerData.get(meta.getCaster().getPlayer()); + RPGPlayer rpgPlayer = playerData.getRPG(); + Player player = meta.getCaster().getPlayer(); + + // Check for cooldown + if (meta.getCaster().getData().getCooldownMap().isOnCooldown(this)) { + CooldownInfo info = playerData.getMMOPlayerData().getCooldownMap().getInfo(this); + if (!getTrigger().isSilent()) { + StringBuilder progressBar = new StringBuilder(ChatColor.YELLOW + ""); + double progress = (double) (info.getInitialCooldown() - info.getRemaining()) / info.getInitialCooldown() * 10; + String barChar = MMOItems.plugin.getConfig().getString("cooldown-progress-bar-char"); + for (int j = 0; j < 10; j++) + progressBar.append(progress >= j ? ChatColor.GREEN : ChatColor.WHITE).append(barChar); + Message.SPELL_ON_COOLDOWN.format(ChatColor.RED, "#left#", MythicLib.plugin.getMMOConfig().decimal.format(info.getRemaining() / 1000d), "#progress#", progressBar.toString(), "#s#", (info.getRemaining() > 1999 ? "s" : "")).send(player); + } + return false; + } + + // Check for permission + if (MMOItems.plugin.getConfig().getBoolean("permissions.abilities") && !player.hasPermission("mmoitems.ability." + getHandler().getLowerCaseId()) && !player.hasPermission("mmoitems.bypass.ability")) + return false; + + // Check for mana cost + if (hasModifier("mana") && rpgPlayer.getMana() < meta.getParameter("mana")) { + Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(player); + return false; + } + + // Check for stamina cost + if (hasModifier("stamina") && rpgPlayer.getStamina() < meta.getParameter("stamina")) { + Message.NOT_ENOUGH_STAMINA.format(ChatColor.RED).send(player); + return false; + } + + return true; + } + + @Override + public void whenCast(SkillMetadata meta) { + PlayerData playerData = PlayerData.get(meta.getCaster().getPlayer()); + RPGPlayer rpgPlayer = playerData.getRPG(); + + // Apply mana cost + if (hasModifier("mana")) rpgPlayer.giveMana(-meta.getParameter("mana")); + + // Apply stamina cost + if (hasModifier("stamina")) rpgPlayer.giveStamina(-meta.getParameter("stamina")); + + // Apply cooldown + double cooldown = meta.getParameter("cooldown") * (1 - Math.min(.8, meta.getCaster().getStat("COOLDOWN_REDUCTION") / 100)); + if (cooldown > 0) meta.getCaster().getData().getCooldownMap().applyCooldown(this, cooldown); + } + + + @Override + public SkillHandler getHandler() { + return ability.getHandler(); + } + + @Override + public double getParameter(String path) { + return modifiers.getOrDefault(path, ability.getDefaultModifier(path)); + } + + + public JsonObject toJson() { + JsonObject object = new JsonObject(); + object.addProperty("Id", ability.getHandler().getId()); + object.addProperty("CastMode", getTrigger().name()); + + JsonObject modifiers = new JsonObject(); + this.modifiers.keySet().forEach(modifier -> modifiers.addProperty(modifier, getParameter(modifier))); + object.add("Modifiers", modifiers); + + return object; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AbilityDataImpl that = (AbilityDataImpl) o; + return ability.equals(that.ability) && getTrigger().equals(that.getTrigger()) && modifiers.equals(that.modifiers); + } + + @Override + public String toString() { + return "AbilityData{" + + "ability=" + ability + + ", modifiers=" + modifiers + + '}'; + } + + @Override + public int hashCode() { + return Objects.hash(ability, modifiers); + } + + @NotNull + public static Type.Builder type() { + return new Type().new Builder(); + } + + public static class Type extends ComponentType { + + @NotNull + @Override + public List editionUiFormat(ItemAbilityComponent data) { + List format = new ArrayList<>(1 + data.getComponentKeys().size()); + format.add("Ability: " + data.getAbility().getName()); + data.forEachModifier((key, comp) -> format.add(key + ": " + comp.getValue())); + return format; + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTagHint("ability"); + } + + public Type build() { + return (Type) super.build(); + } + } + }*/ +} \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/MaterialComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/MaterialComponent.java new file mode 100644 index 00000000..6208b94d --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/MaterialComponent.java @@ -0,0 +1,68 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + + +import io.lumine.mythic.lib.UtilityMethods; +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.List; + +public class MaterialComponent extends StatComponent implements Model { + private Material mat; + + public MaterialComponent(@Nullable Material mat) { + this.mat = mat; + } + + public Material getMaterial() { + return mat; + } + + @Override + public MaterialComponent randomizeComponent(MMOItemBuilder builder) { + return this; + } + + /* + @Override + public void merge(MaterialComponent component) { + value += component.value; + } + */ + + public static class Type extends ComponentType { + + @NotNull + @Override + public List editionUiFormat(MaterialComponent data) { + return Collections.singletonList(data.getMaterial().name()); + } + + @Override + public MaterialComponent initialize(@NotNull Object object) { + return new MaterialComponent(Material.valueOf(UtilityMethods.enumName(object.toString()))); + } + + @NotNull + public static Builder init() { + return new Type().new Builder(); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTags("Left click to edit this material.", "Right click to remove this option."); + setTerminal(true); + } + + public Type build() { + return (Type) super.build(); + } + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponent.java new file mode 100644 index 00000000..f3cd21d1 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponent.java @@ -0,0 +1,38 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.function.BiConsumer; + +/** + * Allows both implementations of abstract objects for user-end + * fully customizable stat components, and builtin hard-coded + * implementations of components like abilities, elements for + * performance. + *

+ * Components for built-in stats like abilities or elements + * have specific implementations for performance to avoid the + * abstraction overhead. + */ +public abstract class ObjectComponent extends StatComponent implements Model { + + public abstract void set(@NotNull String key, @NotNull StatComponent component); + + @Nullable + public abstract StatComponent get(@NotNull String key); + + public abstract void forEachComponent(@NotNull BiConsumer action); + + @NotNull + public abstract Collection getComponentKeys(); + + @Override + public ObjectComponent randomizeComponent(MMOItemBuilder builder) { + return this; + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponentImpl.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponentImpl.java new file mode 100644 index 00000000..7792f578 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/ObjectComponentImpl.java @@ -0,0 +1,36 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + +import net.Indyuce.mmoitems.stat.component.StatComponent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; + +public class ObjectComponentImpl extends ObjectComponent { + private final Map components = new HashMap<>(); + + @Override + public void set(@NotNull String key, @NotNull StatComponent component) { + components.put(key, component); + } + + @Nullable + @Override + public StatComponent get(@NotNull String key) { + return components.get(key); + } + + @Override + public void forEachComponent(@NotNull BiConsumer action) { + components.forEach(action); + } + + @NotNull + @Override + public Set getComponentKeys() { + return components.keySet(); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/StringComponent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/StringComponent.java new file mode 100644 index 00000000..bba3cf63 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/builtin/StringComponent.java @@ -0,0 +1,32 @@ +package net.Indyuce.mmoitems.stat.component.builtin; + + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import org.jetbrains.annotations.Nullable; + +public class StringComponent extends StatComponent implements Model { + private String value; + + public StringComponent(@Nullable String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public StringComponent randomizeComponent(MMOItemBuilder builder) { + return this; + } + + /* + @Override + public void merge(StringComponent component) { + // By default, mere replacement, but can depend on options configured in the config section!! + value = component.value; + } + */ +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/Model.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/Model.java new file mode 100644 index 00000000..79b3600d --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/Model.java @@ -0,0 +1,23 @@ +package net.Indyuce.mmoitems.stat.component.model; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.annotation.TerminalComponentException; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface Model { + + /** + * @param builder The builder of the random item being generated + * @return A random stat data instance which will then be merged onto the + * base item template + */ + C randomizeComponent(MMOItemBuilder builder); + + // TODO change name + @Nullable + default Model getModel(@NotNull String key) { + throw new TerminalComponentException(); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ArrayModel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ArrayModel.java new file mode 100644 index 00000000..babfd24a --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ArrayModel.java @@ -0,0 +1,24 @@ +package net.Indyuce.mmoitems.stat.component.model.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.builtin.ArrayComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import org.apache.commons.lang.NotImplementedException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +// TODO merge with component? +public class ArrayModel implements Model> { + + @Override + public ArrayComponent randomizeComponent(MMOItemBuilder builder) { + throw new NotImplementedException(); + } + + @Nullable + @Override + public Model getModel(@NotNull String key) { + throw new NotImplementedException(); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/BooleanModel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/BooleanModel.java new file mode 100644 index 00000000..b73cde0d --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/BooleanModel.java @@ -0,0 +1,49 @@ +package net.Indyuce.mmoitems.stat.component.model.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.builtin.BooleanComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import org.apache.commons.lang.Validate; + +import java.util.Random; + +public class BooleanModel implements Model { + + private final double chance; + private final Boolean value; + // TODO add string expression + + private static final Random RANDOM = new Random(); + + public BooleanModel(Object object) { + + // Boolean value + if (object instanceof Boolean) { + this.value = (boolean) object; + this.chance = 0; + } + + // Flat nb + else if (object instanceof Number) { + this.value = null; + this.chance = Double.parseDouble(object.toString()); + Validate.isTrue(chance >= 0 && chance <= 1, "Chance must be between 0 and 1"); + } + + throw new IllegalArgumentException("Must be a number or boolean value"); + } + + public double getChance() { + return chance; + } + + public Boolean getValue() { + return value; + } + + @Override + public BooleanComponent randomizeComponent(MMOItemBuilder builder) { + boolean value = this.value != null ? this.value : chance < RANDOM.nextDouble(); + return new BooleanComponent(value); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/DoubleModel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/DoubleModel.java new file mode 100644 index 00000000..176e4666 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/DoubleModel.java @@ -0,0 +1,27 @@ +package net.Indyuce.mmoitems.stat.component.model.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.annotation.TerminalComponentException; +import net.Indyuce.mmoitems.stat.component.builtin.DoubleComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class DoubleModel implements Model { + private final NumericStatFormula formula; + // TODO add string expression + + public DoubleModel(NumericStatFormula formula) { + this.formula = formula; + } + + public NumericStatFormula getFormula() { + return formula; + } + + @Override + public DoubleComponent randomizeComponent(MMOItemBuilder builder) { + return new DoubleComponent(formula.calculate(builder.getLevel())); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/IntegerModel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/IntegerModel.java new file mode 100644 index 00000000..4ab8f080 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/IntegerModel.java @@ -0,0 +1,25 @@ +package net.Indyuce.mmoitems.stat.component.model.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.component.builtin.IntegerComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; + +public class IntegerModel implements Model { + private final NumericStatFormula formula; + + public IntegerModel(NumericStatFormula formula) { + this.formula = formula; + } + + public NumericStatFormula getFormula() { + return formula; + } + + @Override + public IntegerComponent randomizeComponent(MMOItemBuilder builder) { + // TODO add rule for round/ceil/floor? + // TODO make this function require a componentType as argument. cannot save it inside of models/components! + return new IntegerComponent((int) Math.round(formula.calculate(builder.getLevel()))); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ObjectModel.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ObjectModel.java new file mode 100644 index 00000000..c673940c --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/model/builtin/ObjectModel.java @@ -0,0 +1,36 @@ +package net.Indyuce.mmoitems.stat.component.model.builtin; + +import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; +import net.Indyuce.mmoitems.stat.component.builtin.ObjectComponent; +import net.Indyuce.mmoitems.stat.component.builtin.ObjectComponentImpl; +import net.Indyuce.mmoitems.stat.component.model.Model; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +// TODO merge with component? +public class ObjectModel implements Model { + private final Map> components = new HashMap<>(); + + public Map> getComponents() { + return components; + } + + @Override + public ObjectComponent randomizeComponent(MMOItemBuilder builder) { + ObjectComponentImpl comp = new ObjectComponentImpl(); + + for (Map.Entry> entry : this.components.entrySet()) + comp.set(entry.getKey(), entry.getValue().randomizeComponent(builder)); + + return comp; + } + + @Nullable + @Override + public Model getModel(@NotNull String key) { + return components.get(key); + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java index 0ba2e362..4c46c08b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ComponentType.java @@ -1,4 +1,197 @@ package net.Indyuce.mmoitems.stat.component.type; -public class ComponentType { +import net.Indyuce.mmoitems.stat.component.LoreWrapper; +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import net.Indyuce.mmoitems.util.MMOUtils; +import net.Indyuce.mmoitems.util.Pair; +import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang.Validate; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.function.Function; + +public abstract class ComponentType, C extends StatComponent> { + + /** + * A terminal component type is the type for a component + * which holds a terminal value like a string, integer, + * double, boolean, or even custom object types like abilities, + * ... + *

+ * Such terminal components can be directly edited by the player + * by clicking on that component in the editor UI. No further sub-UI + * can be opened to access its subcomponents. + */ + private boolean terminal; + private Function icon; + private Function name; + private Function> description; + + private List actionLoreTags = Arrays.asList("Left click to change this value.", "Right click to reset this value."); + + public boolean isTerminal() { + return terminal; + } + + @NotNull + public ItemStack provideIcon(@Nullable M model) { + return icon.apply(model); + } + + public String provideName(@Nullable M model) { + return name.apply(model); + } + + @Nullable + public List provideDescription(@Nullable M model) { + return description == null ? null : description.apply(model); + } + + public List getActionLoreTags() { + return actionLoreTags; + } + + /* + public void flatten(@NotNull List, StatComponent>> list, @Nullable S statComponent) { + Validate.isTrue(terminal, "Basic impl for terminal components"); + list.add(Pair.of(this, statComponent)); + } + */ + + /** + * @deprecated TODO adapt to arrays + */ + @NotNull + @Deprecated + public List>> getSubcomponents() { + throw new NotImplementedException(); + } + + public static final String NO_VALUE = ChatColor.RED + "---"; + public static final String CURRENT_VALUE = "Current Value: "; + + public void editionUiDisplay(LoreWrapper lore, @Nullable M model) { + + // Display nothing + if (model == null) { + lore.addLine(CURRENT_VALUE + NO_VALUE); + return; + } + + // Error handling + List disp; + try { + disp = editionUiFormat(model); + } catch (Exception exception) { + lore.addLine(CURRENT_VALUE + NO_VALUE); + // TODO improve error handling lore.addLine(ChatColor.RED + "Error: " + exception.getMessage()); + return; + } + + // Display it + if (disp.size() == 1) lore.addLine("Current Value: " + ChatColor.GREEN + disp.getFirst()); + else { + lore.addLine("Current Value:"); + lore.addLines(disp); + } + } + + // TODO remove overhead of using intermediate List + @NotNull + public abstract List editionUiFormat(M model); + + public abstract M initialize(@NotNull Object object); + + public class Builder { + public Builder setTerminal(boolean terminal) { + ComponentType.this.terminal = terminal; + return this; + } + + public Builder setIcon(@NotNull Material material) { + return setIcon(ignored -> new ItemStack(material)); + } + + public Builder setIcon(@NotNull ItemStack icon) { + return setIcon(ignored -> icon); + } + + public Builder setIcon(@NotNull Function material) { + ComponentType.this.icon = material; + return this; + } + + public Builder setActionLoreTags(@NotNull String... tags) { + ComponentType.this.actionLoreTags = Arrays.asList(tags); + return this; + } + + public Builder setActionLoreTagHint(@NotNull String hint) { + return setActionLoreTags("Left click to edit this " + hint + ".", "Right click to remove this " + hint + "."); + } + + public Builder setName(@NotNull String name) { + return setName(ignored -> name); + } + + public Builder setName(@NotNull Function name) { + ComponentType.this.name = name; + return this; + } + + public Builder setLore(@NotNull String... lore) { + return setLore(Arrays.asList(lore)); + } + + public Builder setLore(@NotNull List lore) { + return setLore(ignored -> lore); + } + + public Builder setLore(@NotNull Function> lore) { + ComponentType.this.description = lore; + return this; + } + + public Builder fromConfig(@NotNull ConfigurationSection config) { + setName(config.getString("name", "{no_stat_name}")); + + Object lore = config.get("lore"); + if (lore == null) setLore(Collections.singletonList("{no_stat_description}")); + else if (lore instanceof String) trimLore(lore.toString()); + else if (lore instanceof List) setLore((List) lore); + + setIcon(MMOUtils.readIcon(config.getString("icon"))); + + // TODO + + return this; + } + + public Builder trimLore(@NotNull String lore) { + return setLore(MMOUtils.trimString(40, lore)); + } + + /** + * Should return an exception if one of the fields is not correct + * + * @return Built component type + */ + public ComponentType build() { + // TODO infer data instead of throwing an error + Validate.notNull(icon, "Icon cannot be null"); + Validate.notNull(name, "Name cannot be null"); + //Validate.notNull(description, "Lore cannot be null"); + //Validate.notNull(actionLoreTags, "Action lore tags cannot be null"); + return ComponentType.this; + } + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java deleted file mode 100644 index b454631e..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/DoubleComponentType.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.Indyuce.mmoitems.stat.component.type; - -public class DoubleComponentType extends ComponentType { - - /** - * Are higher values of this component better or worse? Debuff stats - * should set this to false, otherwise should be true by default for - * most stats. - */ - boolean moreIsBetter = true; -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java deleted file mode 100644 index 6814e3d5..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/IntegerComponentType.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.Indyuce.mmoitems.stat.component.type; - -public class IntegerComponentType { - - /** - * Are higher values of this component better or worse? Debuff stats - * should set this to false, otherwise should be true by default for - * most stats. - */ - boolean moreIsBetter = true; - - /** - * Should components be displayed using roman integer format. - */ - boolean useRoman; -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java deleted file mode 100644 index 1b0ee032..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/ObjectComponentType.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.Indyuce.mmoitems.stat.component.type; - -public class ObjectComponentType { - - /** - * Are higher values of this component better or worse? Debuff stats - * should set this to false, otherwise should be true by default for - * most stats. - */ - boolean moreIsBetter = true; - - /** - * Should components be displayed using roman integer format. - */ - boolean useRoman; -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ArrayComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ArrayComponentType.java new file mode 100644 index 00000000..7f21558d --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ArrayComponentType.java @@ -0,0 +1,94 @@ +package net.Indyuce.mmoitems.stat.component.type.builtin; + +import net.Indyuce.mmoitems.stat.component.StatComponent; +import net.Indyuce.mmoitems.stat.component.builtin.ArrayComponent; +import net.Indyuce.mmoitems.stat.component.model.Model; +import net.Indyuce.mmoitems.stat.component.model.builtin.ArrayModel; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class ArrayComponentType + extends ComponentType, ArrayComponent> { + + /** + * The component type that you can find inside your array. + * This must be specified for MMOItems to parse tags containing + * arrays of arbitrary types into component objects. + */ + private ComponentType subtype; + + private boolean displayList; + + private String nbElementsFormat = "Element Count: %s"; + private String listElPrefix = ""; + private String listHeader = ComponentType.CURRENT_VALUE; + + @NotNull + @Override + public List editionUiFormat(ArrayModel data) { +/* + // Display all the elements + if (displayList) { + + // Empty list + List list = data.getComponents(); + if (list.isEmpty()) return Collections.singletonList(listElPrefix + ComponentType.NO_VALUE); + + // Display full list + List lore = new ArrayList<>(1 + list.size()); + lore.add(listHeader); + for (StatComponent comp : list) { + List el = ((ComponentType) subtype).editionUiFormat(comp); // Can throw casting errors + lore.add(listElPrefix + el.removeFirst()); + lore.addAll(el); + } + return lore; + } + + // Simply print number of elements + else return Collections.singletonList(String.format(nbElementsFormat, data.getComponents().size())); + */ + throw new NotImplementedException(); + } + + @NotNull + @SuppressWarnings("rawtypes") + public static ArrayComponentType.Builder array() { + return new ArrayComponentType<>().new Builder(); + } + + @Override + public ArrayModel initialize(@NotNull Object object) { + throw new NotImplementedException(); + } + + @NotNull + public static , T extends ComponentType, S extends StatComponent> ArrayComponentType.Builder arrayOf(T of) { + return new ArrayComponentType().new Builder().of(of); + } + + public class Builder extends ComponentType, ArrayComponent>.Builder { + public Builder() { + //setActionLoreTags("Left click to edit this material.", "Right click to remove this option."); + } + + public Builder of(@NotNull ComponentType subtype) { + ArrayComponentType.this.subtype = subtype; + return this; + } + + public Builder displayList(boolean val) { + ArrayComponentType.this.displayList = val; + return this; + } + + public ArrayComponentType build() { + Validate.notNull(subtype, "Subtype cannot be null"); + return (ArrayComponentType) super.build(); + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/BooleanComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/BooleanComponentType.java new file mode 100644 index 00000000..4aea32b4 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/BooleanComponentType.java @@ -0,0 +1,59 @@ +package net.Indyuce.mmoitems.stat.component.type.builtin; + +import io.lumine.mythic.lib.MythicLib; +import net.Indyuce.mmoitems.stat.component.builtin.BooleanComponent; +import net.Indyuce.mmoitems.stat.component.model.builtin.BooleanModel; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.List; + +public class BooleanComponentType extends ComponentType { + + public MergeMecanism mergeMecanism = MergeMecanism.OR; + + @NotNull + @Override + public List editionUiFormat(BooleanModel model) { + + if (model.getValue() != null) + return Collections.singletonList(model.getValue().toString()); + + // Format boolean + return Collections.singletonList(MythicLib.plugin.getMMOConfig().decimal.format(100 * model.getChance()) + "% Chance"); + } + + @Override + public BooleanModel initialize(@NotNull Object object) { + return new BooleanModel(object); + } + + @NotNull + public static Builder toggle() { + return new BooleanComponentType().new Builder(); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTags("Left click to switch this value.", "Right click to reset this option."); + setTerminal(true); + } + + public BooleanComponentType build() { + return (BooleanComponentType) super.build(); + } + } + + public static enum MergeMecanism { + + OR, + + AND, + + /** + * This could definitely be used in a fun way... + */ + XOR, + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/DoubleComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/DoubleComponentType.java new file mode 100644 index 00000000..363d1b2f --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/DoubleComponentType.java @@ -0,0 +1,79 @@ +package net.Indyuce.mmoitems.stat.component.type.builtin; + +import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.component.builtin.DoubleComponent; +import net.Indyuce.mmoitems.stat.component.model.builtin.DoubleModel; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.jetbrains.annotations.NotNull; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class DoubleComponentType extends ComponentType { + + /** + * Are higher values of this component better or worse? Debuff stats + * should set this to false, otherwise should be true by default for + * most stats. + */ + public boolean moreIsBetter = true; + + // TODO edit with config. if none specified, fetch from MythicLib + public DecimalFormat format = new DecimalFormat("0.####"); + + @NotNull + @Override + public List editionUiFormat(DoubleModel model) { + return editionUiFormat(format, model.getFormula()); + } + + public static List editionUiFormat(DecimalFormat decFormat, NumericStatFormula formula) { + + // Uniform distribution + if (formula.isUniform()) + return Collections.singletonList("Uniform: &a" + decFormat.format(formula.getMin()) + "&7 -> &a" + decFormat.format(formula.getMax())); + + String baseFormat = "&a" + decFormat.format(formula.getBase()) + + (formula.getScale() != 0 ? " &7(+&a" + decFormat.format(formula.getScale()) + "&7/Lvl)" : ""); + + boolean spread = formula.getSpread() > 0, min = formula.hasMin(), max = formula.hasMax(); + if (!spread && !min && !max) + return Collections.singletonList(baseFormat); + + // Gaussian distribution + List list = new ArrayList<>(4); + list.add("Base Value: " + baseFormat); + if (spread) list.add("Spread: &a" + decFormat.format(formula.getSpread())); + if (min) list.add("Min: &a" + decFormat.format(formula.getMin())); + if (max) list.add("Max: &a" + decFormat.format(formula.getMax())); + return list; + } + + @Override + public DoubleModel initialize(@NotNull Object configObject) { + return new DoubleModel(new NumericStatFormula(configObject)); + } + + @NotNull + public static Builder numeric() { + return new DoubleComponentType().new Builder(); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTags("Left click to edit this number.", "Right click to remove this option."); + setTerminal(true); + } + + public Builder moreIsBetter(boolean val) { + DoubleComponentType.this.moreIsBetter = val; + return this; + } + + public DoubleComponentType build() { + return (DoubleComponentType) super.build(); + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/IntegerComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/IntegerComponentType.java new file mode 100644 index 00000000..32fd5124 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/IntegerComponentType.java @@ -0,0 +1,82 @@ +package net.Indyuce.mmoitems.stat.component.type.builtin; + +import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.component.builtin.IntegerComponent; +import net.Indyuce.mmoitems.stat.component.model.builtin.IntegerModel; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.jetbrains.annotations.NotNull; + +import java.text.DecimalFormat; +import java.util.List; + +// TODO merge with DoubleComponents? just add an option for whole numbers. +public class IntegerComponentType extends ComponentType { + + /** + * Are higher values of this component better or worse? Debuff stats + * should set this to false, otherwise should be true by default for + * most stats. + */ + public boolean moreIsBetter = true; + + /** + * Should components be displayed using roman integer format. + */ + public boolean useRoman = false; + + // TODO edit with config. if none specified, fetch from MythicLib + public DecimalFormat format = new DecimalFormat("0.####"); + + public MergeMecanism mergeMecanism = MergeMecanism.SUM; + + @NotNull + @Override + public List editionUiFormat(IntegerModel data) { + return DoubleComponentType.editionUiFormat(format, data.getFormula()); + } + + @Override + public IntegerModel initialize(@NotNull Object object) { + return new IntegerModel(new NumericStatFormula(object)); + } + + @NotNull + public static Builder numericInt() { + return new IntegerComponentType().new Builder(); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTags("Left click to edit this int.", "Right click to remove this option."); + setTerminal(true); + } + + public Builder moreIsBetter(boolean moreIsBetter) { + IntegerComponentType.this.moreIsBetter = moreIsBetter; + return this; + } + + public Builder useRoman(boolean moreIsBetter) { + IntegerComponentType.this.moreIsBetter = moreIsBetter; + return this; + } + + public Builder mergeMecanism(@NotNull MergeMecanism mergeMecanism) { + IntegerComponentType.this.mergeMecanism = mergeMecanism; + return this; + } + + public IntegerComponentType build() { + return (IntegerComponentType) super.build(); + } + } + + public static enum MergeMecanism { + + HIGHEST, + + LOWEST, + + SUM, + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ObjectComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ObjectComponentType.java new file mode 100644 index 00000000..96a2ecaf --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/ObjectComponentType.java @@ -0,0 +1,112 @@ +package net.Indyuce.mmoitems.stat.component.type.builtin; + +import net.Indyuce.mmoitems.stat.component.LoreWrapper; +import net.Indyuce.mmoitems.stat.component.builtin.ObjectComponent; +import net.Indyuce.mmoitems.stat.component.model.builtin.ObjectModel; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import net.Indyuce.mmoitems.util.Pair; +import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang.Validate; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class ObjectComponentType extends ComponentType { + private final Map> fields = new LinkedHashMap<>(); + + /** + * Not a terminal component type, but this display all its subcomponents + * on the same page nonetheless. + *

+ * TODO + */ + private boolean flattened; + + @Override + public void editionUiDisplay(LoreWrapper lore, ObjectModel model) { + throw new NotImplementedException(); + } + + public Map> getFields() { + return fields; + } + + /* + @Override + @SuppressWarnings({"unchecked", "rawtypes"}) + public void flatten(@NotNull List, StatComponent>> list, @Nullable ObjectComponent statComponent) { + + // Do not collect this item, only collect its children + fields.forEach((key, type) -> { + StatComponent subcomponent = statComponent == null ? null : statComponent.get(key); + ((ComponentType) type).flatten(list, subcomponent); + }); + } + */ + + @Override + public List>> getSubcomponents() { + List>> subcomponents = new ArrayList<>(); + this.fields.forEach((key, comp) -> subcomponents.add(Pair.of(key, comp))); + return subcomponents; + } + + @Override + public ObjectModel initialize(@NotNull Object object) { + Validate.isTrue(object instanceof ConfigurationSection, "Must be a configuration section"); + ConfigurationSection section = (ConfigurationSection) object; + + ObjectModel comp = new ObjectModel(); + + for (Map.Entry> entry : fields.entrySet()) { + Object sub = section.get(entry.getKey()); + comp.getComponents().put(entry.getKey(), entry.getValue().initialize(sub)); + } + + return comp; + } + + @NotNull + @Override + public List editionUiFormat(ObjectModel data) { + throw new NotImplementedException(); + } + + @NotNull + public static ObjectComponentType.Builder object() { + return new ObjectComponentType().new Builder(); + } + + @NotNull + public static ObjectComponentType.Builder color() { + return new ObjectComponentType().new Builder().addField("red", IntegerComponentType.numericInt().setIcon(Material.RED_WOOL).setName("Red").build()).addField("green", IntegerComponentType.numericInt().setIcon(Material.GREEN_WOOL).setName("Green").build()).addField("blue", IntegerComponentType.numericInt().setIcon(Material.BLUE_WOOL).setName("Blue").build()); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + //setActionLoreTags("Left click to edit this material.", "Right click to remove this option."); + } + + @Deprecated // TODO + public Builder setFlattened(boolean flattened) { + ObjectComponentType.this.flattened = flattened; + return this; + } + + public Builder addField(String key, ComponentType componentType) { + fields.put(key, componentType); + return this; + } + + @NotNull + public ObjectComponentType build() { + // TODO rules + return (ObjectComponentType) super.build(); + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/StringComponentType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/StringComponentType.java new file mode 100644 index 00000000..edce8d56 --- /dev/null +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/component/type/builtin/StringComponentType.java @@ -0,0 +1,38 @@ +package net.Indyuce.mmoitems.stat.component.type.builtin; + +import net.Indyuce.mmoitems.stat.component.builtin.StringComponent; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.List; + +public class StringComponentType extends ComponentType { + + @NotNull + @Override + public List editionUiFormat(StringComponent data) { + return Collections.singletonList(data.getValue()); + } + + @Override + public StringComponent initialize(@NotNull Object object) { + return new StringComponent(object.toString()); + } + + @NotNull + public static StringComponentType.Builder init() { + return new StringComponentType().new Builder(); + } + + public class Builder extends ComponentType.Builder { + public Builder() { + setActionLoreTags("Left click to edit this string.", "Right click to remove this option."); + } + + @NotNull + public StringComponentType build() { + return (StringComponentType) super.build(); + } + } +} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java index b6aced99..7e5b9470 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java @@ -31,6 +31,7 @@ import java.util.Set; * used utility class which defines the castable implementation * of the {@link Skill} interface for MMOItems. */ +@Deprecated public class AbilityData extends Skill { private final RegisteredSkill ability; @NotNull diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java index 75220a74..08b0b4b0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/DoubleData.java @@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.stat.data; import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; +@Deprecated public class DoubleData implements StatData, Mergeable { private double value; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/dynamic/DynamicStatData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/dynamic/DynamicStatData.java index 27942861..2fc456b0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/dynamic/DynamicStatData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/dynamic/DynamicStatData.java @@ -1,11 +1,15 @@ package net.Indyuce.mmoitems.stat.data.dynamic; +import io.lumine.mythic.lib.util.annotation.NotUsed; + +@Deprecated +@NotUsed public interface DynamicStatData { - /* - * dynamic stat data is used when all the mmoitems are in the player - * inventory and when MMOItems calculates all passive effects which the - * items must apply on the player - */ - // TODO + /* + * dynamic stat data is used when all the mmoitems are in the player + * inventory and when MMOItems calculates all passive effects which the + * items must apply on the player + */ + // TODO } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityData.java index f39a251f..1d409fc7 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityData.java @@ -15,6 +15,10 @@ import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.stat.data.AbilityData; +/** + * @deprecated TODO replace using RandomComponent's + */ +@Deprecated public class RandomAbilityData { private final RegisteredSkill ability; private final TriggerType triggerType; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityListData.java index 601cbeb8..d6ef1149 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomAbilityListData.java @@ -8,6 +8,10 @@ import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.AbilityListData; import net.Indyuce.mmoitems.stat.data.type.StatData; +/** + * @deprecated TODO replace using RandomComponent's + */ +@Deprecated public class RandomAbilityListData implements RandomStatData { private final Set abilities = new LinkedHashSet<>(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomElementListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomElementListData.java index e4d35cc5..3cf33986 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomElementListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomElementListData.java @@ -17,6 +17,10 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +/** + * @deprecated TODO replace using RandomComponent's + */ +@Deprecated public class RandomElementListData implements RandomStatData, UpdatableRandomStatData { private final Map, NumericStatFormula> stats = new LinkedHashMap<>(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomEnchantListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomEnchantListData.java index bf9f89c5..ac2f7289 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomEnchantListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomEnchantListData.java @@ -13,6 +13,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +/** + * @deprecated TODO replace using RandomComponent's + */ +@Deprecated public class RandomEnchantListData implements RandomStatData { private final Map enchants = new HashMap<>(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectData.java index 64a1d571..6cfd9593 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectData.java @@ -9,6 +9,10 @@ import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.stat.data.PotionEffectData; +/** + * @deprecated TODO replace using RandomComponent's + */ +@Deprecated public class RandomPotionEffectData { private final PotionEffectType type; private final NumericStatFormula duration, amplifier; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectListData.java index d877ff96..6ab93c60 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomPotionEffectListData.java @@ -15,6 +15,10 @@ import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import org.bukkit.potion.PotionEffectType; +/** + * @deprecated TODO replace using RandomComponent's + */ +@Deprecated public class RandomPotionEffectListData implements RandomStatData { private final List effects = new ArrayList<>(); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRequiredLevelData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRequiredLevelData.java index 3934505c..0c7dd414 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRequiredLevelData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRequiredLevelData.java @@ -8,7 +8,10 @@ import net.Indyuce.mmoitems.stat.data.type.StatData; /** * Used by the item level restriction as well as attribute * and profession item requirements for MMOCore and AureliumSkills + * + * @deprecated TODO replace using RandomComponent's */ +@Deprecated public class RandomRequiredLevelData extends NumericStatFormula { public RandomRequiredLevelData(Object object) { super(object); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRestoreData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRestoreData.java index 1a78b0d8..bd1613f6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRestoreData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomRestoreData.java @@ -8,31 +8,34 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.stat.data.RestoreData; import net.Indyuce.mmoitems.stat.data.type.StatData; +/** + * @deprecated TODO replace using RandomComponent's + */ public class RandomRestoreData implements RandomStatData { - private final NumericStatFormula health, food, saturation; + private final NumericStatFormula health, food, saturation; - public RandomRestoreData(ConfigurationSection config) { - Validate.notNull(config, "Could not load restore config"); + public RandomRestoreData(ConfigurationSection config) { + Validate.notNull(config, "Could not load restore config"); - health = config.contains("health") ? new NumericStatFormula(config) : NumericStatFormula.ZERO; - food = config.contains("food") ? new NumericStatFormula(config) : NumericStatFormula.ZERO; - saturation = config.contains("saturation") ? new NumericStatFormula(config) : NumericStatFormula.ZERO; - } + health = config.contains("health") ? new NumericStatFormula(config) : NumericStatFormula.ZERO; + food = config.contains("food") ? new NumericStatFormula(config) : NumericStatFormula.ZERO; + saturation = config.contains("saturation") ? new NumericStatFormula(config) : NumericStatFormula.ZERO; + } - public NumericStatFormula getHealth() { - return health; - } + public NumericStatFormula getHealth() { + return health; + } - public NumericStatFormula getFood() { - return food; - } + public NumericStatFormula getFood() { + return food; + } - public NumericStatFormula getSaturation() { - return saturation; - } + public NumericStatFormula getSaturation() { + return saturation; + } - @Override - public RestoreData randomize(MMOItemBuilder builder) { - return new RestoreData(health.calculate(builder.getLevel()), food.calculate(builder.getLevel()), saturation.calculate(builder.getLevel())); - } + @Override + public RestoreData randomize(MMOItemBuilder builder) { + return new RestoreData(health.calculate(builder.getLevel()), food.calculate(builder.getLevel()), saturation.calculate(builder.getLevel())); + } } \ No newline at end of file diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomStatData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomStatData.java index 92234740..c9c06cba 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomStatData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/random/RandomStatData.java @@ -8,13 +8,14 @@ import net.Indyuce.mmoitems.stat.data.type.StatData; * are the first instances called when loading gen templates from config files. * * @author cympe + * @deprecated TODO replace using RandomComponent's */ public interface RandomStatData { /** * @param builder The builder of the random item being generated * @return A random stat data instance which will then be merged onto the - * base item template + * base item template */ S randomize(MMOItemBuilder builder); } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/BooleanStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/BooleanStat.java index a85dc5a7..95006f44 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/BooleanStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/BooleanStat.java @@ -1,157 +1,166 @@ package net.Indyuce.mmoitems.stat.type; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import io.lumine.mythic.lib.MythicLib; +import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; +import io.lumine.mythic.lib.api.util.AltChar; +import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.api.edition.StatEdition; +import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; +import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; +import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.component.type.builtin.BooleanComponentType; +import net.Indyuce.mmoitems.stat.data.BooleanData; +import net.Indyuce.mmoitems.stat.data.random.RandomBooleanData; +import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; - -import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.util.MMOUtils; -import net.Indyuce.mmoitems.api.edition.StatEdition; -import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; -import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; -import net.Indyuce.mmoitems.gui.edition.EditionInventory; -import net.Indyuce.mmoitems.stat.data.BooleanData; -import net.Indyuce.mmoitems.stat.data.random.RandomBooleanData; -import io.lumine.mythic.lib.api.item.ItemTag; -import io.lumine.mythic.lib.api.util.AltChar; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + public class BooleanStat extends ItemStat { - public BooleanStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) { - super(id, mat, name, lore, types, materials); - } + @Deprecated + public BooleanStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) { + this(id, mat, name, MMOUtils.append(lore), types, materials); + } - @Override - public RandomBooleanData whenInitialized(Object object) { + public BooleanStat(String id, Material mat, String name, String lore, String[] types, Material... materials) { + super(id, types, materials); - if (object instanceof Boolean) - return new RandomBooleanData((boolean) object); + setComponentType(BooleanComponentType.toggle() + .setName(name) + .setIcon(mat) + .trimLore(lore) + .build()); + } - if (object instanceof Number) - return new RandomBooleanData(Double.parseDouble(object.toString())); + @Override + public RandomBooleanData whenInitialized(Object object) { - throw new IllegalArgumentException("Must specify a number (chance) or true/false"); - } + if (object instanceof Boolean) + return new RandomBooleanData((boolean) object); - @Override - public void whenApplied(@NotNull ItemStackBuilder item, @NotNull BooleanData data) { + if (object instanceof Number) + return new RandomBooleanData(Double.parseDouble(object.toString())); - // Only if enabled yo - if (data.isEnabled()) { + throw new IllegalArgumentException("Must specify a number (chance) or true/false"); + } - // Add those - item.addItemTag(getAppliedNBT(data)); + @Override + public void whenApplied(@NotNull ItemStackBuilder item, @NotNull BooleanData data) { - // Show in lore - item.getLore().insert(getPath(), getGeneralStatFormat()); - } - } + // Only if enabled yo + if (data.isEnabled()) { - @NotNull - @Override - public ArrayList getAppliedNBT(@NotNull BooleanData data) { + // Add those + item.addItemTag(getAppliedNBT(data)); - // Create Fresh - ArrayList ret = new ArrayList<>(); + // Show in lore + item.getLore().insert(getPath(), getGeneralStatFormat()); + } + } - if (data.isEnabled()) { + @NotNull + @Override + public ArrayList getAppliedNBT(@NotNull BooleanData data) { - // Add sole tag - ret.add(new ItemTag(getNBTPath(), true)); - } + // Create Fresh + ArrayList ret = new ArrayList<>(); - // Return thay - return ret; - } + if (data.isEnabled()) { - @Override - public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { - if (event.getAction() == InventoryAction.PICKUP_ALL) { - inv.getEditedSection().set(getPath(), inv.getEditedSection().getBoolean(getPath()) ? null : true); - inv.registerTemplateEdition(); - } + // Add sole tag + ret.add(new ItemTag(getNBTPath(), true)); + } - else if (event.getAction() == InventoryAction.PICKUP_HALF) - new StatEdition(inv, this).enable("Write in the chat the probability you want (a percentage)"); - } + // Return thay + return ret; + } - @Override - public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { + @Override + public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { + if (event.getAction() == InventoryAction.PICKUP_ALL) { + inv.getEditedSection().set(getPath(), inv.getEditedSection().getBoolean(getPath()) ? null : true); + inv.registerTemplateEdition(); + } else if (event.getAction() == InventoryAction.PICKUP_HALF) + new StatEdition(inv, this).enable("Write in the chat the probability you want (a percentage)"); + } - double probability = MMOUtils.parseDouble(message); - Validate.isTrue(probability >= 0 && probability <= 100, "Chance must be between 0 and 100"); + @Override + public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { - inv.getEditedSection().set(getPath(), probability / 100); - inv.registerTemplateEdition(); - inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + getName() + " successfully changed to " + ChatColor.GREEN - + MythicLib.plugin.getMMOConfig().decimal.format(probability) + "% Chance" + ChatColor.GRAY + "."); - } + double probability = MMOUtils.parseDouble(message); + Validate.isTrue(probability >= 0 && probability <= 100, "Chance must be between 0 and 100"); - @Override - public void whenLoaded(@NotNull ReadMMOItem mmoitem) { + inv.getEditedSection().set(getPath(), probability / 100); + inv.registerTemplateEdition(); + inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + getName() + " successfully changed to " + ChatColor.GREEN + + MythicLib.plugin.getMMOConfig().decimal.format(probability) + "% Chance" + ChatColor.GRAY + "."); + } - // Find the useful tags - ArrayList relevantTags = new ArrayList<>(); + @Override + public void whenLoaded(@NotNull ReadMMOItem mmoitem) { - // That one is useful - if (mmoitem.getNBT().hasTag(getNBTPath())) - relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.BOOLEAN)); + // Find the useful tags + ArrayList relevantTags = new ArrayList<>(); - BooleanData data = (BooleanData) getLoadedNBT(relevantTags); + // That one is useful + if (mmoitem.getNBT().hasTag(getNBTPath())) + relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.BOOLEAN)); - // Success? - if (data != null) { + BooleanData data = (BooleanData) getLoadedNBT(relevantTags); - // Set the data if it was successful - mmoitem.setData(this, data); - } - } + // Success? + if (data != null) { - @Nullable - @Override - public BooleanData getLoadedNBT(@NotNull ArrayList storedTags) { + // Set the data if it was successful + mmoitem.setData(this, data); + } + } - // Find relevant tag - ItemTag encoded = ItemTag.getTagAtPath(getNBTPath(), storedTags); + @Nullable + @Override + public BooleanData getLoadedNBT(@NotNull ArrayList storedTags) { - // Found it? - if (encoded != null) { + // Find relevant tag + ItemTag encoded = ItemTag.getTagAtPath(getNBTPath(), storedTags); - // Well read it! - return new BooleanData((Boolean) encoded.getValue()); - } + // Found it? + if (encoded != null) { - return null; - } + // Well read it! + return new BooleanData((Boolean) encoded.getValue()); + } - @Override - public void whenDisplayed(List lore, Optional statData) { + return null; + } - if (statData.isPresent()) { - final double chance = statData.get().getChance(); - lore.add(ChatColor.GRAY + "Current Value: " + (chance >= 1 ? ChatColor.GREEN + "True" - : chance <= 0 ? ChatColor.RED + "False" : ChatColor.GREEN + MythicLib.plugin.getMMOConfig().decimal.format(chance * 100) + "% Chance")); + @Override + public void whenDisplayed(List lore, Optional statData) { - } else - lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "False"); + if (statData.isPresent()) { + final double chance = statData.get().getChance(); + lore.add(ChatColor.GRAY + "Current Value: " + (chance >= 1 ? ChatColor.GREEN + "True" + : chance <= 0 ? ChatColor.RED + "False" : ChatColor.GREEN + MythicLib.plugin.getMMOConfig().decimal.format(chance * 100) + "% Chance")); - lore.add(""); - lore.add(ChatColor.YELLOW + AltChar.listDash + " Left click to switch this value."); - lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to choose a probability to have this option."); - } + } else + lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "False"); - @NotNull - @Override - public BooleanData getClearStatData() { - return new BooleanData(false); - } + lore.add(""); + lore.add(ChatColor.YELLOW + AltChar.listDash + " Left click to switch this value."); + lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to choose a probability to have this option."); + } + + @NotNull + @Override + public BooleanData getClearStatData() { + return new BooleanData(false); + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java index 9301d71b..3608647c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/DoubleStat.java @@ -17,6 +17,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.component.type.builtin.DoubleComponentType; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo; @@ -37,26 +38,36 @@ import java.util.Optional; public class DoubleStat extends ItemStat implements Upgradable, Previewable { - private final boolean moreIsBetter; - private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.####"); + public DoubleStat(String id, Material mat, String name, String lore) { + this(id, mat, name, lore, new String[]{"!miscellaneous", "!block", "all"}, true); + } + + public DoubleStat(String id, Material mat, String name, String lore, String[] types, boolean moreIsBetter, Material... materials) { + super(id, types, materials); + + setComponentType(DoubleComponentType.numeric() + .moreIsBetter(moreIsBetter) + .setName(name) + .setIcon(mat) + .trimLore(lore) + .build()); + } + + @Deprecated public DoubleStat(String id, Material mat, String name, String[] lore) { this(id, mat, name, lore, new String[]{"!miscellaneous", "!block", "all"}, true); } - public DoubleStat(String id, Material mat, String name, String lore) { - this(id, mat, name, MMOUtils.trimString(LORE_LINE_WIDTH, lore), new String[]{"!miscellaneous", "!block", "all"}, true); - } - + @Deprecated public DoubleStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) { this(id, mat, name, lore, types, true, materials); } + @Deprecated public DoubleStat(String id, Material mat, String name, String[] lore, String[] types, boolean moreIsBetter, Material... materials) { - super(id, mat, name, lore, types, materials); - - this.moreIsBetter = moreIsBetter; + this(id, mat, name, MMOUtils.append(lore), types, moreIsBetter, materials); } /** @@ -78,8 +89,9 @@ public class DoubleStat extends ItemStat impleme *

* However, it's not impossible for a stat to be evil instead, who knows? */ + @Deprecated public boolean moreIsBetter() { - return moreIsBetter; + return ((DoubleComponentType) getComponentType()).moreIsBetter; } @Override @@ -126,7 +138,7 @@ public class DoubleStat extends ItemStat impleme // Display in lore if (value != 0 || upgradeShift != 0) { - String loreInsert = formatPath(getId(), getGeneralStatFormat(), moreIsBetter, value * multiplyWhenDisplaying()); + String loreInsert = formatPath(getId(), getGeneralStatFormat(), moreIsBetter(), value * multiplyWhenDisplaying()); if (upgradeShift != 0) loreInsert += UpgradeTemplate.getUpgradeChangeSuffix(plus(true, upgradeShift * multiplyWhenDisplaying()) + (MythicLib.plugin.getMMOConfig().decimals.format(upgradeShift * multiplyWhenDisplaying())), !isGood(upgradeShift * multiplyWhenDisplaying())); item.getLore().insert(getPath(), loreInsert); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java index 7f0cfd99..56d1be09 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/FakeElementalStat.java @@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.HasCategory; +import net.Indyuce.mmoitems.stat.behaviour.InternalStat; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.util.ElementStatType; import org.bukkit.Material; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemRestriction.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemRestriction.java deleted file mode 100644 index 883cfbde..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemRestriction.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.Indyuce.mmoitems.stat.type; - -import net.Indyuce.mmoitems.api.player.RPGPlayer; -import io.lumine.mythic.lib.api.item.NBTItem; - -/** - * Stats which implement an item restriction. They are automatically collected - * in a list when registered in the StatManager. Lets other plugins implement - * stats which rely on item restrictions without having to use Bukkit events! - * - * @author cympe - * - */ -public interface ItemRestriction { - - /** - * @param player Player trying to use an item - * @param item The item being checked - * @param message Difference between an active and a passive check: if the - * check is active (message boolean set to true), the plugin - * should send a message to the player if he can't use the - * item for eg when he tries to equip the item. If the check - * is passive, no message needs to be sent (when the plugin - * internally needs some similar check) - * @return False if the item cannot be used - */ - boolean canUse(RPGPlayer player, NBTItem item, boolean message); - - /** - * Usually, item restrictions are checked when equipping - * an item, and prevent the item being equipped if they fail that moment. - *

- * Setting this to true will allow items equip anyway - * and check with every use that the conditions for their usage - * are met. - */ - default boolean isDynamic() { return false; } -} diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java index e7fcee9e..24fc83d6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/ItemStat.java @@ -10,9 +10,9 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.annotation.VersionDependant; import net.Indyuce.mmoitems.stat.category.StatCategory; +import net.Indyuce.mmoitems.stat.component.type.ComponentType; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryClickEvent; @@ -23,6 +23,10 @@ import org.jetbrains.annotations.Nullable; import java.util.*; public abstract class ItemStat, S extends StatData> { + + private ComponentType componentType; + + @NotNull private final String id, name, configPath, nbtPath; @NotNull @@ -56,7 +60,13 @@ public abstract class ItemStat, S extends StatData> * @param types Compatible types. See {@link #isCompatible(Type)} * @param materials Materials compatible with the item stat (e.g Shield Pattern), any if empty */ - public ItemStat(@NotNull String id, @NotNull Material material, @NotNull String name, @Nullable String[] lore, @Nullable String[] types, @Nullable Material... materials) { + @Deprecated + public ItemStat(@NotNull String id, + @NotNull Material material, + @NotNull String name, + @Nullable String[] lore, + @Nullable String[] types, + @Nullable Material... materials) { this.id = id; this.material = material; this.lore = lore == null ? new String[0] : lore; @@ -72,12 +82,34 @@ public abstract class ItemStat, S extends StatData> final VersionDependant implVersion = getClass().getAnnotation(VersionDependant.class); if (MythicLib.plugin.getVersion().isUnder(implVersion.version())) disable(); } + } - // Backwards compatibility - if (getClass().isAnnotationPresent(net.Indyuce.mmoitems.util.VersionDependant.class)) { - final net.Indyuce.mmoitems.util.VersionDependant implVersion = getClass().getAnnotation(net.Indyuce.mmoitems.util.VersionDependant.class); + public ItemStat(@NotNull String id, @Nullable String[] types, @Nullable Material... materials) { + this.id = id; + this.compatibleTypes = types == null ? new ArrayList<>() : Arrays.asList(types); + this.compatibleMaterials = materials == null ? new ArrayList<>() : Arrays.asList(materials); + + this.configPath = id.toLowerCase().replace("_", "-"); + this.nbtPath = "MMOITEMS_" + id; + + // Version dependency + if (getClass().isAnnotationPresent(VersionDependant.class)) { + final VersionDependant implVersion = getClass().getAnnotation(VersionDependant.class); if (MythicLib.plugin.getVersion().isUnder(implVersion.version())) disable(); } + + // Backwards comp + this.lore = new String[]{"Lorem ipsum dolor sit amet", "this lore is no longer used"}; + this.material = Material.BARRIER; + this.name = "Awesome Stat"; + } + + public void setComponentType(ComponentType componentType) { + this.componentType = componentType; + } + + public ComponentType getComponentType() { + return componentType; } /** @@ -175,7 +207,6 @@ public abstract class ItemStat, S extends StatData> protected String generalStatFormat; public void readTranslationFile(@NotNull ConfigurationSection translationFile) { - Bukkit.broadcastMessage("reading translation for " + getPath()); String path = getPath(); Object obj = translationFile.get(path); if (obj == null) obj = translationFile.get(getLegacyTranslationPath()); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/RequiredLevelStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/RequiredLevelStat.java index 923c511a..bcb875a8 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/RequiredLevelStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/RequiredLevelStat.java @@ -6,6 +6,8 @@ import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.util.NumericStatFormula; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.ItemRestriction; import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.RequiredLevelData; import net.Indyuce.mmoitems.stat.data.random.RandomRequiredLevelData; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringStat.java index 1560a462..90e33068 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringStat.java @@ -9,7 +9,9 @@ import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; +import net.Indyuce.mmoitems.stat.component.type.builtin.StringComponentType; import net.Indyuce.mmoitems.stat.data.StringData; +import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.event.inventory.InventoryAction; @@ -22,8 +24,20 @@ import java.util.List; import java.util.Optional; public class StringStat extends ItemStat { + + @Deprecated public StringStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) { - super(id, mat, name, lore, types, materials); + this(id, mat, name, MMOUtils.append(lore), types, materials); + } + + public StringStat(String id, Material mat, String name, String lore, String[] types, Material... materials) { + super(id, types, materials); + + setComponentType(StringComponentType.init() + .setIcon(mat) + .setName(name) + .trimLore(lore) + .build()); } @Override diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java index c111f3f2..ead2aaaa 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java @@ -49,24 +49,43 @@ public class MMOUtils { continue; } - StringBuilder currentLine = new StringBuilder(); + StringBuilder currLine = new StringBuilder(); + int currLength = 0; for (String word : input.split(" ")) { - if (!currentLine.isEmpty()) currentLine.append(" "); - currentLine.append(word); - if (currentLine.length() > charactersPerLine || word.endsWith("\n")) { - list.add(currentLine.toString()); // Return line - currentLine.setLength(0); // Empty current line + if (currLength > 0) currLine.append(" "); + + // Append + currLine.append(word); + currLength += word.length(); + + if (currLength > charactersPerLine || word.endsWith("\n")) { + String finalLine = currLine.toString(); + String lastColors = ChatColor.getLastColors(finalLine); + + list.add(finalLine); // Return line + currLine.setLength(0); // Empty current line + currLength = 0; // Reset counter + currLine.append(lastColors); // Remember color } } // Add last line (sometimes not necessary) - if (!currentLine.isEmpty()) list.add(currentLine.toString()); + if (currLength > 0) list.add(currLine.toString()); } return list.toArray(new String[0]); } + public static String append(String... strings) { + StringBuilder builder = new StringBuilder(); + for (String str : strings) { + if (!builder.isEmpty()) builder.append(" "); + builder.append(str); + } + return builder.toString(); + } + @NotNull public static ItemStack readIcon(@NotNull String stringInput) { Validate.notNull(stringInput, "Input must not be null"); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Pair.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Pair.java index f9ac317b..c922558b 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Pair.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/Pair.java @@ -1,6 +1,6 @@ package net.Indyuce.mmoitems.util; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Objects; @@ -8,13 +8,13 @@ public class Pair { private final K key; private final V value; - public Pair(@NotNull K var1, @NotNull V var2) { + public Pair(@Nullable K var1, @Nullable V var2) { this.key = var1; this.value = var2; } - public static Pair of(@NotNull K var0, @NotNull V var1) { - return new Pair(var0, var1); + public static Pair of(@Nullable K var0, @Nullable V var1) { + return new Pair<>(var0, var1); } public K getKey() { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/VersionDependant.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/VersionDependant.java deleted file mode 100644 index 7067314b..00000000 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/VersionDependant.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.Indyuce.mmoitems.util; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * @see net.Indyuce.mmoitems.stat.annotation.VersionDependant - * @deprecated Moved to another class - */ -@Deprecated -@Retention(RetentionPolicy.RUNTIME) -public @interface VersionDependant { - - public int[] version(); -} diff --git a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java index cee3ada5..97698e13 100644 --- a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java +++ b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/reforging/RFGKeepGems.java @@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.stat.data.GemSocketsData; import net.Indyuce.mmoitems.stat.data.GemstoneData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.StatData; -import net.Indyuce.mmoitems.stat.type.GemStoneStat; +import net.Indyuce.mmoitems.stat.behaviour.GemStoneStat; import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.StatHistory; import org.bukkit.event.EventHandler; diff --git a/pom.xml b/pom.xml index 82887d44..1e3fd1eb 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,8 @@ annotations 23.0.0 provided + true +