From 1a5e8c395a57abd897050d7a3cef2fd4a0b1795b Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 21 Nov 2019 20:47:14 +0000 Subject: [PATCH] inherit colors --- .../src/main/java/com/boydti/fawe/config/Caption.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java index 448138069..1bc0c3325 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java @@ -3,6 +3,7 @@ package com.boydti.fawe.config; import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer; import java.util.ArrayList; @@ -36,15 +37,22 @@ public class Caption { } List children = parent.children(); if (!children.isEmpty()) { + TextColor lastColor = parent.color(); for (int i = 0; i < children.size(); i++) { Component child = children.get(i); Component coloredChild = color(child); + if (coloredChild.color() == null && lastColor != null) { + coloredChild = coloredChild.color(lastColor); + } if (coloredChild != child) { if (!(children instanceof ArrayList)) { children = new ArrayList<>(children); } children.set(i, coloredChild); } + if (coloredChild.color() != null) { + lastColor = coloredChild.color(); + } } if (children instanceof ArrayList) { parent = parent.children(children);