From ffc31f565b91f34a511513063f075e3fca6e2548 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Mon, 28 Dec 2020 00:05:33 +0100 Subject: [PATCH] Use builder for flags component --- .../main/java/com/plotsquared/core/plot/Plot.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 6c28ef756..c13ce5009 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -76,6 +76,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BiomeType; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.Template; import org.slf4j.Logger; @@ -2693,11 +2694,12 @@ public class Plot { description = TranslatableCaption.of("info.plot_no_description").getComponent(player); } - Component flags = null; + Component flags; Collection> flagCollection = this.getApplicableFlags(true); if (flagCollection.isEmpty()) { flags = MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(player)); } else { + TextComponent.Builder flagBuilder = Component.text(); String prefix = " "; for (final PlotFlag flag : flagCollection) { Object value; @@ -2707,14 +2709,11 @@ public class Plot { value = flag.toString(); } Component snip = MINI_MESSAGE.parse(prefix + CaptionUtility.format(player, TranslatableCaption.of("info.plot_flag_list").getComponent(player)), - Template.of("flag", flag.getName()), Template.of("value", CaptionUtility.formatRaw(player, value.toString()))); - if (flags != null) { - flags.append(snip); - } else { - flags = snip; - } + Template.of("flag", flag.getName()), Template.of("value", CaptionUtility.formatRaw(player, value.toString()))); + flagBuilder.append(snip); prefix = ", "; } + flags = flagBuilder.build(); } boolean build = this.isAdded(player.getUUID()); Component owner;