From 7c398d2c67095fe54168632d9af8d17f8142b3e4 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 23 Apr 2017 20:51:24 +0100 Subject: [PATCH] Split up chat messages sent to console containing new lines --- .../commands/sender/AbstractSender.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java b/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java index 6e302fe3..7bb39f4c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java @@ -28,6 +28,8 @@ package me.lucko.luckperms.common.commands.sender; import lombok.EqualsAndHashCode; import lombok.Getter; +import com.google.common.base.Splitter; + import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -45,6 +47,8 @@ import java.util.UUID; @Getter @EqualsAndHashCode(of = "uuid") public final class AbstractSender implements Sender { + private static final Splitter NEW_LINE_SPLITTER = Splitter.on("\n"); + private final LuckPermsPlugin platform; private final SenderFactory factory; private final WeakReference ref; @@ -63,12 +67,26 @@ public final class AbstractSender implements Sender { public void sendMessage(String s) { final T t = ref.get(); if (t != null) { - factory.sendMessage(t, s); + + if (!isConsole()) { + factory.sendMessage(t, s); + return; + } + + // if it is console, split up the lines and send individually. + for (String line : NEW_LINE_SPLITTER.split(s)) { + factory.sendMessage(t, line); + } } } @Override public void sendMessage(FancyMessage message) { + if (isConsole()) { + sendMessage(message.toOldMessageFormat()); + return; + } + final T t = ref.get(); if (t != null) { factory.sendMessage(t, message);