From 2d042e52f23e1954654cc719f5c77de2427f08b7 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 21 Mar 2016 09:00:28 +1100 Subject: [PATCH] Start work on making whether pillar is allowed per-level configurable. --- .../Fun/{CmdMapAuthors.cs => CmdMapSet.cs} | 18 ++++++++++++------ Games/ZombieSurvival/ZombieGame.Game.cs | 4 ++-- Levels/IO/LvlProperties.cs | 3 +++ Levels/Level.cs | 2 ++ MCGalaxy_.csproj | 2 +- Server/Server.cs | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) rename Commands/Fun/{CmdMapAuthors.cs => CmdMapSet.cs} (70%) diff --git a/Commands/Fun/CmdMapAuthors.cs b/Commands/Fun/CmdMapSet.cs similarity index 70% rename from Commands/Fun/CmdMapAuthors.cs rename to Commands/Fun/CmdMapSet.cs index ef7311c9d..f031f7a62 100644 --- a/Commands/Fun/CmdMapAuthors.cs +++ b/Commands/Fun/CmdMapSet.cs @@ -21,9 +21,9 @@ using System.Threading; namespace MCGalaxy.Commands { - public sealed class CmdMapAuthor : Command { - public override string name { get { return "mapauthors"; } } - public override string shortcut { get { return "authors"; } } + public sealed class CmdMapSet : Command { + public override string name { get { return "mapset"; } } + public override string shortcut { get { return "mset"; } } public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } @@ -31,14 +31,20 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { if (p == null) { MessageInGameOnly(p); return; } - p.level.Authors = message; - Player.SendMessage(p, "Sets the authors of the map to: " + message.Replace(" ", "%S, ")); + if (message == "") { + Player.SendMessage(p, "Map authors: " + p.level.Authors); + Player.SendMessage(p, "Pillaring allowed: " + p.level.Pillaring); + } + p.level.Authors = message.Replace(" ", "%S, ") + Player.SendMessage(p, "Sets the authors of the map to: " + message); } public override void Help(Player p) { - Player.SendMessage(p, "%T/mapauthors [name1] ..."); + Player.SendMessage(p, "%T/mapset author [name1] ..."); Player.SendMessage(p, "%HSets the authors of the current map. " + "This is shown to players at the start of rounds in various games."); + Player.SendMessage(p, "%T/mapset pillaring [true/false]"); + Player.SendMessage(p, "%HSets whether players can pillar on this map in various games."); } } } diff --git a/Games/ZombieSurvival/ZombieGame.Game.cs b/Games/ZombieSurvival/ZombieGame.Game.cs index 87ca994bb..250e9b694 100644 --- a/Games/ZombieSurvival/ZombieGame.Game.cs +++ b/Games/ZombieSurvival/ZombieGame.Game.cs @@ -24,7 +24,7 @@ namespace MCGalaxy.Games { public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z, byte action, byte tile, byte b) { - if (action == 1 && noPillaring && !p.referee) { + if (action == 1 && !CurrentLevel.Pillaring && !p.referee) { if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) { p.blocksStacked++; } else { @@ -112,7 +112,7 @@ namespace MCGalaxy.Games { p.SendMessage("This map has &a" + CurrentLevel.Likes + " likes %Sand &c" + CurrentLevel.Dislikes + " dislikes"); if (CurrentLevel.Authors != "") - p.SendMessage("It was created by " + CurrentLevel.Authors.Replace(" ", "%S, ")); + p.SendMessage("It was created by " + CurrentLevel.Authors); p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys); UpdatePlayerStatus(p); return; diff --git a/Levels/IO/LvlProperties.cs b/Levels/IO/LvlProperties.cs index aa5be5701..f14847e35 100644 --- a/Levels/IO/LvlProperties.cs +++ b/Levels/IO/LvlProperties.cs @@ -83,6 +83,7 @@ namespace MCGalaxy.Levels.IO { writer.WriteLine("Likes = " + level.Likes); writer.WriteLine("Dislikes = " + level.Dislikes); writer.WriteLine("Authors = " + level.Authors); + writer.WriteLine("Pillaring = " + level.Pillaring); } static string GetName(LevelPermission perm) { @@ -225,6 +226,8 @@ namespace MCGalaxy.Levels.IO { level.Dislikes = int.Parse(value); break; case "authors": level.Authors = value; break; + case "pillaring": + level.Pillaring = bool.Parse(value); break; } } diff --git a/Levels/Level.cs b/Levels/Level.cs index 206d844b1..038b6d33c 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -204,8 +204,10 @@ namespace MCGalaxy BufferedBlockSender bulkSender; public List C4list = new List(); + // Games fields public int Likes, Dislikes; public string Authors = ""; + public bool Pillaring = !Server.zombie.noPillaring; public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false) { diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index bb5936a3b..dd24091f4 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -182,7 +182,7 @@ - + diff --git a/Server/Server.cs b/Server/Server.cs index 12636d4c7..100153217 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -412,7 +412,7 @@ namespace MCGalaxy if (File.Exists("externalurl.txt")) File.Move("externalurl.txt", "text/externalurl.txt"); if (File.Exists("autoload.txt")) File.Move("autoload.txt", "text/autoload.txt"); if (File.Exists("IRC_Controllers.txt")) File.Move("IRC_Controllers.txt", "ranks/IRC_Controllers.txt"); - if (useWhitelist) if (File.Exists("whitelist.txt")) File.Move("whitelist.txt", "ranks/whitelist.txt"); + if (useWhitelist && File.Exists("whitelist.txt")) File.Move("whitelist.txt", "ranks/whitelist.txt"); } catch { } Chat.LoadCustomTokens();