From 5bda049802f3c982b1c1ae21fb408d8988e717ff Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 25 Oct 2024 00:05:18 +0200 Subject: [PATCH] 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 cd3f15f2..080d74d7 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", true, 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 90be3363..8d999e5a 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