Don't send whisper to offline players ty

This commit is contained in:
Draycia committed 2020-09-08 21:41:46 -07:00
1 parent 986475b2b9
commit a99f445c3c
2 files changed
+26 -6

No files matched your search

@@ -1,5 +1,6 @@
package net.draycia.carbon.storage.impl;
import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.events.ChannelSwitchEvent;
@@ -303,13 +304,31 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
}
}
} else if (sender.isOnline()) {
sender.sendMessage(toPlayerComponent);
final String targetNameFinal = targetName;
final String senderNameFinal = senderName;
// TODO: make sure this works lol
carbonChat.getMessageManager().sendMessage("whisper-component", sender.getUUID(), (byteArray) -> {
byteArray.writeLong(this.getUUID().getMostSignificantBits());
byteArray.writeLong(this.getUUID().getLeastSignificantBits());
byteArray.writeUTF(carbonChat.getAdventureManager().getAudiences().gsonSerializer().serialize(fromPlayerComponent));
BungeeChannelApi.of(carbonChat).getPlayerList("ALL").thenAccept(list -> {
if (!list.contains(this.asOfflinePlayer().getName())) {
String playerOfflineFormat = carbonChat.getLanguage().getString("other-player-offline");
Component playerOfflineComponent = carbonChat.getAdventureManager().processMessage(playerOfflineFormat,
"br", "\n",
"message", message,
"targetname", targetOfflineName, "sendername", senderOfflineName,
"target", targetNameFinal, "sender", senderNameFinal);
sender.sendMessage(playerOfflineComponent);
return;
}
sender.sendMessage(toPlayerComponent);
carbonChat.getMessageManager().sendMessage("whisper-component", sender.getUUID(), (byteArray) -> {
byteArray.writeLong(this.getUUID().getMostSignificantBits());
byteArray.writeLong(this.getUUID().getLeastSignificantBits());
byteArray.writeUTF(carbonChat.getAdventureManager().getAudiences().gsonSerializer().serialize(fromPlayerComponent));
});
});
}
+1
View File
@@ -12,6 +12,7 @@ formatting:
reloaded: '<yellow>Chat config has been reloaded!'
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><reset><green>] <message>'
message-from-other: '<green>[<gray><sender><reset> <gold>-> <gray>Me<green>] <message>'
other-player-offline: '<red>That player is offline!'
spy-whispers: '<yellow>Spy [<gray><sender><reset> <gold>-> <gray><target><reset><yellow>] <message>'
no-reply-target: '<red>You have no one to reply to!'
empty-channel: 'NONE' #<channel>, set to "NONE" to disable