mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Only save ignore files when using /ignore, not everytime you leave the server.
This commit is contained in:
parent
679a213570
commit
591d11d528
@ -17,7 +17,9 @@
|
|||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands {
|
namespace MCGalaxy.Commands {
|
||||||
|
|
||||||
public sealed class CmdIgnore : Command {
|
public sealed class CmdIgnore : Command {
|
||||||
@ -38,21 +40,21 @@ namespace MCGalaxy.Commands {
|
|||||||
if (action == "all") {
|
if (action == "all") {
|
||||||
p.ignoreAll = !p.ignoreAll;
|
p.ignoreAll = !p.ignoreAll;
|
||||||
Player.Message(p, "{0} ignoring all chat", p.ignoreAll ? "&cNow " : "&aNo longer ");
|
Player.Message(p, "{0} ignoring all chat", p.ignoreAll ? "&cNow " : "&aNo longer ");
|
||||||
CreateIgnoreFile(p); return;
|
SaveIgnores(p); return;
|
||||||
} else if (action == "irc") {
|
} else if (action == "irc") {
|
||||||
p.ignoreIRC = !p.ignoreIRC;
|
p.ignoreIRC = !p.ignoreIRC;
|
||||||
Player.Message(p, "{0} ignoring IRC chat", p.ignoreIRC ? "&cNow " : "&aNo longer ");
|
Player.Message(p, "{0} ignoring IRC chat", p.ignoreIRC ? "&cNow " : "&aNo longer ");
|
||||||
CreateIgnoreFile(p); return;
|
SaveIgnores(p); return;
|
||||||
} else if (action == "titles") {
|
} else if (action == "titles") {
|
||||||
p.ignoreTitles = !p.ignoreTitles;
|
p.ignoreTitles = !p.ignoreTitles;
|
||||||
Player.Message(p, "{0} show before names in chat",
|
Player.Message(p, "{0} show before names in chat",
|
||||||
p.ignoreTitles ? "&cPlayer titles no longer" : "&aPlayer titles now");
|
p.ignoreTitles ? "&cPlayer titles no longer" : "&aPlayer titles now");
|
||||||
CreateIgnoreFile(p); return;
|
SaveIgnores(p); return;
|
||||||
} else if (action == "nicks") {
|
} else if (action == "nicks") {
|
||||||
p.ignoreNicks = !p.ignoreNicks;
|
p.ignoreNicks = !p.ignoreNicks;
|
||||||
Player.Message(p, "{0} show in chat",
|
Player.Message(p, "{0} show in chat",
|
||||||
p.ignoreNicks ? "&cCustom player nicks no longer" : "&aCustom player nicks");
|
p.ignoreNicks ? "&cCustom player nicks no longer" : "&aCustom player nicks");
|
||||||
CreateIgnoreFile(p); return;
|
SaveIgnores(p); return;
|
||||||
} else if (action == "list") {
|
} else if (action == "list") {
|
||||||
Player.Message(p, "&cCurrently ignoring the following players:");
|
Player.Message(p, "&cCurrently ignoring the following players:");
|
||||||
string names = p.listignored.Join();
|
string names = p.listignored.Join();
|
||||||
@ -64,7 +66,6 @@ namespace MCGalaxy.Commands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateIgnoreFile(p);
|
|
||||||
string unignore = null;
|
string unignore = null;
|
||||||
for (int i = 0; i < p.listignored.Count; i++) {
|
for (int i = 0; i < p.listignored.Count; i++) {
|
||||||
if (!action.CaselessEq(p.listignored[i])) continue;
|
if (!action.CaselessEq(p.listignored[i])) continue;
|
||||||
@ -92,12 +93,28 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.Message(p, "&cNow ignoring {0}", who.ColoredName);
|
Player.Message(p, "&cNow ignoring {0}", who.ColoredName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SaveIgnores(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateIgnoreFile(Player p) {
|
static void SaveIgnores(Player p) {
|
||||||
string path = "ranks/ignore/" + p.name + ".txt";
|
string path = "ranks/ignore/" + p.name + ".txt";
|
||||||
if (!Directory.Exists("ranks/ignore")) Directory.CreateDirectory("ranks/ignore");
|
if (!Directory.Exists("ranks/ignore"))
|
||||||
if (!File.Exists(path)) File.Create(path).Dispose();
|
Directory.CreateDirectory("ranks/ignore");
|
||||||
|
|
||||||
|
try {
|
||||||
|
using (StreamWriter w = new StreamWriter(path)) {
|
||||||
|
if (p.ignoreAll) w.WriteLine("&all");
|
||||||
|
if (p.ignoreIRC) w.WriteLine("&irc");
|
||||||
|
if (p.ignoreTitles) w.WriteLine("&titles");
|
||||||
|
if (p.ignoreNicks) w.WriteLine("&nicks");
|
||||||
|
|
||||||
|
foreach (string line in p.listignored)
|
||||||
|
w.WriteLine(line);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Server.ErrorLog(ex);
|
||||||
|
Server.s.Log("Failed to save ignored list for player: " + p.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
@ -266,7 +266,6 @@ namespace MCGalaxy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// FlyBuffer.Clear();
|
// FlyBuffer.Clear();
|
||||||
SaveIgnores();
|
|
||||||
DisposeTimers();
|
DisposeTimers();
|
||||||
LastAction = DateTime.UtcNow;
|
LastAction = DateTime.UtcNow;
|
||||||
IsAfk = false;
|
IsAfk = false;
|
||||||
@ -516,26 +515,6 @@ namespace MCGalaxy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveIgnores() {
|
|
||||||
string path = "ranks/ignore/" + name + ".txt";
|
|
||||||
if (!File.Exists(path)) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
using (StreamWriter w = new StreamWriter(path)) {
|
|
||||||
if (ignoreAll) w.WriteLine("&all");
|
|
||||||
if (ignoreIRC) w.WriteLine("&irc");
|
|
||||||
if (ignoreTitles) w.WriteLine("&titles");
|
|
||||||
if (ignoreNicks) w.WriteLine("&nicks");
|
|
||||||
|
|
||||||
foreach (string line in listignored)
|
|
||||||
w.WriteLine(line);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Server.ErrorLog(ex);
|
|
||||||
Server.s.Log("Failed to save ignored list for player: " + name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void RemoveInvalidUndos() {
|
internal void RemoveInvalidUndos() {
|
||||||
UndoDrawOpEntry[] items = DrawOps.Items;
|
UndoDrawOpEntry[] items = DrawOps.Items;
|
||||||
for (int i = 0; i < items.Length; i++) {
|
for (int i = 0; i < items.Length; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user