From 2e1aa7055dbeb7d0a5e345eacba984bd0d416435 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 21 Mar 2016 07:57:09 +1100 Subject: [PATCH] Add /mapauthors command for zombie and lava survival. --- Commands/Fun/CmdMapAuthors.cs | 44 +++++++++++++++++++++++++ Commands/Fun/RateMapCmds.cs | 4 +-- Games/LavaSurvival/LavaSurvival.cs | 1 + Games/ZombieSurvival/ZombieGame.Game.cs | 2 ++ Levels/IO/LvlProperties.cs | 6 ++++ Levels/Level.cs | 1 + MCGalaxy_.csproj | 1 + 7 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 Commands/Fun/CmdMapAuthors.cs diff --git a/Commands/Fun/CmdMapAuthors.cs b/Commands/Fun/CmdMapAuthors.cs new file mode 100644 index 000000000..ef7311c9d --- /dev/null +++ b/Commands/Fun/CmdMapAuthors.cs @@ -0,0 +1,44 @@ +/* + Copyright 2015 MCGalaxy + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +using System; +using System.Collections.Generic; +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 override string type { get { return CommandTypes.Games; } } + public override bool museumUsable { get { return true; } } + public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } + public override bool Enabled { get { return Server.ZombieModeOn || Server.lava.active; } } + + 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, ")); + } + + public override void Help(Player p) { + Player.SendMessage(p, "%T/mapauthors [name1] ..."); + Player.SendMessage(p, "%HSets the authors of the current map. " + + "This is shown to players at the start of rounds in various games."); + } + } +} diff --git a/Commands/Fun/RateMapCmds.cs b/Commands/Fun/RateMapCmds.cs index a1376f4de..40b386668 100644 --- a/Commands/Fun/RateMapCmds.cs +++ b/Commands/Fun/RateMapCmds.cs @@ -21,7 +21,7 @@ using System.Threading; namespace MCGalaxy.Commands { - public sealed class MapLikeCmd : Command { + public sealed class CmdMapLike : Command { public override string name { get { return "maplike"; } } public override string shortcut { get { return "like"; } } public override string type { get { return CommandTypes.Games; } } @@ -43,7 +43,7 @@ namespace MCGalaxy.Commands { } } - public sealed class MapDislikeCmd : Command { + public sealed class CmdMapDislike : Command { public override string name { get { return "mapdislike"; } } public override string shortcut { get { return "dislike"; } } public override string type { get { return CommandTypes.Games; } } diff --git a/Games/LavaSurvival/LavaSurvival.cs b/Games/LavaSurvival/LavaSurvival.cs index aca5902d7..bb4acdaeb 100644 --- a/Games/LavaSurvival/LavaSurvival.cs +++ b/Games/LavaSurvival/LavaSurvival.cs @@ -302,6 +302,7 @@ namespace MCGalaxy.Games { Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { + pl.ratedMap = false; if (pl.level == oldMap) { if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, ""); diff --git a/Games/ZombieSurvival/ZombieGame.Game.cs b/Games/ZombieSurvival/ZombieGame.Game.cs index 7ff967fed..87ca994bb 100644 --- a/Games/ZombieSurvival/ZombieGame.Game.cs +++ b/Games/ZombieSurvival/ZombieGame.Game.cs @@ -111,6 +111,8 @@ namespace MCGalaxy.Games { p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!"); 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.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 3b5173597..aa5be5701 100644 --- a/Levels/IO/LvlProperties.cs +++ b/Levels/IO/LvlProperties.cs @@ -61,6 +61,7 @@ namespace MCGalaxy.Levels.IO { writer.WriteLine("Unload = " + level.unload); writer.WriteLine("WorldChat = " + level.worldChat); + writer.WriteLine(); writer.WriteLine("PerBuild = " + GetName(level.permissionbuild)); writer.WriteLine("PerVisit = " + GetName(level.permissionvisit)); writer.WriteLine("PerBuildMax = " + GetName(level.perbuildmax)); @@ -68,6 +69,7 @@ namespace MCGalaxy.Levels.IO { writer.WriteLine("Buildable = " + level.Buildable); writer.WriteLine("Deletable = " + level.Deletable); + writer.WriteLine(); writer.WriteLine("Guns = " + level.guns); writer.WriteLine("LoadOnGoto = " + level.loadOnGoto); writer.WriteLine("LeafDecay = " + level.leafDecay); @@ -77,8 +79,10 @@ namespace MCGalaxy.Levels.IO { writer.WriteLine("Texture = " + level.terrainUrl); writer.WriteLine("TexturePack = " + level.texturePackUrl); + writer.WriteLine(); writer.WriteLine("Likes = " + level.Likes); writer.WriteLine("Dislikes = " + level.Dislikes); + writer.WriteLine("Authors = " + level.Authors); } static string GetName(LevelPermission perm) { @@ -219,6 +223,8 @@ namespace MCGalaxy.Levels.IO { level.Likes = int.Parse(value); break; case "dislikes": level.Dislikes = int.Parse(value); break; + case "authors": + level.Authors = value; break; } } diff --git a/Levels/Level.cs b/Levels/Level.cs index b102b63a7..206d844b1 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -205,6 +205,7 @@ namespace MCGalaxy public List C4list = new List(); public int Likes, Dislikes; + public string Authors = ""; 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 d1d93e451..bb5936a3b 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -182,6 +182,7 @@ +