Skip to content

Commit

Permalink
🐛 OxidePluginEventParser picked up team chat payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGraversen committed Sep 27, 2023
1 parent b0e77c9 commit 8983af8
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class OxidePluginEventParser extends BaseRustEventParser<OxidePluginEvent
private static final String EVENT_PATTERN = "^\\[(.*?)\\].*";
private static final String NATIVE_EVENT_PREFIX = "[event]";
private static final String CHAT_EVENT_PREFIX = "[CHAT]";
private static final String TEAM_CHAT_EVENT_PREFIX = "[TEAM CHAT]";
private static final String ENTITY_COMMAND_EVENT_PREFIX = "[ENTCMD]";

@Override
Expand All @@ -32,9 +33,17 @@ protected Function<RustRconResponse, Optional<OxidePluginEvent>> eventParser() {
@Override
public boolean supports(@NonNull RustRconResponse payload) {
final var message = payload.getMessage();

if (message.isBlank()) {
return false;
}

if (message.matches(EVENT_PATTERN)) {
final var prefix = message.substring(message.indexOf('['), message.indexOf(']') + 1);
return !prefix.equals(NATIVE_EVENT_PREFIX) && !prefix.equals(CHAT_EVENT_PREFIX) && !prefix.equals(ENTITY_COMMAND_EVENT_PREFIX);
return !prefix.equals(NATIVE_EVENT_PREFIX)
&& !prefix.equals(CHAT_EVENT_PREFIX)
&& !prefix.equals(TEAM_CHAT_EVENT_PREFIX)
&& !prefix.equals(ENTITY_COMMAND_EVENT_PREFIX);
}

return false;
Expand Down

0 comments on commit 8983af8

Please sign in to comment.