Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with chat preview refactor #5062

Merged
merged 3 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ boolean isAborted(final AsyncPlayerChatEvent event) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Chat getIntermediateOrElseProcessedChat(final Player player) {
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;
Expand Down Expand Up @@ -96,6 +96,7 @@ public ProcessedChat(final IEssentials ess, final IntermediateChat sourceChat) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean tryRegisterListeners() {

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 {
Expand Down