From 290189d3c43bc7a5d3dd1a1a5bbaf4a11a93445c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 15 Mar 2016 13:58:15 +1100 Subject: [PATCH] Cleanup /freeze and /trust. --- Commands/Information/CmdWhois.cs | 2 +- Commands/Moderation/CmdBan.cs | 4 +-- Commands/Moderation/CmdFreeze.cs | 35 +++++++++----------- Commands/Moderation/CmdTrust.cs | 24 +++++--------- Commands/other/CmdFakerank.cs | 6 ++-- {Server/Extra => Economy}/Awards.cs | 0 {Server/Extra => Economy}/Economy.cs | 0 Economy/Item.cs | 43 +++++++++++++++++++++++++ Games/ZombieSurvival/ZombieGame.Game.cs | 3 +- MCGalaxy_.csproj | 6 ++-- Player/Player.cs | 2 ++ 11 files changed, 80 insertions(+), 45 deletions(-) rename {Server/Extra => Economy}/Awards.cs (100%) rename {Server/Extra => Economy}/Economy.cs (100%) create mode 100644 Economy/Item.cs diff --git a/Commands/Information/CmdWhois.cs b/Commands/Information/CmdWhois.cs index 2c183d6f9..6c0611fe7 100644 --- a/Commands/Information/CmdWhois.cs +++ b/Commands/Information/CmdWhois.cs @@ -40,7 +40,7 @@ namespace MCGalaxy.Commands Player.SendMessage(p, who.color + who.name + " %S(" + who.DisplayName + ") %Sis on &b" + who.level.name); Player.SendMessage(p, who.FullName + Server.DefaultColor + " %Shas :"); Player.SendMessage(p, "> > the rank of " + who.group.color + who.group.name); - if (Economy.Settings.Enabled)) + if (Economy.Settings.Enabled) Player.SendMessage(p, "> > &a" + who.money + Server.DefaultColor + " " + Server.moneys); Player.SendMessage(p, "> > &cdied &a" + who.overallDeath + Server.DefaultColor + " times"); diff --git a/Commands/Moderation/CmdBan.cs b/Commands/Moderation/CmdBan.cs index 6e5b96d5a..389942080 100644 --- a/Commands/Moderation/CmdBan.cs +++ b/Commands/Moderation/CmdBan.cs @@ -67,10 +67,10 @@ namespace MCGalaxy.Commands { Player.GlobalMessage(banMsg); } else { if (stealth) { - banMsg = who.FullName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason; + banMsg = who.ColoredName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason; Chat.GlobalMessageOps(banMsg); } else { - banMsg = who.FullName + " %Swas &8banned %Sby " + banner + "%S." + banReason; + banMsg = who.ColoredName + " %Swas &8banned %Sby " + banner + "%S." + banReason; Player.GlobalMessage(banMsg); } diff --git a/Commands/Moderation/CmdFreeze.cs b/Commands/Moderation/CmdFreeze.cs index 0636229de..86e2cb8e8 100644 --- a/Commands/Moderation/CmdFreeze.cs +++ b/Commands/Moderation/CmdFreeze.cs @@ -26,30 +26,27 @@ namespace MCGalaxy.Commands public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public CmdFreeze() { } - public override void Use(Player p, string message) - { + public override void Use(Player p, string message) { if (message == "") { Help(p); return; } - Player who = PlayerInfo.Find(message); - if (who == null) { Player.SendMessage(p, "Could not find player."); return; } - else if (who == p) { Player.SendMessage(p, "Cannot freeze yourself."); return; } - else if (p != null) { if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot freeze someone of equal or greater rank."); return; } } - string frozenby = (p == null) ? "" : p.color + p.DisplayName; - - if (!who.frozen) - { - who.frozen = true; - Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &bfrozen" + Server.DefaultColor + " by " + frozenby + Server.DefaultColor + ".", false); - Server.s.Log(who.name + " has been frozen by " + frozenby); + Player who = PlayerInfo.FindOrShowMatches(message); + if (who == null) return; + if (p == who) { Player.SendMessage(p, "Cannot freeze yourself."); return; } + if (p != nul && who.group.Permission >= p.group.Permission) { + Player.SendMessage(p, "Cannot freeze someone of equal or greater rank."); return; } - else - { - who.frozen = false; - Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &adefrosted" + Server.DefaultColor + " by " + frozenby + Server.DefaultColor + ".", false); + + string frozenby = (p == null) ? "(console)" : p.ColoredName; + if (!who.frozen) { + Player.SendChatFrom(who, who.ColoredName + " %Shas been &bfrozen %Sby " + frozenby + "%S.", false); + Server.s.Log(who.name + " has been frozen by " + frozenby); + } else { + Player.SendChatFrom(who, who.ColoredName + " %Shas been &adefrosted %Sby " + frozenby + "%S.", false); Server.s.Log(who.name + " has been defrosted by " + frozenby); } + who.frozen = !who.frozen; } - public override void Help(Player p) - { + + public override void Help(Player p) { Player.SendMessage(p, "/freeze - Stops from moving until unfrozen."); } } diff --git a/Commands/Moderation/CmdTrust.cs b/Commands/Moderation/CmdTrust.cs index 1523c8bca..6171ceef3 100644 --- a/Commands/Moderation/CmdTrust.cs +++ b/Commands/Moderation/CmdTrust.cs @@ -26,25 +26,17 @@ namespace MCGalaxy.Commands public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public CmdTrust() { } - public override void Use(Player p, string message) - { + public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; } - Player who = PlayerInfo.Find(message); - if (who == null) - { - Player.SendMessage(p, "Could not find player specified"); - return; - } - else - { - who.ignoreGrief = !who.ignoreGrief; - Player.SendMessage(p, who.color + who.DisplayName + Server.DefaultColor + "'s trust status: " + who.ignoreGrief); - who.SendMessage("Your trust status was changed to: " + who.ignoreGrief); - } + Player who = PlayerInfo.FindOrShowMatches(p, message); + if (who == null) return; + who.ignoreGrief = !who.ignoreGrief; + Player.SendMessage(p, who.ColoredName + "%S's trust status: " + who.ignoreGrief); + who.SendMessage("Your trust status was changed to: " + who.ignoreGrief); } - public override void Help(Player p) - { + + public override void Help(Player p) { Player.SendMessage(p, "/trust - Turns off the anti-grief for "); } } diff --git a/Commands/other/CmdFakerank.cs b/Commands/other/CmdFakerank.cs index 7a396a5de..55080e3de 100644 --- a/Commands/other/CmdFakerank.cs +++ b/Commands/other/CmdFakerank.cs @@ -37,10 +37,10 @@ namespace MCGalaxy.Commands } if (grp.Permission == LevelPermission.Banned) { - string banner = p == null ? "console" : p.color + p.DisplayName; - Player.GlobalMessage(who.FullName + " %Swas &8banned" + " %Sby " + banner + "%S."); + string banner = p == null ? "console" : p.FullName; + Player.GlobalMessage(who.ColoredName + " %Swas &8banned %Sby " + banner + "%S."); } else { - Player.GlobalMessage(who.color + who.DisplayName + "%S's rank was set to " + + Player.GlobalMessage(who.ColoredName + "%S's rank was set to " + grp.color + grp.name + "%S. (Congratulations!)"); who.SendMessage("You are now ranked " + grp.color + grp.name + "%S, type /help for your new set of commands."); } diff --git a/Server/Extra/Awards.cs b/Economy/Awards.cs similarity index 100% rename from Server/Extra/Awards.cs rename to Economy/Awards.cs diff --git a/Server/Extra/Economy.cs b/Economy/Economy.cs similarity index 100% rename from Server/Extra/Economy.cs rename to Economy/Economy.cs diff --git a/Economy/Item.cs b/Economy/Item.cs new file mode 100644 index 000000000..65e4e11f9 --- /dev/null +++ b/Economy/Item.cs @@ -0,0 +1,43 @@ +/* + 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.IO; + +namespace MCGalaxy { + + /// An abstract object that can be bought in the economy. (e.g. a rank, title, levels, etc) + public abstract class Item { + + /// Simple name for this item. + public abstract string Name { get; } + + /// Other common names for this item. + public abstract string[] Aliases { get; } + + /// Whether this item can currently be bought in the economy. + public bool Enabled { get; set; } + + /// Reads the properties of this item from the economy.properties file. + public abstract void Parse(StreamReader reader); + + /// Writes the properties of this item to the economy.properties file. + public virtual void Serialise(StreamWriter writer) { + writer.WriteLine(Name + ":enabled:" + Enabled); + } + } +} diff --git a/Games/ZombieSurvival/ZombieGame.Game.cs b/Games/ZombieSurvival/ZombieGame.Game.cs index 2c2c70a37..ce65ab162 100644 --- a/Games/ZombieSurvival/ZombieGame.Game.cs +++ b/Games/ZombieSurvival/ZombieGame.Game.cs @@ -35,8 +35,7 @@ namespace MCGalaxy { p.SendMessage("You are pillaring! Stop before you get kicked!"); } if (p.blocksStacked == 4 ) { - p.Kick(" No pillaring allowed!"); - return true; + p.Kick("No pillaring allowed!"); return true; } } p.lastXblock = x; p.lastYblock = y; p.lastZblock = z; diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index bb2f1db08..7c4adaabd 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -411,6 +411,9 @@ + + + @@ -522,10 +525,8 @@ - - Form @@ -729,6 +730,7 @@ + diff --git a/Player/Player.cs b/Player/Player.cs index d673d47fa..e3f21adaf 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -106,6 +106,8 @@ namespace MCGalaxy { public bool hackrank; public string FullName { get { return color + prefix + DisplayName; } } + + public string ColoredName { get { return color + DisplayName; } } //Gc checks public string lastmsg = "";