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);
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();
if (parts.Length != 7) continue;
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();
// 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;
foreach (string filter in filters) {
foreach (string filter in filters)
{
if (reduced[i].Contains(filter)) {
isFiltered = true; break;
}
@ -79,7 +81,8 @@ namespace MCGalaxy {
string[] lines = filterFile.GetText();
filters = new List<string>();
// 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;
string word = Reduce(line);

View File

@ -65,8 +65,9 @@ namespace MCGalaxy.Drawing
List<PaletteEntry> entries = new List<PaletteEntry>();
string[] parts = new string[5];
foreach (string line in lines) {
if (line.StartsWith("#") || line.Length == 0) continue;
foreach (string line in lines)
{
if (line.IsCommentLine()) continue;
line.FixedSplit(parts, ':');
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) {
if (p.Game.Referee || GameOn(p.level) == null)
return true;
IGame game = GameOn(p.level);
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);
return false;

View File

@ -264,7 +264,8 @@ namespace MCGalaxy.Modules.Relay
"# 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);
}
}