mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Allow custom profanity filter replacement
This commit is contained in:
parent
800fe69e5f
commit
201fc8a927
@ -51,12 +51,17 @@ namespace MCGalaxy {
|
|||||||
if (!isFiltered) continue;
|
if (!isFiltered) continue;
|
||||||
|
|
||||||
// If a bad word is found anywhere in the word, replace the word
|
// If a bad word is found anywhere in the word, replace the word
|
||||||
int length = words[i].Length;
|
words[i] = Replace(words[i]);
|
||||||
words[i] = "&c[&fBlocked&c]&f";
|
|
||||||
}
|
}
|
||||||
return String.Join(" ", words);
|
return String.Join(" ", words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string Replace(string word) {
|
||||||
|
string replacement = Server.Config.ProfanityReplacement;
|
||||||
|
// for * repeat to ****
|
||||||
|
return replacement.Length == 1 ? new string(replacement[0], word.Length) : replacement;
|
||||||
|
}
|
||||||
|
|
||||||
static void InitReduceTable() {
|
static void InitReduceTable() {
|
||||||
if (reduceKeys != null) return;
|
if (reduceKeys != null) return;
|
||||||
// Because some letters are similar (Like i and l), they are reduced to the same form.
|
// Because some letters are similar (Like i and l), they are reduced to the same form.
|
||||||
|
@ -201,6 +201,8 @@ namespace MCGalaxy {
|
|||||||
internal List<string> DisabledChatTokens = new List<string>();
|
internal List<string> DisabledChatTokens = new List<string>();
|
||||||
[ConfigBool("profanity-filter", "Other", false)]
|
[ConfigBool("profanity-filter", "Other", false)]
|
||||||
public bool ProfanityFiltering = false;
|
public bool ProfanityFiltering = false;
|
||||||
|
[ConfigString("profanity-replacement", "Other", "*")]
|
||||||
|
public string ProfanityReplacement = "*";
|
||||||
[ConfigString("host-state", "Other", "Alive")]
|
[ConfigString("host-state", "Other", "Alive")]
|
||||||
public string ConsoleName = "Alive";
|
public string ConsoleName = "Alive";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user