|
73 | 73 | i++; |
74 | 74 | } |
75 | 75 | } |
| 76 | +@@ -236,6 +_,54 @@ |
| 77 | + if (!this.itemName.equals(item.getHoverName().getString())) { |
| 78 | + i1 = 1; |
| 79 | + i += i1; |
| 80 | ++ // Purpur start - Allow anvil colors |
| 81 | ++ if (this.player != null) { |
| 82 | ++ org.bukkit.craftbukkit.entity.CraftHumanEntity player = this.player.getBukkitEntity(); |
| 83 | ++ String name = this.itemName; |
| 84 | ++ boolean removeItalics = false; |
| 85 | ++ if (player.hasPermission("purpur.anvil.remove_italics")) { |
| 86 | ++ if (name.startsWith("&r")) { |
| 87 | ++ name = name.substring(2); |
| 88 | ++ removeItalics = true; |
| 89 | ++ } else if (name.startsWith("<r>")) { |
| 90 | ++ name = name.substring(3); |
| 91 | ++ removeItalics = true; |
| 92 | ++ } else if (name.startsWith("<reset>")) { |
| 93 | ++ name = name.substring(7); |
| 94 | ++ removeItalics = true; |
| 95 | ++ } |
| 96 | ++ } |
| 97 | ++ if (this.player.level().purpurConfig.anvilAllowColors) { |
| 98 | ++ if (player.hasPermission("purpur.anvil.color")) { |
| 99 | ++ java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("(?i)&([0-9a-fr])").matcher(name); |
| 100 | ++ while (matcher.find()) { |
| 101 | ++ String match = matcher.group(1); |
| 102 | ++ name = name.replace("&" + match, "\u00a7" + match.toLowerCase(java.util.Locale.ROOT)); |
| 103 | ++ } |
| 104 | ++ //name = name.replaceAll("(?i)&([0-9a-fr])", "\u00a7$1"); |
| 105 | ++ } |
| 106 | ++ if (player.hasPermission("purpur.anvil.format")) { |
| 107 | ++ java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("(?i)&([k-or])").matcher(name); |
| 108 | ++ while (matcher.find()) { |
| 109 | ++ String match = matcher.group(1); |
| 110 | ++ name = name.replace("&" + match, "\u00a7" + match.toLowerCase(java.util.Locale.ROOT)); |
| 111 | ++ } |
| 112 | ++ //name = name.replaceAll("(?i)&([l-or])", "\u00a7$1"); |
| 113 | ++ } |
| 114 | ++ } |
| 115 | ++ net.kyori.adventure.text.Component component; |
| 116 | ++ if (this.player.level().purpurConfig.anvilColorsUseMiniMessage && player.hasPermission("purpur.anvil.minimessage")) { |
| 117 | ++ component = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.bukkit.ChatColor.stripColor(name)); |
| 118 | ++ } else { |
| 119 | ++ component = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(name); |
| 120 | ++ } |
| 121 | ++ if (removeItalics) { |
| 122 | ++ component = component.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false); |
| 123 | ++ } |
| 124 | ++ itemStack.set(DataComponents.CUSTOM_NAME, io.papermc.paper.adventure.PaperAdventure.asVanilla(component)); |
| 125 | ++ } |
| 126 | ++ else |
| 127 | ++ // Purpur end - Allow anvil colors |
| 128 | + itemStack.set(DataComponents.CUSTOM_NAME, Component.literal(this.itemName)); |
| 129 | + } |
| 130 | + } else if (item.has(DataComponents.CUSTOM_NAME)) { |
76 | 131 | @@ -260,6 +_,12 @@ |
77 | 132 | this.onlyRenaming = true; |
78 | 133 | } |
|
0 commit comments