mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Convert the old /os blacklist txt files to VisitBlacklist in level properties.
This commit is contained in:
parent
94879791a8
commit
b97dc56257
@ -267,24 +267,13 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
Level.SaveSettings(p.level);
|
Level.SaveSettings(p.level);
|
||||||
Player.Message(p, value + " has been removed from your map's blacklist.");
|
Player.Message(p, value + " has been removed from your map's blacklist.");
|
||||||
} else if (cmd == "BLACKLIST") {
|
} else if (cmd == "BLACKLIST") {
|
||||||
string path = "levels/blacklists/" + p.level.name + ".txt";
|
|
||||||
if (!File.Exists(path)) {
|
|
||||||
Player.Message(p, "There are no blacklisted players on this map.");
|
|
||||||
} else {
|
|
||||||
Player.Message(p, "Current blocked players on level &b" + p.level.name + "%S:");
|
|
||||||
string blocked = "";
|
|
||||||
string[] lines = File.ReadAllLines(path);
|
|
||||||
foreach (string line in lines) {
|
|
||||||
string player = line.Split(' ')[1];
|
|
||||||
blocked += player + ", ";
|
|
||||||
}
|
|
||||||
Player.Message(p, blocked);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<string> blacklist = p.level.VisitAccess.Blacklisted;
|
List<string> blacklist = p.level.VisitAccess.Blacklisted;
|
||||||
if (blacklist.Count > 0)
|
if (blacklist.Count > 0) {
|
||||||
Player.Message(p, "Blacklisted players: " + blacklist.Join());
|
Player.Message(p, "Blacklisted players: " + blacklist.Join());
|
||||||
|
} else {
|
||||||
|
Player.Message(p, "There are no blacklisted players on this map.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Player.MessageLines(p, zoneHelp);
|
Player.MessageLines(p, zoneHelp);
|
||||||
}
|
}
|
||||||
|
@ -146,10 +146,6 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public bool CanJoin(Player p) {
|
public bool CanJoin(Player p) {
|
||||||
if (p == null) return true;
|
if (p == null) return true;
|
||||||
if (Player.BlacklistCheck(p.name, name)) {
|
|
||||||
Player.Message(p, "You are blacklisted from going to {0}.", name); return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!VisitAccess.CheckDetailed(p, p.ignorePermission)) return false;
|
if (!VisitAccess.CheckDetailed(p, p.ignorePermission)) return false;
|
||||||
if (File.Exists("text/lockdown/map/" + name)) {
|
if (File.Exists("text/lockdown/map/" + name)) {
|
||||||
Player.Message(p, "The level " + name + " is locked."); return false;
|
Player.Message(p, "The level " + name + " is locked."); return false;
|
||||||
|
@ -498,13 +498,6 @@ namespace MCGalaxy {
|
|||||||
CurrentAmountOfTnt--;
|
CurrentAmountOfTnt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool BlacklistCheck(string name, string foundLevel) {
|
|
||||||
string path = "levels/blacklists/" + foundLevel + ".txt";
|
|
||||||
if (!File.Exists(path)) return false;
|
|
||||||
if (File.ReadAllText(path).Contains(name)) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static bool CheckVote(string message, Player p, string a, string b, ref int totalVotes) {
|
internal static bool CheckVote(string message, Player p, string a, string b, ref int totalVotes) {
|
||||||
if (!p.voted && (message == a || message == b)) {
|
if (!p.voted && (message == a || message == b)) {
|
||||||
totalVotes++;
|
totalVotes++;
|
||||||
|
@ -70,7 +70,7 @@ namespace MCGalaxy {
|
|||||||
void LoadPlayerLists() {
|
void LoadPlayerLists() {
|
||||||
agreed = new PlayerList("ranks/agreed.txt");
|
agreed = new PlayerList("ranks/agreed.txt");
|
||||||
try {
|
try {
|
||||||
CheckOldAgreed();
|
UpgradeOldAgreed();
|
||||||
agreed = PlayerList.Load("agreed.txt");
|
agreed = PlayerList.Load("agreed.txt");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Server.ErrorLog(ex);
|
Server.ErrorLog(ex);
|
||||||
@ -95,7 +95,34 @@ namespace MCGalaxy {
|
|||||||
whiteList = PlayerList.Load("whitelist.txt");
|
whiteList = PlayerList.Load("whitelist.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckOldAgreed() {
|
static void UpgradeOldBlacklist() {
|
||||||
|
if (!Directory.Exists("levels/blacklists")) return;
|
||||||
|
string[] files = Directory.GetFiles("levels/blacklists");
|
||||||
|
for (int i = 0; i < files.Length; i++) {
|
||||||
|
string[] blacklist = File.ReadAllLines(files[i]);
|
||||||
|
List<string> names = new List<string>();
|
||||||
|
|
||||||
|
// Lines are in the format: day.month.year name+
|
||||||
|
foreach (string entry in blacklist) {
|
||||||
|
string[] parts = entry.Split(' ');
|
||||||
|
string name = parts[parts.Length - 1];
|
||||||
|
name = name.Substring(0, name.Length - 1);
|
||||||
|
names.Add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (names.Count > 0) {
|
||||||
|
string lvlName = Path.GetFileNameWithoutExtension(files[i]);
|
||||||
|
string propsPath = LevelInfo.PropertiesPath(lvlName);
|
||||||
|
using (StreamWriter w = new StreamWriter(propsPath, true)) {
|
||||||
|
w.WriteLine("VisitBlacklist = " + names.Join());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File.Delete(files[i]);
|
||||||
|
}
|
||||||
|
Directory.Delete("levels/blacklists");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UpgradeOldAgreed() {
|
||||||
// agreed.txt format used to be names separated by spaces, we need to fix that up.
|
// agreed.txt format used to be names separated by spaces, we need to fix that up.
|
||||||
if (!File.Exists("ranks/agreed.txt")) return;
|
if (!File.Exists("ranks/agreed.txt")) return;
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ namespace MCGalaxy {
|
|||||||
Background.QueueOnce(CombineEnvFiles);
|
Background.QueueOnce(CombineEnvFiles);
|
||||||
Background.QueueOnce(LoadMainLevel);
|
Background.QueueOnce(LoadMainLevel);
|
||||||
Plugin.Load();
|
Plugin.Load();
|
||||||
|
Background.QueueOnce(UpgradeOldBlacklist);
|
||||||
Background.QueueOnce(LoadPlayerLists);
|
Background.QueueOnce(LoadPlayerLists);
|
||||||
Background.QueueOnce(LoadAutoloadCommands);
|
Background.QueueOnce(LoadAutoloadCommands);
|
||||||
Background.QueueOnce(MovePreviousLevelFiles);
|
Background.QueueOnce(MovePreviousLevelFiles);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user