Skip to content

Commit 0106473

Browse files
committed
Add core api
1 parent 6f3958a commit 0106473

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

paper/src/main/java/io/wdsj/asw/bukkit/api/AdvancedSensitiveWordsApi.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@SuppressWarnings("unused")
77
public final class AdvancedSensitiveWordsApi {
88
private static final ShadowBanApi SHADOW_BAN_API = new ShadowBanApi();
9+
private static final CoreApi CORE_API = new CoreApi();
910

1011
private AdvancedSensitiveWordsApi() {
1112
}
@@ -18,4 +19,13 @@ private AdvancedSensitiveWordsApi() {
1819
public static ShadowBanApi shadowBan() {
1920
return SHADOW_BAN_API;
2021
}
22+
23+
/**
24+
* Get the core API.
25+
*
26+
* @return core API
27+
*/
28+
public static CoreApi core() {
29+
return CORE_API;
30+
}
2131
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.wdsj.asw.bukkit.api;
2+
3+
import io.wdsj.asw.bukkit.AdvancedSensitiveWords;
4+
5+
import java.util.List;
6+
7+
@SuppressWarnings("unused")
8+
public final class CoreApi {
9+
CoreApi() {
10+
}
11+
12+
/**
13+
* Returns whether the plugin is initialized.
14+
*
15+
* @return true if the plugin is initialized, false otherwise
16+
*/
17+
public boolean isInitialized() {
18+
return AdvancedSensitiveWords.isInitialized;
19+
}
20+
21+
/**
22+
* Finds all sensitive words in the given text.
23+
* <p>
24+
* <b>Warning:</b> This method should be called after checking initialization state.
25+
*
26+
* @param text the text to search for sensitive words
27+
* @return a list of sensitive words found in the text
28+
* @see #isInitialized()
29+
*/
30+
public List<String> findSensitiveWords(String text) {
31+
return AdvancedSensitiveWords.sensitiveWordBs.findAll(text);
32+
}
33+
34+
/**
35+
* Replaces all sensitive words in the given text.
36+
* <p>
37+
* <b>Warning:</b> This method should be called after checking initialization state.
38+
*
39+
* @param text the text to replace sensitive words in
40+
* @return the text with sensitive words replaced
41+
* @see #isInitialized()
42+
*/
43+
public String replaceSensitiveWords(String text) {
44+
return AdvancedSensitiveWords.sensitiveWordBs.replace(text);
45+
}
46+
}

0 commit comments

Comments
 (0)