Skip to content

Commit 964e17d

Browse files
committed
Fix the color formatting issue
1 parent 88801ec commit 964e17d

File tree

2 files changed

+13
-28
lines changed

2 files changed

+13
-28
lines changed

src/main/java/org/maxgamer/quickshop/chat/platform/minedown/BungeeQuickChat.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,12 @@ public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @
8585
TextSplitter.SpilledString spilledString = TextSplitter.deBakeItem(text);
8686
if (spilledString == null) {
8787
Util.debugLog("Spilled string is null");
88-
builder.append(text);
88+
builder.appendLegacy(text);
8989
} else {
90-
Util.debugLog("Building component...");
91-
builder.append(spilledString.getLeft())
92-
.append(spilledString.getComponents())
93-
.append(spilledString.getRight());
94-
Util.debugLog("Left is " + spilledString.getLeft());
95-
Util.debugLog("Right is " + spilledString.getRight());
96-
Util.debugLog("Component is " + ComponentSerializer.toString(spilledString.getComponents()));
97-
Util.debugLog("Success...");
90+
builder.appendLegacy(spilledString.getLeft());
91+
net.md_5.bungee.api.ChatColor color = builder.getCurrentComponent().getColorRaw();
92+
builder.append(spilledString.getComponents()).color(color);
93+
builder.appendLegacy(spilledString.getRight()).color(color);
9894
}
9995
builder.event(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(json).create()));
10096
BaseComponent[] components = builder.create();
@@ -117,21 +113,15 @@ public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @
117113
ComponentBuilder builder = new ComponentBuilder();
118114
TextSplitter.SpilledString spilledString = TextSplitter.deBakeItem(message);
119115
if (spilledString == null) {
120-
Util.debugLog("Spilled string is null");
121-
builder.append(message);
116+
builder.appendLegacy(message);
122117
} else {
123-
Util.debugLog("Building component...");
124-
builder.append(spilledString.getLeft())
125-
.append(spilledString.getComponents())
126-
.append(spilledString.getRight());
127-
Util.debugLog("Left is " + spilledString.getLeft());
128-
Util.debugLog("Right is " + spilledString.getRight());
129-
Util.debugLog("Component is " + ComponentSerializer.toString(spilledString.getComponents()));
130-
Util.debugLog("Success...");
118+
builder.appendLegacy(spilledString.getLeft());
119+
net.md_5.bungee.api.ChatColor color = builder.getCurrentComponent().getColorRaw();
120+
builder.append(spilledString.getComponents()).color(color);
121+
builder.appendLegacy(spilledString.getRight()).color(color);
131122
}
132123

133-
builder.append(" ")
134-
.append(plugin.text().of(player, "menu.preview").forLocale());
124+
builder.appendLegacy(" ").appendLegacy(plugin.text().of(player, "menu.preview").forLocale());
135125
// builder.event(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(json).create()));
136126
if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) {
137127
builder.event(new ClickEvent(

src/main/java/org/maxgamer/quickshop/util/MsgUtil.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import lombok.Data;
2828
import lombok.Getter;
2929
import net.md_5.bungee.api.chat.ComponentBuilder;
30-
import net.md_5.bungee.api.chat.TextComponent;
3130
import net.md_5.bungee.api.chat.TranslatableComponent;
3231
import org.apache.commons.lang.StringUtils;
3332
import org.bukkit.Bukkit;
@@ -715,14 +714,10 @@ public static void sendDirectMessage(@Nullable CommandSender sender, @Nullable S
715714
if (spilledString == null) {
716715
plugin.getQuickChat().send(sender, msg);
717716
} else {
718-
Util.debugLog("Built successfully");
719717
ComponentBuilder builder = new ComponentBuilder();
720-
Util.debugLog("Left " + Arrays.toString(TextComponent.fromLegacyText(spilledString.getLeft())));
721-
builder.append(TextComponent.fromLegacyText(spilledString.getLeft()));
722-
Util.debugLog("Center " + Arrays.toString(spilledString.getComponents()));
718+
builder.appendLegacy(spilledString.getLeft());
723719
builder.append(spilledString.getComponents());
724-
Util.debugLog("Right " + Arrays.toString(TextComponent.fromLegacyText(spilledString.getRight())));
725-
builder.append(TextComponent.fromLegacyText(spilledString.getRight()));
720+
builder.appendLegacy(spilledString.getRight());
726721
plugin.getQuickChat().send(sender, new QuickComponentImpl(builder.create()));
727722
}
728723
} catch (Throwable throwable) {

0 commit comments

Comments
 (0)