From 9afc2f8a966c0a40d3192cc48c9e6a7a8ba49e34 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 25 Nov 2016 20:26:43 -0500 Subject: [PATCH] Fixed Word Wrap not preserving lines --- .../java/buttondevteam/lib/DebugPotato.java | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotato.java b/src/main/java/buttondevteam/lib/DebugPotato.java index 5c6139b..69a1b55 100644 --- a/src/main/java/buttondevteam/lib/DebugPotato.java +++ b/src/main/java/buttondevteam/lib/DebugPotato.java @@ -36,37 +36,46 @@ public class DebugPotato { /** * Sets the message (lore of the potato). - * - * @param message - * The message + * @param message The message you wish to set + * @param forceWordWrap Word Wraps the whole String List, without preserving previous line breaks. Preserves line breaks if false + * @return This potato + */ + + public DebugPotato setMessage(List message, boolean forceWordWrap) { + if (forceWordWrap){ + this.message = WordWrap(message.toString()); + }else{ + List outputList = new ArrayList(); + List tempList = new ArrayList(); + for(String line: message){ + tempList = WordWrap(line.toString()); + for (String s: tempList){ + outputList.add(s); + } + } + this.message = outputList; + } + + return this; + } + /** + * Sets the message (lore of the potato). It will be word wrapped automatically. * @return This potato */ public DebugPotato setMessage(List message) { - this.message = WordWrap(message.toString()); - return this; - } - public DebugPotato setMessage(List message, boolean isWordWrapped) { - this.message = (isWordWrapped) ? WordWrap(message.toString()): message; - return this; + return setMessage(message, false); } /** * Sets the message (lore of the potato). It will be word wrapped automatically. - * - * @param message - * The message * @return This potato */ public DebugPotato setMessage(String message) { - this.message = WordWrap(message); - return this; + return setMessage(Arrays.asList(message)); } /** - * Sets the message (lore of the potato). - * - * @param message - * The message + * Sets the message (lore of the potato). It will be word wrapped automatically. * @return This potato */ public DebugPotato setMessage(String[] message) {