mirror of
https://github.com/Auxilor/Reforges.git
synced 2025-12-23 17:09:32 +00:00
Display changes
This commit is contained in:
@@ -29,7 +29,6 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||||
maven { url 'https://papermc.io/repo/repository/maven-public/' }
|
|
||||||
maven { url 'https://repo.codemc.org/repository/nms/' }
|
maven { url 'https://repo.codemc.org/repository/nms/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ group 'com.willfp'
|
|||||||
version rootProject.version
|
version rootProject.version
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||||
|
compileOnly 'net.kyori:adventure-api:4.9.1'
|
||||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,6 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class ReforgeGUI {
|
public class ReforgeGUI {
|
||||||
/**
|
/**
|
||||||
* The reforge GUI.
|
* The reforge GUI.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@SuppressWarnings({"unused", "checkstyle:JavadocVariable"})
|
@SuppressWarnings("unused")
|
||||||
public class Reforges {
|
public class Reforges {
|
||||||
private static final BiMap<String, Reforge> BY_KEY = HashBiMap.create();
|
private static final BiMap<String, Reforge> BY_KEY = HashBiMap.create();
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,11 @@ 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.Component
|
||||||
import net.kyori.adventure.text.TextReplacementConfig
|
import net.kyori.adventure.translation.Translatable
|
||||||
import net.kyori.adventure.text.format.TextDecoration
|
|
||||||
import org.bukkit.ChatColor
|
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin, DisplayPriority.HIGHEST) {
|
class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin, DisplayPriority.HIGHEST) {
|
||||||
private val shadowKey = plugin.namespacedKeyFactory.create("shadowed_name")
|
private val shadowKey = plugin.namespacedKeyFactory.create("shadowed_name")
|
||||||
|
|
||||||
@@ -74,19 +71,40 @@ class ReforgesDisplay(private val plugin: ReforgesPlugin) : DisplayModule(plugin
|
|||||||
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") && Prerequisite.HAS_PAPER.isMet) {
|
||||||
var displayName = if (meta.hasDisplayName()) meta.displayName()!! else Component.translatable(itemStack)
|
var displayName = if (meta.hasDisplayName()) meta.displayName else StringUtils.toLegacy(
|
||||||
displayName = displayName.replaceText(
|
Component.translatable(itemStack as Translatable)
|
||||||
TextReplacementConfig.builder()
|
|
||||||
.matchLiteral(ChatColor.stripColor(reforge.name + " "))
|
|
||||||
.replacement("")
|
|
||||||
.build()
|
|
||||||
)
|
)
|
||||||
val newName = StringUtils.toComponent(reforge.name).decoration(TextDecoration.ITALIC, false)
|
displayName = displayName.replace(
|
||||||
.append(Component.text(" ").append(displayName))
|
reforge.name + " ",
|
||||||
meta.displayName(newName)
|
""
|
||||||
|
)
|
||||||
|
val newName = reforge.name + " " + displayName
|
||||||
|
meta.setDisplayName(newName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemStack.itemMeta = meta
|
itemStack.itemMeta = meta
|
||||||
fastItemStack.lore = lore
|
fastItemStack.lore = lore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun revert(itemStack: ItemStack) {
|
||||||
|
val target = ReforgeTarget.getForItem(itemStack)
|
||||||
|
|
||||||
|
if (target == null && itemStack.type != Material.PLAYER_HEAD) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val meta = itemStack.itemMeta ?: return
|
||||||
|
val reforge = ReforgeUtils.getReforge(meta) ?: return
|
||||||
|
|
||||||
|
if (plugin.configYml.getBool("reforge.display-in-name")) {
|
||||||
|
var displayName = meta.displayName
|
||||||
|
displayName = displayName.replace(
|
||||||
|
reforge.name + " ",
|
||||||
|
""
|
||||||
|
)
|
||||||
|
meta.setDisplayName(displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemStack.itemMeta = meta
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user