mirror of
https://github.com/Auxilor/Reforges.git
synced 2026-01-06 15:51:32 +00:00
Improved performance with new FIS API
This commit is contained in:
@@ -43,7 +43,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.willfp:eco:6.31.0'
|
compileOnly 'com.willfp:eco:6.33.0'
|
||||||
implementation 'com.willfp:libreforge:3.33.3'
|
implementation 'com.willfp:libreforge:3.33.3'
|
||||||
|
|
||||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class ReforgesPlugin extends LibReforgePlugin {
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getMinimumEcoVersion() {
|
public String getMinimumEcoVersion() {
|
||||||
return "6.31.0";
|
return "6.33.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.willfp.reforges.display
|
package com.willfp.reforges.display
|
||||||
|
|
||||||
import com.willfp.eco.core.Prerequisite
|
|
||||||
import com.willfp.eco.core.display.Display
|
import com.willfp.eco.core.display.Display
|
||||||
import com.willfp.eco.core.display.DisplayModule
|
import com.willfp.eco.core.display.DisplayModule
|
||||||
import com.willfp.eco.core.display.DisplayPriority
|
import com.willfp.eco.core.display.DisplayPriority
|
||||||
@@ -10,7 +9,6 @@ import com.willfp.eco.util.StringUtils
|
|||||||
import com.willfp.reforges.ReforgesPlugin
|
import com.willfp.reforges.ReforgesPlugin
|
||||||
import com.willfp.reforges.reforges.meta.ReforgeTarget
|
import com.willfp.reforges.reforges.meta.ReforgeTarget
|
||||||
import com.willfp.reforges.reforges.util.ReforgeUtils
|
import com.willfp.reforges.reforges.util.ReforgeUtils
|
||||||
import net.kyori.adventure.text.Component
|
|
||||||
import net.kyori.adventure.text.TextReplacementConfig
|
import net.kyori.adventure.text.TextReplacementConfig
|
||||||
import net.kyori.adventure.text.format.TextDecoration
|
import net.kyori.adventure.text.format.TextDecoration
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
|
||||||
@@ -82,6 +80,7 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
|
|||||||
}.toList()
|
}.toList()
|
||||||
lore.addAll(0, stoneLore)
|
lore.addAll(0, stoneLore)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reforge != null) {
|
if (reforge != null) {
|
||||||
if (plugin.configYml.getBool("reforge.display-in-lore")) {
|
if (plugin.configYml.getBool("reforge.display-in-lore")) {
|
||||||
val addLore: MutableList<String> = ArrayList()
|
val addLore: MutableList<String> = ArrayList()
|
||||||
@@ -92,34 +91,35 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
|
|||||||
addLore.replaceAll { "${Display.PREFIX}$it" }
|
addLore.replaceAll { "${Display.PREFIX}$it" }
|
||||||
lore.addAll(addLore)
|
lore.addAll(addLore)
|
||||||
}
|
}
|
||||||
if (plugin.configYml.getBool("reforge.display-in-name") && Prerequisite.HAS_PAPER.isMet) {
|
if (plugin.configYml.getBool("reforge.display-in-name")) {
|
||||||
val displayName = (meta.displayName() ?: Component.translatable(itemStack)).replaceText(replacement)
|
val displayName = fastItemStack.displayNameComponent.replaceText(replacement)
|
||||||
meta.persistentDataContainer.set(
|
|
||||||
|
val newName = StringUtils.toComponent("${reforge.name} ")
|
||||||
|
.decoration(TextDecoration.ITALIC, false).append(displayName)
|
||||||
|
|
||||||
|
fastItemStack.setDisplayName(newName)
|
||||||
|
|
||||||
|
fastItemStack.persistentDataContainer.set(
|
||||||
originalComponentKey,
|
originalComponentKey,
|
||||||
PersistentDataType.STRING,
|
PersistentDataType.STRING,
|
||||||
serializer.serialize(displayName)
|
serializer.serialize(displayName)
|
||||||
)
|
)
|
||||||
val newName = StringUtils.toComponent("${reforge.name} ")
|
|
||||||
.decoration(TextDecoration.ITALIC, false).append(displayName)
|
|
||||||
meta.displayName(newName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemStack.itemMeta = meta
|
|
||||||
fastItemStack.lore = lore
|
fastItemStack.lore = lore
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun revert(itemStack: ItemStack) {
|
override fun revert(itemStack: ItemStack) {
|
||||||
ReforgeTarget.getForItem(itemStack) ?: return
|
ReforgeTarget.getForItem(itemStack) ?: return
|
||||||
|
|
||||||
val meta = itemStack.itemMeta ?: return
|
val fis = FastItemStack.wrap(itemStack)
|
||||||
|
|
||||||
if (plugin.configYml.getBool("reforge.display-in-name") && Prerequisite.HAS_PAPER.isMet) {
|
if (plugin.configYml.getBool("reforge.display-in-name")) {
|
||||||
val originalName =
|
val originalName =
|
||||||
meta.persistentDataContainer.get(originalComponentKey, PersistentDataType.STRING) ?: return
|
fis.persistentDataContainer.get(originalComponentKey, PersistentDataType.STRING) ?: return
|
||||||
meta.persistentDataContainer.remove(originalComponentKey)
|
fis.persistentDataContainer.remove(originalComponentKey)
|
||||||
meta.displayName(serializer.deserialize(originalName).replaceText(replacement))
|
fis.setDisplayName(serializer.deserialize(originalName).replaceText(replacement))
|
||||||
}
|
}
|
||||||
|
|
||||||
itemStack.itemMeta = meta
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ reforge:
|
|||||||
- "&8This item can be reforged!"
|
- "&8This item can be reforged!"
|
||||||
|
|
||||||
display-in-lore: true
|
display-in-lore: true
|
||||||
display-in-name: true # Requires paper to be installed on the server
|
display-in-name: true
|
||||||
|
|
||||||
reforged-prefix:
|
reforged-prefix:
|
||||||
- ""
|
- ""
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 4.61.4
|
version = 4.61.5
|
||||||
plugin-name = Reforges
|
plugin-name = Reforges
|
||||||
Reference in New Issue
Block a user