mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-10-31 07:51:05 +01:00
Split up chat messages sent to console containing new lines
This commit is contained in:
parent
a526c942ca
commit
7c398d2c67
@ -28,6 +28,8 @@ package me.lucko.luckperms.common.commands.sender;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
@ -45,6 +47,8 @@ import java.util.UUID;
|
|||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(of = "uuid")
|
@EqualsAndHashCode(of = "uuid")
|
||||||
public final class AbstractSender<T> implements Sender {
|
public final class AbstractSender<T> implements Sender {
|
||||||
|
private static final Splitter NEW_LINE_SPLITTER = Splitter.on("\n");
|
||||||
|
|
||||||
private final LuckPermsPlugin platform;
|
private final LuckPermsPlugin platform;
|
||||||
private final SenderFactory<T> factory;
|
private final SenderFactory<T> factory;
|
||||||
private final WeakReference<T> ref;
|
private final WeakReference<T> ref;
|
||||||
@ -63,12 +67,26 @@ public final class AbstractSender<T> implements Sender {
|
|||||||
public void sendMessage(String s) {
|
public void sendMessage(String s) {
|
||||||
final T t = ref.get();
|
final T t = ref.get();
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
|
|
||||||
|
if (!isConsole()) {
|
||||||
factory.sendMessage(t, s);
|
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
|
@Override
|
||||||
public void sendMessage(FancyMessage message) {
|
public void sendMessage(FancyMessage message) {
|
||||||
|
if (isConsole()) {
|
||||||
|
sendMessage(message.toOldMessageFormat());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final T t = ref.get();
|
final T t = ref.get();
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
factory.sendMessage(t, message);
|
factory.sendMessage(t, message);
|
||||||
|
Loading…
Reference in New Issue
Block a user