-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
bukkit/src/main/java/io/wdsj/asw/bukkit/core/condition/WordResultConditionNumMatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.wdsj.asw.bukkit.core.condition; | ||
|
||
import com.github.houbb.heaven.util.lang.CharUtil; | ||
import com.github.houbb.sensitive.word.api.IWordContext; | ||
import com.github.houbb.sensitive.word.api.IWordResult; | ||
import com.github.houbb.sensitive.word.constant.enums.WordValidModeEnum; | ||
import com.github.houbb.sensitive.word.support.resultcondition.AbstractWordResultCondition; | ||
|
||
public class WordResultConditionNumMatch extends AbstractWordResultCondition { | ||
@Override | ||
protected boolean doMatch(IWordResult wordResult, String text, WordValidModeEnum modeEnum, IWordContext context) { | ||
final int startIndex = wordResult.startIndex(); | ||
final int endIndex = wordResult.endIndex(); | ||
if (startIndex > 0) { | ||
char preC = text.charAt(startIndex-1); | ||
if (CharUtil.isDigit(preC)) { | ||
return false; | ||
} | ||
} | ||
if (endIndex < text.length()) { | ||
char afterC = text.charAt(endIndex); | ||
if (CharUtil.isDigit(afterC)) { | ||
return false; | ||
} | ||
} | ||
for (int i = startIndex; i < endIndex; i++) { | ||
char c = text.charAt(i); | ||
if (!CharUtil.isDigit(c)) { | ||
return true; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters