From 91072e4cf97d16147051f781165ca2fc7e306ac1 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:37:17 +0100 Subject: [PATCH 1/3] Add `crafting-recipe` to tiers adds crafting-recipe to tier crystals, like exists in sets, shards, ecoitems etc. Refactored what seems to be dated crafting logic into the logic shared in other plugins and craftable items. I have tested this and appears to be working as expected and no console errors. --- .../com/willfp/ecoarmor/upgrades/Tier.kt | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt index b5829495..96077d4c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt @@ -5,6 +5,7 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.display.Display import com.willfp.eco.core.items.CustomItem import com.willfp.eco.core.items.Items +import com.willfp.eco.core.recipe.Recipes import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe import com.willfp.eco.core.registry.Registrable import com.willfp.eco.util.StringUtils @@ -43,11 +44,6 @@ class Tier( */ val crystal: ItemStack - /** - * The crafting recipe to make the crystal. - */ - val crystalRecipe: ShapedCraftingRecipe? - /** * Item properties. */ @@ -98,28 +94,17 @@ class Tier( ).register() if (this.craftable) { - val recipeOut = out.clone() - recipeOut.amount = this.config.getInt("crystal.giveAmount") - val builder = ShapedCraftingRecipe.builder(plugin, "upgrade_crystal_$id") - .setOutput(recipeOut) - val recipeStrings: List = this.config.getStrings("crystal.recipe") - CustomItem(plugin.namespacedKeyFactory.create("upgrade_crystal_$id"), { test: ItemStack? -> - if (test == null) { - return@CustomItem false - } - if (getCrystalTier(test) == null) { - return@CustomItem false - } - this == getCrystalTier(test) - }, out).register() - for (i in 0..8) { - builder.setRecipePart(i, Items.lookup(recipeStrings[i])) + val recipeOut = out.clone().apply { + amount = config.getInt("crystal.giveAmount") } - crystalRecipe = builder.build() - crystalRecipe.register() - } else { - crystalRecipe = null - } + Recipes.createAndRegisterRecipe( + plugin, + "upgrade_crystal_$id", + recipeOut, + config.getStrings("crystal.recipe"), + config.getStringOrNull("crystal.crafting-permission") + ) + } else null } /** From dce3468ec5cb1eb42e7221212f7f2d8d5955b0c8 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:44:22 +0100 Subject: [PATCH 2/3] update examples --- .../src/main/resources/sets/_example.yml | 137 +++++++++++------- .../src/main/resources/tiers/_example.yml | 46 +++--- 2 files changed, 110 insertions(+), 73 deletions(-) diff --git a/eco-core/core-plugin/src/main/resources/sets/_example.yml b/eco-core/core-plugin/src/main/resources/sets/_example.yml index 53ca8f54..fefa46b4 100644 --- a/eco-core/core-plugin/src/main/resources/sets/_example.yml +++ b/eco-core/core-plugin/src/main/resources/sets/_example.yml @@ -4,7 +4,8 @@ # including in subfolders if you want to organize your set configs # _example.yml is not loaded. -conditions: [] +# The effects of the set (i.e. the functionality) +# See here: https://plugins.auxilor.io/effects/configuring-an-effect effects: - id: damage_multiplier args: @@ -13,6 +14,9 @@ effects: - melee_attack - bow_attack - trident_attack + - + # The effects of the set (i.e. the functionality) + # See here: https://plugins.auxilor.io/effects/configuring-an-effect advancedEffects: - id: damage_multiplier args: @@ -26,81 +30,97 @@ advancedEffects: multiplier: 0.9 triggers: - take_damage + sounds: equip: - enabled: false - sound: "" + enabled: false # If a sound should play when armor is equipped. + sound: "" # The sound to play, sounds: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html volume: 1 pitch: 1 advancedEquip: - enabled: false - sound: "" + enabled: false # If a sound should play when advanced armor is equipped. + sound: "" # The sound to play, sounds: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html volume: 1 pitch: 1 unequip: - enabled: false - sound: "" + enabled: false # If a sound should play when armor is unequipped. + sound: "" # The sound to play, sounds: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html volume: 1 pitch: 1 -advancedLore: + +advancedLore: # Lore to be added to the armor piece when it has been advanced. - '' - "&lADVANCED BONUS" - "&8» &6Take 10% less damage" - "&8&oRequires full set to be worn" + shard: - item: prismarine_shard unbreaking:1 hide_enchants - name: "Advancement Shard: &cReaper" - lore: + item: prismarine_shard unbreaking:1 hide_enchants # The shard item, read more here: https://plugins.auxilor.io/all-plugins/the-item-lookup-system + name: "Advancement Shard: &cReaper" # The in-game name of the shard. + lore: # The lore shown in-game on the shard. Set to `lore: []` to remove lore. - "&8Drop this onto &cReaper Armor" - "&8to make it Advanced." - craftable: false - crafting-permission: "permission" # (Optional: Require a permission to craft this item) - recipe: + craftable: false # If the shard is craftable + crafting-permission: "permission" # (Optional) The permission required to craft this recipe. + recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#crafting-recipes - prismarine_shard - ecoarmor:set_reaper_helmet - prismarine_shard + - ecoarmor:set_reaper_chestplate - nether_star - ecoarmor:set_reaper_leggings + - prismarine_shard - ecoarmor:set_reaper_boots - prismarine_shard + helmet: - item: leather_helmet color:#303030 hide_dye - name: "&cReaper Helmet" - advancedName: "Advanced&c Reaper Helmet" - effectiveDurability: 2048 - effects: [] - advancedEffects: [] - conditions: [] - lore: + item: leather_helmet color:#303030 hide_dye # https://plugins.auxilor.io/all-plugins/the-item-lookup-system + name: "&cReaper Helmet" # The name shown in-game. + advancedName: "Advanced&c Reaper Helmet" # The advanced name shown in-game. + lore: # The lore shown in-game. Set to `lore: []` to remove lore. - "&c&lREAPER SET BONUS" - "&8» &cDeal 25% more damage" - "&8&oRequires full set to be worn" - '' - "&fTier: %tier%" - "&8&oUpgrade with an Upgrade Crystal" - craftable: true - crafting-permission: "permission" # (Optional: Require a permission to craft this item) - defaultTier: default - recipe: + craftable: true # If the armor piece is craftable + crafting-permission: "permission" # (Optional) The permission required to craft this recipe. + recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#crafting-recipes - ecoitems:armor_core ? air - nether_star - ecoitems:armor_core ? air + - nether_star - netherite_helmet - nether_star + - air - nether_star - air + defaultTier: default # The default tier of the armor + + # The actual item durability isn't set (because it can't be changed), but instead + # this scales how quickly the item wears to act as if it had this durability. + # For example, let's say the actual durability is 350, but you set this to 700, + # it will wear at half the normal rate. + + effectiveDurability: 2048 # Optional, set the durability + + # The effects of the item (i.e. the functionality) + # See here: https://plugins.auxilor.io/effects/configuring-an-effect + effects: [] + advancedEffects: [] + + # The conditions required for the effects to activate + conditions: [] # The conditions for the effects to be ru + chestplate: item: leather_chestplate color:#303030 hide_dye name: "&cReaper Chestplate" advancedName: "Advanced&c Reaper Chestplate" - effectiveDurability: 2048 - effects: [] - advancedEffects: [] - conditions: [] lore: - "&c&lREAPER SET BONUS" - "&8» &cDeal 25% more damage" @@ -109,27 +129,29 @@ chestplate: - "&fTier: %tier%" - "&8&oUpgrade with an Upgrade Crystal" craftable: true - crafting-permission: "permission" # (Optional: Require a permission to craft this item) # (Optional: Require a permission to craft this item) - defaultTier: default + crafting-permission: "permission" recipe: - ecoitems:armor_core ? air - nether_star - ecoitems:armor_core ? air + - nether_star - netherite_chestplate - nether_star + - air - nether_star - air -elytra: - item: elytra - name: "&cReaper Elytra" - advancedName: "Advanced&c Reaper Elytra" + defaultTier: default effectiveDurability: 2048 effects: [] advancedEffects: [] - crafting-permission: "permission" # (Optional: Require a permission to craft this item) conditions: [] + +elytra: + item: elytra + name: "&cReaper Elytra" + advancedName: "Advanced&c Reaper Elytra" lore: - "&c&lREAPER SET BONUS" - "&8» &cDeal 25% more damage" @@ -138,25 +160,29 @@ elytra: - "&fTier: %tier%" - "&8&oUpgrade with an Upgrade Crystal" craftable: true - defaultTier: default + crafting-permission: "permission" recipe: - ecoitems:armor_core ? air - nether_star - ecoitems:armor_core ? air + - nether_star - elytra - nether_star + - air - nether_star - air -leggings: - item: leather_leggings color:#303030 hide_dye - name: "&cReaper Leggings" - advancedName: "Advanced&c Reaper Leggings" + defaultTier: default effectiveDurability: 2048 effects: [] advancedEffects: [] conditions: [] + +leggings: + item: leather_leggings color:#303030 hide_dye + name: "&cReaper Leggings" + advancedName: "Advanced&c Reaper Leggings" lore: - "&c&lREAPER SET BONUS" - "&8» &cDeal 25% more damage" @@ -165,26 +191,29 @@ leggings: - "&fTier: %tier%" - "&8&oUpgrade with an Upgrade Crystal" craftable: true - crafting-permission: "permission" # (Optional: Require a permission to craft this item) - defaultTier: default + crafting-permission: "permission" recipe: - ecoitems:armor_core ? air - nether_star - ecoitems:armor_core ? air + - nether_star - netherite_leggings - nether_star + - air - nether_star - air -boots: - item: leather_boots color:#303030 hide_dye - name: "&cReaper Boots" - advancedName: "Advanced&c Reaper Boots" + defaultTier: default effectiveDurability: 2048 effects: [] advancedEffects: [] conditions: [] + +boots: + item: leather_boots color:#303030 hide_dye + name: "&cReaper Boots" + advancedName: "Advanced&c Reaper Boots" lore: - "&c&lREAPER SET BONUS" - "&8» &cDeal 25% more damage" @@ -193,15 +222,21 @@ boots: - "&fTier: %tier%" - "&8&oUpgrade with an Upgrade Crystal" craftable: true - crafting-permission: "permission" # (Optional: Require a permission to craft this item) - defaultTier: default + crafting-permission: "permission" recipe: - ecoitems:armor_core ? air - nether_star - ecoitems:armor_core ? air + - nether_star - netherite_boots - nether_star + - air - nether_star - - air \ No newline at end of file + - air + defaultTier: default + effectiveDurability: 2048 + effects: [] + advancedEffects: [] + conditions: [] \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/tiers/_example.yml b/eco-core/core-plugin/src/main/resources/tiers/_example.yml index b05e9cf5..6f960056 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/_example.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/_example.yml @@ -5,14 +5,22 @@ # _example.yml is not loaded. id: netherite -display: "&c&lNETHERITE" -requiresTiers: - - diamond +display: "&c&lNETHERITE" # The display in-game +requiresTiers: # If this tier requires a prior tier + - diamond # Tier ID + - iron crystal: - item: end_crystal - name: "&cNetherite Upgrade Crystal" - craftable: true - recipe: + item: end_crystal # The crystal item, read more here: https://plugins.auxilor.io/all-plugins/the-item-lookup-system + name: "&cNetherite Upgrade Crystal" # The name shown in-game. + lore: # The lore shown in-game. Set to `lore: []` to remove lore. + - "&8Drop this onto an armor piece" + - "&8to set its tier to:" + - "&c&lNETHERITE" + - '' + - "&8&oRequires the armor to already have Diamond tier" + craftable: true # If the armor piece is craftable + crafting-permission: "permission" # (Optional) The permission required to craft this recipe. + recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins/the-item-lookup-system#crafting-recipes - air - netherite_ingot - air @@ -22,22 +30,16 @@ crystal: - air - netherite_ingot - air - giveAmount: 1 - lore: - - "&8Drop this onto an armor piece" - - "&8to set its tier to:" - - "&c&lNETHERITE" - - '' - - "&8&oRequires the armor to already have Diamond tier" + giveAmount: 1 # Optional, set the amount of items to give in the recipe properties: helmet: - armor: 3 - toughness: 3 - knockbackResistance: 1 - speedPercentage: 0 - attackSpeedPercentage: 0 - attackDamagePercentage: 0 - attackKnockbackPercentage: 0 + armor: 3 # The armor attribute + toughness: 3 # the toughness attribute + knockbackResistance: 1 # The knockback resistance attribute + speedPercentage: 0 # The movement speed attribute + attackSpeedPercentage: 0 # The attack speed attribute + attackDamagePercentage: 0 # The damage attribute + attackKnockbackPercentage: 0 # The knockback attribute chestplate: armor: 8 toughness: 3 @@ -69,4 +71,4 @@ properties: speedPercentage: 0 attackSpeedPercentage: 0 attackDamagePercentage: 0 - attackKnockbackPercentage: 0 \ No newline at end of file + attackKnockbackPercentage: 0: 0 \ No newline at end of file From aa8046eec92e8a00668930f6027edb15383c5d26 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:48:23 +0100 Subject: [PATCH 3/3] remove redundant IDs --- eco-core/core-plugin/src/main/resources/tiers/_example.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/ancient.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/cobalt.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/default.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/diamond.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/exotic.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/iron.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/mythic.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/netherite.yml | 1 - eco-core/core-plugin/src/main/resources/tiers/osmium.yml | 1 - 11 files changed, 11 deletions(-) diff --git a/eco-core/core-plugin/src/main/resources/tiers/_example.yml b/eco-core/core-plugin/src/main/resources/tiers/_example.yml index 6f960056..5bac1e09 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/_example.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/_example.yml @@ -4,7 +4,6 @@ # including in subfolders if you want to organize your tier configs # _example.yml is not loaded. -id: netherite display: "&c&lNETHERITE" # The display in-game requiresTiers: # If this tier requires a prior tier - diamond # Tier ID diff --git a/eco-core/core-plugin/src/main/resources/tiers/ancient.yml b/eco-core/core-plugin/src/main/resources/tiers/ancient.yml index 5666c847..6066a7c4 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/ancient.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/ancient.yml @@ -1,4 +1,3 @@ -id: ancient display: "&6&k!!&r &lANCIENT&r &6&k!!&r" requiresTiers: [] crystal: diff --git a/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml b/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml index 6b58c623..c669e546 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/cobalt.yml @@ -1,4 +1,3 @@ -id: cobalt display: "/ab&lCOBALT" requiresTiers: - iron diff --git a/eco-core/core-plugin/src/main/resources/tiers/default.yml b/eco-core/core-plugin/src/main/resources/tiers/default.yml index 5ef10928..68c07f2a 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/default.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/default.yml @@ -1,4 +1,3 @@ -id: default display: "&8&lDEFAULT" requiresTiers: [] crystal: diff --git a/eco-core/core-plugin/src/main/resources/tiers/diamond.yml b/eco-core/core-plugin/src/main/resources/tiers/diamond.yml index 4d582885..f369e58e 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/diamond.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/diamond.yml @@ -1,4 +1,3 @@ -id: diamond display: "&b&lDIAMOND" requiresTiers: - iron diff --git a/eco-core/core-plugin/src/main/resources/tiers/exotic.yml b/eco-core/core-plugin/src/main/resources/tiers/exotic.yml index 0c375a39..7333e2c7 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/exotic.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/exotic.yml @@ -1,4 +1,3 @@ -id: exotic display: "&6&k!!&r &lEXOTIC&r &6&k!!&r" requiresTiers: - netherite diff --git a/eco-core/core-plugin/src/main/resources/tiers/iron.yml b/eco-core/core-plugin/src/main/resources/tiers/iron.yml index b244a602..6f3dca95 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/iron.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/iron.yml @@ -1,4 +1,3 @@ -id: iron display: "&7&lIRON" requiresTiers: - default diff --git a/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml b/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml index db19eb66..3e8b1496 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/manyullyn.yml @@ -1,4 +1,3 @@ -id: manyullyn display: "&d&k!!&r &lMANYULLYN&r &d&k!!&r" requiresTiers: - netherite diff --git a/eco-core/core-plugin/src/main/resources/tiers/mythic.yml b/eco-core/core-plugin/src/main/resources/tiers/mythic.yml index 7a2abff4..8c20a6ff 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/mythic.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/mythic.yml @@ -1,4 +1,3 @@ -id: mythic display: "&1&k!!&r &lMYTHIC&r &1&k!!&r" requiresTiers: [] crystal: diff --git a/eco-core/core-plugin/src/main/resources/tiers/netherite.yml b/eco-core/core-plugin/src/main/resources/tiers/netherite.yml index 20253761..0cd39985 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/netherite.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/netherite.yml @@ -1,4 +1,3 @@ -id: netherite display: "&c&lNETHERITE" requiresTiers: - diamond diff --git a/eco-core/core-plugin/src/main/resources/tiers/osmium.yml b/eco-core/core-plugin/src/main/resources/tiers/osmium.yml index ebdb186d..c4a502d7 100644 --- a/eco-core/core-plugin/src/main/resources/tiers/osmium.yml +++ b/eco-core/core-plugin/src/main/resources/tiers/osmium.yml @@ -1,4 +1,3 @@ -id: osmium display: "&b&k!!&r &lOSMIUM&r &b&k!!" requiresTiers: - cobalt