java.lang.Object
ua.mcchickenstudio.opencreative.settings.filters.FilterRule

public final class FilterRule extends Object

FilterRule

This class represents a filter rule, that has identifier, check settings, list of patterns and list of commands.
  • Constructor Details

    • FilterRule

      public FilterRule(@NotNull @NotNull String id, boolean warnPlayer, boolean notifyStaff, boolean checkChat, boolean checkAnvils, boolean checkBooks, boolean checkSigns, @NotNull @NotNull FilterTextAction action, @NotNull @NotNull String replacement, @NotNull @NotNull List<Pattern> patterns, @NotNull @NotNull List<Command> commands)
  • Method Details

    • matches

      @Nullable public @Nullable String matches(@NotNull @NotNull String text)
      Checks whether text matches and violates the rule.
      Parameters:
      text - text to check.
      Returns:
      true - text violates the rule, false - text is fine.
    • shouldCheckAnvils

      public boolean shouldCheckAnvils()
      Checks whether renaming item in anvil should be checked.
      Returns:
      true - should be checked, false - not.
    • shouldCheckBooks

      public boolean shouldCheckBooks()
      Checks whether editing book's content should be checked.
      Returns:
      true - should be checked, false - not.
    • shouldCheckChat

      public boolean shouldCheckChat()
      Checks whether chat messages should be checked.
      Returns:
      true - should be checked, false - not.
    • shouldCheckSigns

      public boolean shouldCheckSigns()
      Checks whether editing sign's text should be checked.
      Returns:
      true - should be checked, false - not.
    • filterText

      @NotNull public @NotNull FilterResult filterText(@NotNull @NotNull String text, @NotNull Filter.Context context)
      Filters text and returns a filter result.
      Parameters:
      text - text to check.
      context - context to check.
      Returns:
      a filter result.
    • onViolation

      public void onViolation(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull FilterResult result)
      Executes actions when text violated the rule.
      Parameters:
      player - player to do action.
      result - a filter result.
    • executeCommands

      public void executeCommands(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String content, @NotNull @NotNull String result, @NotNull @NotNull String context)
      Executes violation commands on player.
      Parameters:
      player - player to replace placeholders.
      content - initial content.
      result - censored content or same.
      context - context that was checked.
    • getId

      @NotNull public @NotNull String getId()