9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-29 11:59:21 +00:00

Allowed specifying custom item for reforge stones altogether

This commit is contained in:
Auxilor
2021-11-18 15:08:38 +00:00
parent cf58c5de49
commit 3436c11972
3 changed files with 32 additions and 36 deletions

View File

@@ -14,7 +14,6 @@ import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextReplacementConfig
import net.kyori.adventure.text.format.TextDecoration
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.SkullMeta
import org.bukkit.persistence.PersistentDataType
@@ -39,25 +38,20 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
) {
val target = ReforgeTarget.getForItem(itemStack)
if (target.isEmpty() && itemStack.type != Material.PLAYER_HEAD) {
// Letting player heads through here to add the stone check
val meta = itemStack.itemMeta ?: return
val stone = ReforgeUtils.getReforgeStone(meta)
if (target.isEmpty() && stone == null) {
return
}
val meta = itemStack.itemMeta ?: return
val fastItemStack = FastItemStack.wrap(itemStack)
val lore = fastItemStack.lore
val reforge = ReforgeUtils.getReforge(meta)
val stone = ReforgeUtils.getReforgeStone(meta)
if (stone == null && target.isEmpty()) {
return
}
if (reforge == null && stone == null && target != null) {
if (plugin.configYml.getBool("reforge.show-reforgable")) {
val addLore: MutableList<String> = ArrayList()
@@ -70,11 +64,13 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
if (stone != null) {
meta.setDisplayName(stone.config.getFormattedString("stone.name"))
if (stone.config.has("stone.texture") && stone.config.getString("stone.texture").isNotEmpty()) {
SkullUtils.setSkullTexture(
meta as SkullMeta,
stone.config.getString("stone.texture")
)
val stoneMeta = stone.stone.itemMeta
if (stoneMeta is SkullMeta) {
val stoneTexture = SkullUtils.getSkullTexture(stoneMeta)
if (stoneTexture != null) {
SkullUtils.setSkullTexture(meta as SkullMeta, stoneTexture)
}
}
itemStack.itemMeta = meta
val stoneLore = stone.config.getFormattedStrings("stone.lore").map {

View File

@@ -3,7 +3,8 @@ package com.willfp.reforges.reforges
import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.eco.core.display.Display
import com.willfp.eco.core.items.CustomItem
import com.willfp.eco.core.items.builder.SkullBuilder
import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.builder.ItemStackBuilder
import com.willfp.eco.core.recipe.Recipes
import com.willfp.libreforge.api.conditions.Conditions
import com.willfp.libreforge.api.conditions.ConfiguredCondition
@@ -41,9 +42,8 @@ class Reforge(
val requiresStone = config.getBool("stone.enabled")
val stone: ItemStack = SkullBuilder().apply {
val stone: ItemStack = ItemStackBuilder(Items.lookup(config.getString("stone.item")).item).apply {
if (config.getBool("stone.enabled")) {
setSkullTexture(config.getString("stone.texture"))
setDisplayName(config.getFormattedString("stone.name").replace("%reforge%", name))
addLoreLines(
config.getFormattedStrings("stone.lore").map { "${Display.PREFIX}${it.replace("%reforge%", name)}" })

View File

@@ -13,7 +13,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -39,7 +39,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -68,7 +68,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -99,7 +99,7 @@
"&7reforge menu to apply the",
"<gradient:#AAFFA9>Dynamic</gradient:#11FFBD>&7 reforge!"
],
"texture": "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM0YTY1YzY4OWIyZDM2NDA5MTAwYTYwYzJhYjhkM2QwYTY3Y2U5NGVlYTNjMWY3YWM5NzRmZDg5MzU2OGI1ZCJ9fX0=",
"item": "player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM0YTY1YzY4OWIyZDM2NDA5MTAwYTYwYzJhYjhkM2QwYTY3Y2U5NGVlYTNjMWY3YWM5NzRmZDg5MzU2OGI1ZCJ9fX0=",
"craftable": true,
"recipe": [
"air",
@@ -139,7 +139,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -166,7 +166,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -194,7 +194,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -230,7 +230,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -259,7 +259,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -285,7 +285,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -312,7 +312,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -343,7 +343,7 @@
"&7reforge menu to apply the",
"<gradient:#DBDBDB>Rich</gradient:#F2F2F2>&7 reforge!"
],
"texture": "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2RjNTdjNzVhZGYzOWVjNmYwZTA5MTYwNDlkZDk2NzFlOThhOGExZTYwMDEwNGU4NGU2NDVjOTg4OTUwYmQ3In19fQ==",
"item": "player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2RjNTdjNzVhZGYzOWVjNmYwZTA5MTYwNDlkZDk2NzFlOThhOGExZTYwMDEwNGU4NGU2NDVjOTg4OTUwYmQ3In19fQ==",
"craftable": true,
"recipe": [
"gold_block",
@@ -379,7 +379,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -405,7 +405,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -432,7 +432,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -463,7 +463,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},
@@ -494,7 +494,7 @@
"enabled": false,
"name": "",
"lore": [],
"texture": "",
"item": "",
"craftable": false,
"recipe": []
},