mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Changing custom chat tokens and bad words list in GUI should update live server state immediately.
This commit is contained in:
parent
57d34b9c68
commit
9cb259fd32
@ -104,11 +104,17 @@ namespace MCGalaxy {
|
||||
};
|
||||
|
||||
public static List<ChatToken> Custom = new List<ChatToken>();
|
||||
static bool hookedCustom;
|
||||
internal static void LoadCustom() {
|
||||
Custom.Clear();
|
||||
TextFile tokensFile = TextFile.Files["Custom $s"];
|
||||
tokensFile.EnsureExists();
|
||||
|
||||
if (!hookedCustom) {
|
||||
hookedCustom = true;
|
||||
tokensFile.OnTextChanged += LoadCustom;
|
||||
}
|
||||
|
||||
string[] lines = tokensFile.GetText();
|
||||
char[] colon = null;
|
||||
foreach (string line in lines) {
|
||||
|
@ -27,6 +27,7 @@ namespace MCGalaxy {
|
||||
public static class ProfanityFilter {
|
||||
static string[] reduceKeys, reduceValues;
|
||||
static List<string> filters;
|
||||
static bool hookedFilter;
|
||||
|
||||
public static void Init() {
|
||||
InitReduceTable();
|
||||
@ -69,6 +70,11 @@ namespace MCGalaxy {
|
||||
static void LoadBadWords() {
|
||||
TextFile filterFile = TextFile.Files["Profanity filter"];
|
||||
filterFile.EnsureExists();
|
||||
|
||||
if (!hookedFilter) {
|
||||
hookedFilter = true;
|
||||
filterFile.OnTextChanged += LoadBadWords;
|
||||
}
|
||||
|
||||
string[] lines = filterFile.GetText();
|
||||
filters = new List<string>();
|
||||
|
@ -30,6 +30,9 @@ namespace MCGalaxy.Util {
|
||||
/// <summary> Default text that the file contains. </summary>
|
||||
public readonly string[] DefaultText;
|
||||
|
||||
/// <summary> Callback invoked when contents of this file are changed. </summary>
|
||||
public Action OnTextChanged;
|
||||
|
||||
public TextFile(string filename, params string[] defaultText) {
|
||||
Filename = filename;
|
||||
DefaultText = defaultText;
|
||||
@ -59,6 +62,7 @@ namespace MCGalaxy.Util {
|
||||
/// <summary> Updates the text in this text file. </summary>
|
||||
public void SetText(string[] text) {
|
||||
File.WriteAllLines(Filename, text);
|
||||
if (OnTextChanged != null) OnTextChanged();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user