Fix issues with chat preview refactor (#5062)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
MD 2022-08-14 23:49:02 +01:00 committed by GitHub
parent 1c22edbb1b
commit 2f4f555923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -260,6 +260,11 @@ public abstract class AbstractChatHandler {
return event.isCancelled();
}
boolean isPlayerChat(final AsyncPlayerChatEvent event) {
// Used to distinguish chats from Player#chat (sync) from chats sent by the player (async)
return event.isAsynchronous();
}
String getChatType(final User user, final String message) {
if (message.length() == 0) {
//Ignore empty chat events generated by plugins

View File

@ -54,7 +54,7 @@ public class ChatProcessingCache {
return getProcessedChat(player);
}
public static abstract class Chat {
public abstract static class Chat {
private final User user;
private final String type;
private final String originalMessage;
@ -96,6 +96,7 @@ public class ChatProcessingCache {
super(sourceChat.getUser(), sourceChat.getType(), sourceChat.getOriginalMessage());
this.message = sourceChat.messageResult;
this.format = sourceChat.formatResult;
this.radius = sourceChat.radius;
this.charge = new Trade(getLongType(), ess);
}

View File

@ -44,7 +44,7 @@ public class SignedChatHandler extends AbstractChatHandler {
private void handleChatApplyPreview(AsyncPlayerChatEvent event) {
final ChatProcessingCache.ProcessedChat chat = cache.getProcessedChat(event.getPlayer());
if (chat == null) {
if (!isPlayerChat(event) || chat == null) {
handleChatFormat(event);
handleChatPostFormat(event);
} else {