diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index 45f0545b..d1a97bb0 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -248,10 +248,6 @@ public class Commons { public static void addChatMessage(final ICommandSender commandSender, @Nonnull final ITextComponent textComponent) { final String message = textComponent.getFormattedText(); - addChatMessage(commandSender, message); - } - - public static void addChatMessage(final ICommandSender commandSender, @Nonnull final String message) { if (commandSender == null) { WarpDrive.logger.error(String.format("Unable to send message to NULL sender: %s", message)); @@ -264,23 +260,28 @@ public class Commons { } final String[] lines = updateEscapeCodes(message).split("\n"); - String formatNextLine = ""; - for (final String line : lines) { - commandSender.sendMessage(new TextComponentString(formatNextLine + line)); + if (lines.length == 1) { + commandSender.sendMessage(textComponent); - // compute remaining format - int index = 0; - while (index < line.length()) { - if (line.charAt(index) == (char) 167 && index + 1 < line.length()) { - index++; - final char charFormat = line.charAt(index); - if (charFormat == 'r') { - formatNextLine = CHAR_FORMATTING + charFormat; - } else { - formatNextLine += CHAR_FORMATTING + charFormat; + } else { + String formatNextLine = ""; + for (final String line : lines) { + commandSender.sendMessage(new TextComponentString(formatNextLine + line)); + + // compute remaining format + int index = 0; + while (index < line.length()) { + if (line.charAt(index) == (char) 167 && index + 1 < line.length()) { + index++; + final char charFormat = line.charAt(index); + if (charFormat == 'r') { + formatNextLine = CHAR_FORMATTING + charFormat; + } else { + formatNextLine += CHAR_FORMATTING + charFormat; + } } + index++; } - index++; } } diff --git a/src/main/java/cr0s/warpdrive/api/WarpDriveText.java b/src/main/java/cr0s/warpdrive/api/WarpDriveText.java index ab80df86..0575448c 100644 --- a/src/main/java/cr0s/warpdrive/api/WarpDriveText.java +++ b/src/main/java/cr0s/warpdrive/api/WarpDriveText.java @@ -28,10 +28,20 @@ public class WarpDriveText extends TextComponentString { super(""); final ITextComponent textComponent = new TextComponentTranslation(translationKey, args); - if (style != null) { - textComponent.setStyle(style); + final String textRaw = textComponent.getUnformattedText(); + if (textRaw.startsWith("[") && textRaw.endsWith("]")) { + final ITextComponent textComponentNested = ITextComponent.Serializer.jsonToComponent(textRaw); + if (textComponentNested != null) { + append(textComponentNested); + } else { + append(textComponent); + } + } else { + if (style != null) { + textComponent.setStyle(style); + } + append(textComponent); } - append(textComponent); } @Nonnull diff --git a/src/main/resources/assets/warpdrive/lang/de_de.lang b/src/main/resources/assets/warpdrive/lang/de_de.lang index 8a08f7aa..2a01f8f8 100644 --- a/src/main/resources/assets/warpdrive/lang/de_de.lang +++ b/src/main/resources/assets/warpdrive/lang/de_de.lang @@ -947,7 +947,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad warpdrive.ship.guide.entering_hyperspace=Entering hyperspace... warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace... warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s! -warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=Turning to the right warpdrive.ship.guide.turning_back=Turning back warpdrive.ship.guide.turning_left=Turning to the left diff --git a/src/main/resources/assets/warpdrive/lang/en_us.lang b/src/main/resources/assets/warpdrive/lang/en_us.lang index 53eeebd5..97b592ae 100644 --- a/src/main/resources/assets/warpdrive/lang/en_us.lang +++ b/src/main/resources/assets/warpdrive/lang/en_us.lang @@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad warpdrive.ship.guide.entering_hyperspace=Entering hyperspace... warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace... warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s! -warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=Turning to the right warpdrive.ship.guide.turning_back=Turning back warpdrive.ship.guide.turning_left=Turning to the left diff --git a/src/main/resources/assets/warpdrive/lang/fr_fr.lang b/src/main/resources/assets/warpdrive/lang/fr_fr.lang index cd6b2993..fca0538d 100644 --- a/src/main/resources/assets/warpdrive/lang/fr_fr.lang +++ b/src/main/resources/assets/warpdrive/lang/fr_fr.lang @@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad warpdrive.ship.guide.entering_hyperspace=Entering hyperspace... warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace... warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s! -warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=Turning to the right warpdrive.ship.guide.turning_back=Turning back warpdrive.ship.guide.turning_left=Turning to the left diff --git a/src/main/resources/assets/warpdrive/lang/nl_nl.lang b/src/main/resources/assets/warpdrive/lang/nl_nl.lang index ada7754d..cd2f06da 100644 --- a/src/main/resources/assets/warpdrive/lang/nl_nl.lang +++ b/src/main/resources/assets/warpdrive/lang/nl_nl.lang @@ -952,7 +952,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad warpdrive.ship.guide.entering_hyperspace=Entering hyperspace... warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace... warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s! -warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=Turning to the right warpdrive.ship.guide.turning_back=Turning back warpdrive.ship.guide.turning_left=Turning to the left diff --git a/src/main/resources/assets/warpdrive/lang/ru_ru.lang b/src/main/resources/assets/warpdrive/lang/ru_ru.lang index fc5cba29..b6dd6f1b 100644 --- a/src/main/resources/assets/warpdrive/lang/ru_ru.lang +++ b/src/main/resources/assets/warpdrive/lang/ru_ru.lang @@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad warpdrive.ship.guide.entering_hyperspace=Entering hyperspace... warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace... warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s! -warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=Turning to the right warpdrive.ship.guide.turning_back=Turning back warpdrive.ship.guide.turning_left=Turning to the left diff --git a/src/main/resources/assets/warpdrive/lang/zh_cn.lang b/src/main/resources/assets/warpdrive/lang/zh_cn.lang index 0ecb196c..73905ac9 100644 --- a/src/main/resources/assets/warpdrive/lang/zh_cn.lang +++ b/src/main/resources/assets/warpdrive/lang/zh_cn.lang @@ -953,7 +953,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=调整后空间不足。 warpdrive.ship.guide.entering_hyperspace=正在进入超空间…… warpdrive.ship.guide.leaving_hyperspace=正在离开超空间…… warpdrive.ship.guide.engaging_jumpgate_x=向 %1$s 启动跃迁门! -warpdrive.ship.guide.jumping_xyz=正在跃迁 %1$d 格 (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "正在跃迁 %1$d 格 (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=右转 warpdrive.ship.guide.turning_back=向后转 warpdrive.ship.guide.turning_left=左转 diff --git a/src/main/resources/assets/warpdrive/lang/zh_tw.lang b/src/main/resources/assets/warpdrive/lang/zh_tw.lang index 17c55639..b759fdc6 100644 --- a/src/main/resources/assets/warpdrive/lang/zh_tw.lang +++ b/src/main/resources/assets/warpdrive/lang/zh_tw.lang @@ -952,7 +952,7 @@ warpdrive.ship.guide.not_enough_space_after_adjustment=Not enough space after ad warpdrive.ship.guide.entering_hyperspace=Entering hyperspace... warpdrive.ship.guide.leaving_hyperspace=Leaving hyperspace... warpdrive.ship.guide.engaging_jumpgate_x=Engaging jumpgate towards %1$s! -warpdrive.ship.guide.jumping_xyz=Jumping of %1$d blocks (XYZ %2$d %3$d %4$d) +warpdrive.ship.guide.jumping_xyz=[{"text": "Jumping of %1$d blocks (XYZ %2$d %3$d %4$d). "}, {"text": "Click to update home.", "color": "blue", "clickEvent": { "action": "run_command", "value": "/sethome -o" }}] warpdrive.ship.guide.turning_right=Turning to the right warpdrive.ship.guide.turning_back=Turning back warpdrive.ship.guide.turning_left=Turning to the left