Games can now override the respawn prevention behaviour

This commit is contained in:
UnknownShadow200 2023-12-27 20:50:57 +11:00
parent c771fe78a8
commit 170deda2f4
5 changed files with 19 additions and 9 deletions

View File

@ -275,7 +275,8 @@ namespace MCGalaxy {
string[] lines = File.ReadAllLines(Paths.CustomColorsFile); string[] lines = File.ReadAllLines(Paths.CustomColorsFile);
ColorDesc col = default(ColorDesc); ColorDesc col = default(ColorDesc);
for (int i = 0; i < lines.Length; i++) { for (int i = 0; i < lines.Length; i++)
{
string[] parts = lines[i].SplitSpaces(); string[] parts = lines[i].SplitSpaces();
if (parts.Length != 7) continue; if (parts.Length != 7) continue;
col.Code = parts[0][0]; col.Fallback = parts[1][0]; col.Name = parts[2]; col.Code = parts[0][0]; col.Fallback = parts[1][0]; col.Name = parts[2];

View File

@ -38,9 +38,11 @@ namespace MCGalaxy {
string[] reduced = Reduce(text).SplitSpaces(); string[] reduced = Reduce(text).SplitSpaces();
// Loop through each reduced word, looking for a bad word // Loop through each reduced word, looking for a bad word
for (int i = 0; i < reduced.Length; i++) { for (int i = 0; i < reduced.Length; i++)
{
bool isFiltered = false; bool isFiltered = false;
foreach (string filter in filters) { foreach (string filter in filters)
{
if (reduced[i].Contains(filter)) { if (reduced[i].Contains(filter)) {
isFiltered = true; break; isFiltered = true; break;
} }
@ -79,7 +81,8 @@ namespace MCGalaxy {
string[] lines = filterFile.GetText(); string[] lines = filterFile.GetText();
filters = new List<string>(); filters = new List<string>();
// Run the badwords through the reducer to ensure things like Ls become Is and everything is lowercase // Run the badwords through the reducer to ensure things like Ls become Is and everything is lowercase
foreach (string line in lines) { foreach (string line in lines)
{
if (line.StartsWith("#") || line.Trim().Length == 0) continue; if (line.StartsWith("#") || line.Trim().Length == 0) continue;
string word = Reduce(line); string word = Reduce(line);

View File

@ -65,8 +65,9 @@ namespace MCGalaxy.Drawing
List<PaletteEntry> entries = new List<PaletteEntry>(); List<PaletteEntry> entries = new List<PaletteEntry>();
string[] parts = new string[5]; string[] parts = new string[5];
foreach (string line in lines) { foreach (string line in lines)
if (line.StartsWith("#") || line.Length == 0) continue; {
if (line.IsCommentLine()) continue;
line.FixedSplit(parts, ':'); line.FixedSplit(parts, ':');
if (parts[3] == null || parts[4] != null) continue; // not a proper line if (parts[3] == null || parts[4] != null) continue; // not a proper line

View File

@ -40,8 +40,12 @@ namespace MCGalaxy.Games
} }
public static bool CheckAllowed(Player p, string action) { public static bool CheckAllowed(Player p, string action) {
if (p.Game.Referee || GameOn(p.level) == null) IGame game = GameOn(p.level);
return true; return game == null || game.CheckRespawnAllowed(p, action);
}
protected virtual bool CheckRespawnAllowed(Player p, string action) {
if (p.Game.Referee) return true;
p.Message("&WYou cannot {0} &Wwhile a game is running", action); p.Message("&WYou cannot {0} &Wwhile a game is running", action);
return false; return false;

View File

@ -264,7 +264,8 @@ namespace MCGalaxy.Modules.Relay
"# Lines starting with \"#\" are ignored." }); "# Lines starting with \"#\" are ignored." });
} }
foreach (string line in File.ReadAllLines("text/irccmdblacklist.txt")) { foreach (string line in Utils.ReadAllLinesList("text/irccmdblacklist.txt"))
{
if (!line.IsCommentLine()) BannedCommands.Add(line); if (!line.IsCommentLine()) BannedCommands.Add(line);
} }
} }