From ddf5ae711ae9bd0bf6cdec9a40ceaeda3a7a1edb Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Mon, 1 Jul 2024 10:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=A7=B0=E5=8F=B7?= =?UTF-8?q?=E5=89=8D=E5=90=8E=E7=BC=80=E9=A2=9C=E8=89=B2=E4=B8=8D=E5=AE=9A?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../java/cn/lunadeer/miniplayertitle/dtos/TitleDTO.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index f53b5d9..931c750 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lunadeer MiniPlayerTitle - 4.2.5 + 4.2.6 jar MiniPlayerTitle diff --git a/src/main/java/cn/lunadeer/miniplayertitle/dtos/TitleDTO.java b/src/main/java/cn/lunadeer/miniplayertitle/dtos/TitleDTO.java index fe7ed76..59f01c7 100644 --- a/src/main/java/cn/lunadeer/miniplayertitle/dtos/TitleDTO.java +++ b/src/main/java/cn/lunadeer/miniplayertitle/dtos/TitleDTO.java @@ -74,9 +74,11 @@ public class TitleDTO { } public TextComponent getTitleColored() { - String title = MiniPlayerTitle.config.getPrefix() + this.title + MiniPlayerTitle.config.getSuffix(); - String[] parts = title.split("&#"); + TextComponent prefix = Component.text(MiniPlayerTitle.config.getPrefix(), new Color("#ffffff").getStyle()); + TextComponent suffix = Component.text(MiniPlayerTitle.config.getSuffix(), new Color("#ffffff").getStyle()); + String[] parts = this.title.split("&#"); List components = new ArrayList<>(); + components.add(prefix); for (String part : parts) { if (part.isEmpty()) { continue; @@ -92,6 +94,7 @@ public class TitleDTO { } components.add(Component.text(content, color.getStyle())); } + components.add(suffix); TextComponent.Builder title_component = Component.text(); for (TextComponent component : components) { title_component.append(component); @@ -107,7 +110,7 @@ public class TitleDTO { * @return String */ public String getTitleColoredBukkit() { - String title = MiniPlayerTitle.config.getPrefix() + this.title + MiniPlayerTitle.config.getSuffix(); + String title = "&f" + MiniPlayerTitle.config.getPrefix() + this.title + "&f" + MiniPlayerTitle.config.getSuffix(); title = title.replaceAll("&#", "#"); Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}"); Matcher matcher = pattern.matcher(title);