Skip to content

Commit

Permalink
⚡ More cases to avoid accidental OxidePluginEventParser invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGraversen committed Sep 27, 2023
1 parent 8983af8 commit 7c470af
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class OxidePluginEventParser extends BaseRustEventParser<OxidePluginEvent
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]";
private static final String GENERIC_SUFFIX = "(Generic)";
private static final String DESTROYING_SUFFIX = "(destroying)";
private static final String NETWORK_GROUP_NULL_SUFFIX = "network group to null";

@Override
protected Function<RustRconResponse, Optional<OxidePluginEvent>> eventParser() {
Expand All @@ -38,6 +41,10 @@ public boolean supports(@NonNull RustRconResponse payload) {
return false;
}

if (message.endsWith(GENERIC_SUFFIX) || message.endsWith(DESTROYING_SUFFIX) || message.endsWith(NETWORK_GROUP_NULL_SUFFIX)) {
return false;
}

if (message.matches(EVENT_PATTERN)) {
final var prefix = message.substring(message.indexOf('['), message.indexOf(']') + 1);
return !prefix.equals(NATIVE_EVENT_PREFIX)
Expand Down

0 comments on commit 7c470af

Please sign in to comment.