From 2061035bc6a623b93372e9b7e530167a57c82aff Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 21 Nov 2019 21:04:39 +0000 Subject: [PATCH] merge color with parent --- .../java/com/boydti/fawe/config/Caption.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 1bc0c3325..b77b99418 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 @@ -35,29 +35,33 @@ public class Caption { } } } + TextColor lastColor = parent.color(); 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); + Component original = children.get(i); + Component child = original; + if (child.color() == null && lastColor != null) { + child = child.color(lastColor); } - if (coloredChild != child) { + child = color(child); + if (original != child) { if (!(children instanceof ArrayList)) { children = new ArrayList<>(children); } - children.set(i, coloredChild); + children.set(i, child); } - if (coloredChild.color() != null) { - lastColor = coloredChild.color(); + if (child.color() != null) { + lastColor = child.color(); } } if (children instanceof ArrayList) { parent = parent.children(children); } } + if (parent.color() == null && lastColor != null) { + parent = parent.color(lastColor); + } return parent; }