Class FilterRule
java.lang.Object
ua.mcchickenstudio.opencreative.settings.filters.FilterRule
FilterRule
This class represents a filter rule, that has identifier, check settings, list of patterns and list of commands.-
Constructor Summary
ConstructorsConstructorDescriptionFilterRule(@NotNull String id, boolean warnPlayer, boolean notifyStaff, boolean checkChat, boolean checkAnvils, boolean checkBooks, boolean checkSigns, @NotNull FilterTextAction action, @NotNull String replacement, @NotNull List<Pattern> patterns, @NotNull List<Command> commands) -
Method Summary
Modifier and TypeMethodDescriptionvoidexecuteCommands(@NotNull org.bukkit.entity.Player player, @NotNull String content, @NotNull String result, @NotNull String context) Executes violation commands on player.@NotNull FilterResultfilterText(@NotNull String text, Filter.Context context) Filters text and returns a filter result.@NotNull StringgetId()@Nullable StringChecks whether text matches and violates the rule.voidonViolation(@NotNull org.bukkit.entity.Player player, @NotNull FilterResult result) Executes actions when text violated the rule.booleanChecks whether renaming item in anvil should be checked.booleanChecks whether editing book's content should be checked.booleanChecks whether chat messages should be checked.booleanChecks whether editing sign's text should be checked.
-
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
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
-