From 76acf539fcc015b2dfdd8a1e4f247089be186b62 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 15 Aug 2016 09:26:08 +1000 Subject: [PATCH] Make many commands use Chat.MessageAll --- Commands/CPE/CmdModel.cs | 2 +- Commands/CPE/CmdSkin.cs | 16 ++++----- Commands/Economy/CmdAward.cs | 4 +-- Commands/Economy/CmdAwardMod.cs | 4 +-- Commands/Economy/CmdFakePay.cs | 2 +- Commands/Fun/CmdCountdown.cs | 12 +++---- Commands/Fun/CmdCtf.cs | 4 +-- Commands/Fun/CmdFlipHeads.cs | 4 +-- Commands/Fun/ZombieSurvival/CmdDisinfect.cs | 2 +- Commands/Fun/ZombieSurvival/CmdInfect.cs | 2 +- Commands/Information/CmdAfk.cs | 4 +-- Commands/Moderation/CmdAllowGuns.cs | 4 +-- Commands/Moderation/CmdLimit.cs | 38 ++++++++++----------- Commands/Moderation/CmdLowlag.cs | 6 ++-- Commands/Moderation/CmdModerate.cs | 4 +-- Commands/Moderation/CmdMute.cs | 2 +- Commands/Moderation/CmdVoteKick.cs | 12 +++---- Commands/Moderation/CmdXJail.cs | 4 +-- Commands/Moderation/CmdXmute.cs | 2 +- Commands/World/CmdLoad.cs | 5 ++- Commands/World/CmdLockdown.cs | 8 ++--- Commands/World/CmdNewLvl.cs | 2 +- Commands/World/CmdPause.cs | 6 ++-- Commands/World/CmdRenameLvl.cs | 2 +- Commands/World/CmdUnflood.cs | 2 +- Games/ZombieSurvival/ZombieGame.Core.cs | 2 +- Games/ZombieSurvival/ZombieGame.cs | 2 +- Player/Player.Handlers.cs | 8 ++--- Player/Player.Login.cs | 6 ++-- Player/Player.cs | 17 +++------ 30 files changed, 89 insertions(+), 99 deletions(-) diff --git a/Commands/CPE/CmdModel.cs b/Commands/CPE/CmdModel.cs index 70c28bb06..4f0d7b53e 100644 --- a/Commands/CPE/CmdModel.cs +++ b/Commands/CPE/CmdModel.cs @@ -76,7 +76,7 @@ namespace MCGalaxy.Commands.CPE { if (isBot) { bot.model = model; Entities.UpdateModel(bot.id, model, bot.level, null); - Player.GlobalMessage("Bot " + bot.ColoredName + "'s %Smodel was changed to a &c" + model); + Chat.MessageAll("Bot {0}'s %Smodel was changed to a &c{1}", bot.ColoredName, model); BotsFile.UpdateBot(bot); } else { who.model = model; diff --git a/Commands/CPE/CmdSkin.cs b/Commands/CPE/CmdSkin.cs index 912c030b7..df9859dd6 100644 --- a/Commands/CPE/CmdSkin.cs +++ b/Commands/CPE/CmdSkin.cs @@ -36,14 +36,14 @@ namespace MCGalaxy.Commands.CPE { if (message == "") message = p.truename; Player who = p; - PlayerBot pBot = null; + PlayerBot bot = null; bool isBot = message.CaselessStarts("bot "); string[] args = message.SplitSpaces(isBot ? 3 : 2); string skin = null; if (isBot && args.Length > 2) { - pBot = PlayerBot.FindMatches(p, args[1]); - if (pBot == null) return; + bot = PlayerBot.FindMatches(p, args[1]); + if (bot == null) return; skin = args[2]; } else if (args.Length >= 2) { isBot = false; @@ -66,11 +66,11 @@ namespace MCGalaxy.Commands.CPE { skin = "http://skins.minecraft.net/MinecraftSkins/" + skin.Substring(1) + ".png"; if (isBot) { - pBot.SkinName = skin; - pBot.GlobalDespawn(); - pBot.GlobalSpawn(); - Player.GlobalMessage("Bot " + pBot.ColoredName + "'s %Sskin was changed to &c" + skin); - BotsFile.UpdateBot(pBot); + bot.SkinName = skin; + bot.GlobalDespawn(); + bot.GlobalSpawn(); + Chat.MessageAll("Bot {0}'s %Sskin was changed to &c{1}", bot.ColoredName, skin); + BotsFile.UpdateBot(bot); } else { who.skinName = skin; Entities.GlobalDespawn(who, true); diff --git a/Commands/Economy/CmdAward.cs b/Commands/Economy/CmdAward.cs index 13ebc0197..ea339e6ba 100644 --- a/Commands/Economy/CmdAward.cs +++ b/Commands/Economy/CmdAward.cs @@ -48,13 +48,13 @@ namespace MCGalaxy.Commands { if (!take) { if (Awards.GiveAward(plName, award)) { - Player.GlobalMessage(Server.FindColor(plName) + plName + " %Swas awarded: &b" + award); + Chat.MessageAll("{0}{1} %Swas awarded: &b{2}", Server.FindColor(plName), plName, award); } else { Player.Message(p, "The player already has that award."); return; } } else { if (Awards.TakeAward(plName, award)) { - Player.GlobalMessage(Server.FindColor(plName) + plName + " %Shad their &b" + award + " %Saward removed"); + Chat.MessageAll("{0}{1} %Shad their &b{2} %Saward removed", Server.FindColor(plName), plName, award); } else { Player.Message(p, "The player didn't have the award you tried to take"); return; } diff --git a/Commands/Economy/CmdAwardMod.cs b/Commands/Economy/CmdAwardMod.cs index 7ce270bae..e031df8e8 100644 --- a/Commands/Economy/CmdAwardMod.cs +++ b/Commands/Economy/CmdAwardMod.cs @@ -40,13 +40,13 @@ namespace MCGalaxy.Commands { if (!Awards.Add(args[0], args[1])) { Player.Message(p, "This award already exists."); return; } else { - Player.GlobalMessage("Award added: &6" + args[0] + " : " + args[1]); + Chat.MessageAll("Award added: &6{0} : {1}", args[0], args[1]); } } else { if (!Awards.Remove(args[1])) { Player.Message(p, "This award does not exist."); return; } else { - Player.GlobalMessage("Award removed: &6" + args[1]); + Chat.MessageAll("Award removed: &6{0}", args[1]); } } Awards.Save(); diff --git a/Commands/Economy/CmdFakePay.cs b/Commands/Economy/CmdFakePay.cs index 929842b7a..2d041863d 100644 --- a/Commands/Economy/CmdFakePay.cs +++ b/Commands/Economy/CmdFakePay.cs @@ -40,7 +40,7 @@ namespace MCGalaxy.Commands { if (amount < 0) { Player.Message(p, "You can't fakepay a negative amount."); return; } if (amount >= 16777215) { Player.Message(p, "You can only fakepay up to 16777215."); return; } - Player.GlobalMessage(who.ColoredName + " %Swas given " + amount + " " + Server.moneys); + Chat.MessageAll("{0} %Swas given {1} {2}", who.ColoredName, amount, Server.moneys); } public override void Help(Player p) { diff --git a/Commands/Fun/CmdCountdown.cs b/Commands/Fun/CmdCountdown.cs index 8d5ca5b6f..eb022942d 100644 --- a/Commands/Fun/CmdCountdown.cs +++ b/Commands/Fun/CmdCountdown.cs @@ -186,11 +186,11 @@ namespace MCGalaxy.Commands { Player.Message(p, "The last person alive will win!!"); } else if (hasPerm) { if (target == "all") { - Player.GlobalMessage("Countdown Rules being sent to everyone by " + p.ColoredName + ":"); - Player.GlobalMessage("The aim of the game is to stay alive the longest."); - Player.GlobalMessage("Don't fall in the lava!!"); - Player.GlobalMessage("Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappering."); - Player.GlobalMessage("The last person alive will win!!"); + Chat.MessageAll("Countdown Rules being sent to everyone by " + p.ColoredName + ":"); + Chat.MessageAll("The aim of the game is to stay alive the longest."); + Chat.MessageAll("Don't fall in the lava!!"); + Chat.MessageAll("Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappering."); + Chat.MessageAll("The last person alive will win!!"); Player.Message(p, "Countdown rules sent to everyone"); return; } else if (target == "map") { @@ -269,7 +269,7 @@ namespace MCGalaxy.Commands { Server.Countdown.mapon.motd = "Welcome to the Countdown map! -hax"; Server.Countdown.gamestatus = CountdownGameStatus.Enabled; - Player.GlobalMessage("Countdown has been enabled!!"); + Chat.MessageAll("Countdown has been enabled!!"); } else { Player.Message(p, "A Game is either already enabled or is already progress"); } diff --git a/Commands/Fun/CmdCtf.cs b/Commands/Fun/CmdCtf.cs index b70c40866..64d34cae5 100644 --- a/Commands/Fun/CmdCtf.cs +++ b/Commands/Fun/CmdCtf.cs @@ -44,7 +44,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Starting CTF.."); Server.ctf = new Auto_CTF(); - Player.GlobalMessage("A CTF GAME IS STARTING AT CTF! TYPE /goto CTF to join!"); + Chat.MessageAll("A CTF GAME IS STARTING AT CTF! TYPE /goto CTF to join!"); } else if (Server.ctf.started) { @@ -54,7 +54,7 @@ namespace MCGalaxy.Commands else if (!Server.ctf.started) { Server.ctf.Start(); - Player.GlobalMessage("A CTF GAME IS STARTING AT CTF! TYPE /goto CTF to join!"); + Chat.MessageAll("A CTF GAME IS STARTING AT CTF! TYPE /goto CTF to join!"); } } if (message == "stop") diff --git a/Commands/Fun/CmdFlipHeads.cs b/Commands/Fun/CmdFlipHeads.cs index b29939fca..4b8dbfd6f 100644 --- a/Commands/Fun/CmdFlipHeads.cs +++ b/Commands/Fun/CmdFlipHeads.cs @@ -26,8 +26,8 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { Server.flipHead = !Server.flipHead; - if (Server.flipHead) Player.GlobalMessage("All necks were broken"); - else Player.GlobalMessage("All necks were mended"); + if (Server.flipHead) Chat.MessageAll("All necks were broken"); + else Chat.MessageAll("All necks were mended"); } public override void Help(Player p) { diff --git a/Commands/Fun/ZombieSurvival/CmdDisinfect.cs b/Commands/Fun/ZombieSurvival/CmdDisinfect.cs index 4249d5609..cdaca0756 100644 --- a/Commands/Fun/ZombieSurvival/CmdDisinfect.cs +++ b/Commands/Fun/ZombieSurvival/CmdDisinfect.cs @@ -35,7 +35,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Cannot disinfect player"); } else if (!who.Game.Referee) { Server.zombie.DisinfectPlayer(who); - Player.GlobalMessage(who.ColoredName + " %Swas disinfected!"); + Chat.MessageAll("{0} %Swas disinfected.", who.ColoredName); } } diff --git a/Commands/Fun/ZombieSurvival/CmdInfect.cs b/Commands/Fun/ZombieSurvival/CmdInfect.cs index afc0e64da..3eb9efa41 100644 --- a/Commands/Fun/ZombieSurvival/CmdInfect.cs +++ b/Commands/Fun/ZombieSurvival/CmdInfect.cs @@ -33,7 +33,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Cannot infect player"); } else if (!who.Game.Referee) { Server.zombie.InfectPlayer(who); - Player.GlobalMessage(who.ColoredName + " %Swas infected!"); + Chat.MessageAll("{0} %Swas infected.", who.ColoredName); } } diff --git a/Commands/Information/CmdAfk.cs b/Commands/Information/CmdAfk.cs index 19767888c..781a74c23 100644 --- a/Commands/Information/CmdAfk.cs +++ b/Commands/Information/CmdAfk.cs @@ -50,7 +50,7 @@ namespace MCGalaxy.Commands { bool send = !Server.chatmod && !p.muted; if (p.IsAfk) { if (send) { - Player.GlobalMessage("-" + p.ColoredName + "%S- is AFK " + message); + Chat.MessageAll("-{0}%S- is AFK {1}", p.ColoredName, message); Player.RaisePlayerAction(p, PlayerAction.AFK, message); } else { Player.Message(p, "You are now marked as being AFK."); @@ -61,7 +61,7 @@ namespace MCGalaxy.Commands { OnPlayerAFKEvent.Call(p); } else { if (send) { - Player.GlobalMessage("-" + p.ColoredName + "%S- is no longer AFK"); + Chat.MessageAll("-{0}%S- is no longer AFK", p.ColoredName); Player.RaisePlayerAction(p, PlayerAction.UnAFK, message); } else { Player.Message(p, "You are no longer marked as being AFK."); diff --git a/Commands/Moderation/CmdAllowGuns.cs b/Commands/Moderation/CmdAllowGuns.cs index 4c6bac31c..b38304c52 100644 --- a/Commands/Moderation/CmdAllowGuns.cs +++ b/Commands/Moderation/CmdAllowGuns.cs @@ -36,13 +36,13 @@ namespace MCGalaxy.Commands { } if (lvl.guns) { - Player.GlobalMessage("&9Gun usage has been disabled on &c" + lvl.name + "&9!"); + Chat.MessageAll("&9Gun usage has been disabled on &c{0}&9!", lvl.name); Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) if (pl.level.name.CaselessEq(lvl.name)) pl.aiming = false; } else { - Player.GlobalMessage("&9Gun usage has been enabled on &c" + lvl.name + "&9!"); + Chat.MessageAll("&9Gun usage has been enabled on &c{0}&9!", lvl.name); } lvl.guns = !lvl.guns; Level.SaveSettings(lvl); diff --git a/Commands/Moderation/CmdLimit.cs b/Commands/Moderation/CmdLimit.cs index 73912800b..3b8b48a9b 100644 --- a/Commands/Moderation/CmdLimit.cs +++ b/Commands/Moderation/CmdLimit.cs @@ -37,35 +37,29 @@ namespace MCGalaxy.Commands { switch (args[0].ToLower()) { case "rt": case "reloadthreshold": - Player.GlobalMessage("Threshold before drawing reloads map set to &b" + limit); - Server.DrawReloadLimit = limit; - SrvProperties.Save(); return; + SetLimit("Threshold before drawing reloads map set to {0}", ref Server.DrawReloadLimit, limit); + return; case "rp": case "restartphysics": - Player.GlobalMessage("Custom /rp's limit was changed to &b" + limit); - Server.rpLimit = limit; - SrvProperties.Save(); return; + SetLimit("Custom /rp's limit was changed to {0}", ref Server.rpLimit, limit); + return; case "rpnormal": - Player.GlobalMessage("Normal /rp's limit set to &b" + limit); - Server.rpNormLimit = limit; - SrvProperties.Save(); return; + SetLimit("Normal /rp's limit set to {0}", ref Server.rpNormLimit, limit); + return; case "pu": case "physicsundo": - Player.GlobalMessage("Physics undo max entries set to &b" + limit); - Server.physUndo = limit; - SrvProperties.Save(); return; + SetLimit("Physics undo max entries set to {0}", ref Server.physUndo, limit); + return; case "gen": case "genlimit": - Player.GlobalMessage("Maximum volume of maps players can generate set to &b" + limit); - Server.MapGenLimit = limit; - SrvProperties.Save(); return; + SetLimit("Maximum volume of maps players can generate set to {0}", ref Server.MapGenLimit, limit); + return; case "genadmin": case "genadminlimit": case "admingen": case "admingenlimit": - Player.GlobalMessage("Maximum volume of maps admins can generate set to &b" + limit); - Server.MapGenLimitAdmin = limit; - SrvProperties.Save(); return; + SetLimit("Maximum volume of maps admins can generate set to &b{0}", ref Server.MapGenLimitAdmin, limit); + return; } if (args.Length == 2) { Player.Message(p, "You need to provide a rank name for this type."); return; } @@ -80,13 +74,19 @@ namespace MCGalaxy.Commands { case "mu": case "maxundo": Player.GlobalMessage(grp.ColoredName + "%S's undo limit set to &b" + limit); - grp.maxUndo = limit; break; + grp.maxUndo = limit; break; default: Help(p); return; } Group.saveGroups(Group.GroupList); } + static void SetLimit(string format, ref int target, int limit) { + Chat.MessageAll(format, "&b" + limit); + target = limit; + SrvProperties.Save(); + } + public override void Help(Player p) { Player.Message(p, "%T/limit [rank]"); Player.Message(p, "%HSets the limit for "); diff --git a/Commands/Moderation/CmdLowlag.cs b/Commands/Moderation/CmdLowlag.cs index a7a73f169..86da70712 100644 --- a/Commands/Moderation/CmdLowlag.cs +++ b/Commands/Moderation/CmdLowlag.cs @@ -29,10 +29,10 @@ namespace MCGalaxy.Commands public override void Use(Player p, string message) { if (message == "" && Server.updateTimer.Interval > 1000) { Server.PositionInterval = 100; - Player.GlobalMessage("&dLow lag %Sturned &cOFF %S- positions update every &b100%S ms."); + Chat.MessageAll("&dLow lag %Sturned &cOFF %S- positions update every &b100%S ms."); } else if (message == "") { Server.PositionInterval = 2000; - Player.GlobalMessage("&dLow lag %Sturned &aON %S- positions update every &b2000%S ms."); + Chat.MessageAll("&dLow lag %Sturned &aON %S- positions update every &b2000%S ms."); } else { int interval; if (!int.TryParse(message, out interval)) { @@ -42,7 +42,7 @@ namespace MCGalaxy.Commands Player.Message(p, "Interval must be between 20 and 2000 milliseconds."); return; } Server.PositionInterval = interval; - Player.GlobalMessage("Positions now update every &b" + interval + " %Smilliseconds."); + Chat.MessageAll("Positions now update every &b{0} %Smilliseconds.", interval); } Server.updateTimer.Interval = Server.PositionInterval; SrvProperties.Save(); diff --git a/Commands/Moderation/CmdModerate.cs b/Commands/Moderation/CmdModerate.cs index cfa19840a..d95eef579 100644 --- a/Commands/Moderation/CmdModerate.cs +++ b/Commands/Moderation/CmdModerate.cs @@ -28,9 +28,9 @@ namespace MCGalaxy.Commands { if (message != "") { Help(p); return; } if (Server.chatmod) { - Player.GlobalMessage("Chat moderation has been disabled. Everyone can now speak."); + Chat.MessageAll("Chat moderation has been disabled. Everyone can now speak."); } else { - Player.GlobalMessage("Chat moderation engaged! Silence the plebians!"); + Chat.MessageAll("Chat moderation engaged! Silence the plebians!"); } Server.chatmod = !Server.chatmod; } diff --git a/Commands/Moderation/CmdMute.cs b/Commands/Moderation/CmdMute.cs index 01e6109b7..2ddbc157a 100644 --- a/Commands/Moderation/CmdMute.cs +++ b/Commands/Moderation/CmdMute.cs @@ -34,7 +34,7 @@ namespace MCGalaxy.Commands.Moderation { if (Server.muted.Contains(message)) { Server.muted.Remove(message); Server.muted.Save(); - Player.GlobalMessage(message + " %Sis not online but is now &bun-muted"); + Chat.MessageAll("{0} %Sis not online but is now &bun-muted", message); } return; } diff --git a/Commands/Moderation/CmdVoteKick.cs b/Commands/Moderation/CmdVoteKick.cs index 0e5ca637b..a224849f8 100644 --- a/Commands/Moderation/CmdVoteKick.cs +++ b/Commands/Moderation/CmdVoteKick.cs @@ -42,8 +42,8 @@ namespace MCGalaxy.Commands { } Chat.MessageOps(p.ColoredName + " %Sused &a/votekick"); - Player.GlobalMessage("&9A vote to kick " + who.ColoredName + " %Shas been called!"); - Player.GlobalMessage("&9Type &aY %Sor &cN %Sto vote."); + Chat.MessageAll("&9A vote to kick {0} %Shas been called!", who.ColoredName); + Chat.MessageAll("&9Type &aY %Sor &cN %Sto vote."); // 1/3rd of the players must vote or nothing happens // Keep it at 0 to disable min number of votes @@ -65,7 +65,7 @@ namespace MCGalaxy.Commands { string name = (string)task.State; Player who = PlayerInfo.FindExact(name); if (who == null) { - Player.GlobalMessage(name + " was not kicked, as they already left the server."); return; + Chat.MessageAll("{0} was not kicked, as they already left the server.", name); return; } int netVotesYes = votesYes - votesNo; @@ -74,12 +74,12 @@ namespace MCGalaxy.Commands { Server.s.Log("VoteKick results for " + who.DisplayName + ": " + votesYes + " yes and " + votesNo + " no votes."); if (votesYes + votesNo < Server.voteKickVotesNeeded) { - Player.GlobalMessage("Not enough votes were made. " + who.ColoredName + " %Sshall remain!"); + Chat.MessageAll("Not enough votes were made. {0} %Sshall remain!", who.ColoredName); } else if (netVotesYes > 0) { - Player.GlobalMessage("The people have spoken, " + who.ColoredName + " %Sis gone!"); + Chat.MessageAll("The people have spoken, {0} %Sis gone!", who.ColoredName); who.Kick("Vote-Kick: The people have spoken!"); } else { - Player.GlobalMessage(who.ColoredName + " %Sshall remain!"); + Chat.MessageAll("{0} %Sshall remain!", who.ColoredName); } } diff --git a/Commands/Moderation/CmdXJail.cs b/Commands/Moderation/CmdXJail.cs index 4e619edcf..9058b7952 100644 --- a/Commands/Moderation/CmdXJail.cs +++ b/Commands/Moderation/CmdXJail.cs @@ -57,7 +57,7 @@ namespace MCGalaxy.Commands { PlayerActions.ChangeMap(pl, xjailMap); pl.BlockUntilLoad(10); jail.Use(p, message); - Player.GlobalMessage(pl.ColoredName + " %Swas XJailed!"); + Chat.MessageAll("{0} %Swas XJailed!", pl.ColoredName); } else { if (pl.muted) mute.Use(p, message); if (pl.frozen) freeze.Use(p, message); @@ -67,7 +67,7 @@ namespace MCGalaxy.Commands { jail.Use(p, message); spawn.Use(pl, ""); - Player.GlobalMessage(pl.ColoredName + " %Swas released from XJail!"); + Chat.MessageAll("{0} %Swas released from XJail!", pl.ColoredName); } } diff --git a/Commands/Moderation/CmdXmute.cs b/Commands/Moderation/CmdXmute.cs index 03ae14d19..6b463ec61 100644 --- a/Commands/Moderation/CmdXmute.cs +++ b/Commands/Moderation/CmdXmute.cs @@ -54,7 +54,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Time must be positive and greater than zero."); return; } - Player.GlobalMessage(muter.color + muter.DisplayName + " %Shas been muted for " + time + " seconds"); + Chat.MessageAll("{0} %Shas been muted for {1} seconds", muter.ColoredName, time); Player.Message(muter, "You have been muted for " + time + " seconds"); Thread.Sleep(time * 1000); Command.all.Find("mute").Use(p, muter.name); diff --git a/Commands/World/CmdLoad.cs b/Commands/World/CmdLoad.cs index 64ad6410d..e74f27862 100644 --- a/Commands/World/CmdLoad.cs +++ b/Commands/World/CmdLoad.cs @@ -62,9 +62,8 @@ namespace MCGalaxy.Commands { } LevelInfo.Loaded.Add(lvl); - if (p == null || !p.hidden) { - Player.GlobalMessage("Level \"" + lvl.name + "\" loaded."); - } + if (p == null || !p.hidden) + Player.GlobalMessage("Level \"{0}\" loaded.", lvl.name); /*try { Gui.Window.thisWindow.UpdatePlayerMapCombo(); Gui.Window.thisWindow.UnloadedlistUpdate(); diff --git a/Commands/World/CmdLockdown.cs b/Commands/World/CmdLockdown.cs index 8dc2d0e41..edd9728c2 100644 --- a/Commands/World/CmdLockdown.cs +++ b/Commands/World/CmdLockdown.cs @@ -44,11 +44,11 @@ namespace MCGalaxy.Commands { string path = "text/lockdown/map/" + args[1]; if (!File.Exists(path)) { File.Create(path).Dispose(); - Player.GlobalMessage("The map " + args[1] + " has been locked"); + Chat.MessageAll("The map {0} has been locked", args[1]); Chat.MessageOps("Locked by: " + ((p == null) ? "Console" : p.name)); } else { File.Delete(path); - Player.GlobalMessage("The map " + args[1] + " has been unlocked"); + Chat.MessageAll("The map {0} has been unlocked", args[1]); Chat.MessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name)); } } else { @@ -64,10 +64,10 @@ namespace MCGalaxy.Commands { PlayerActions.ChangeMap(who, p.level.name); who.BlockUntilLoad(500); } - Player.GlobalMessage(who.ColoredName + " %Shas been locked down!"); + Chat.MessageAll("{0} %Shas been locked down!", who.ColoredName); Chat.MessageOps("Locked by: " + ((p == null) ? "Console" : p.name)); } else { - Player.GlobalMessage(who.ColoredName + " %Shas been unlocked."); + Chat.MessageAll("{0} %Shas been unlocked.", who.ColoredName); Chat.MessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name)); } who.jailed = !who.jailed; diff --git a/Commands/World/CmdNewLvl.cs b/Commands/World/CmdNewLvl.cs index d693d2158..46439b2c8 100644 --- a/Commands/World/CmdNewLvl.cs +++ b/Commands/World/CmdNewLvl.cs @@ -69,7 +69,7 @@ namespace MCGalaxy.Commands.World { } string format = seed != "" ? "Level \"{0}\" created with seed \"{1}\"" : "Level \"{0}\" created"; - Player.GlobalMessage(String.Format(format, name, seed)); + Chat.MessageAll(format, name, seed); } internal static bool CheckMapSize(Player p, int x, int y, int z) { diff --git a/Commands/World/CmdPause.cs b/Commands/World/CmdPause.cs index b1f7278af..ffc9c343a 100644 --- a/Commands/World/CmdPause.cs +++ b/Commands/World/CmdPause.cs @@ -49,11 +49,11 @@ namespace MCGalaxy.Commands { lvl.PhysicsEnabled = enabled; lvl.physPause = !lvl.physPause; if (enabled) { - Player.GlobalMessage("Physics on " + lvl.name + " were re-enabled."); + Chat.MessageAll("Physics on {0} were re-enabled.", lvl.name); } else { Server.MainScheduler.QueueOnce(PauseCallback, lvl.name, TimeSpan.FromSeconds(seconds)); - Player.GlobalMessage("Physics on " + lvl.name + " were temporarily disabled."); + Chat.MessageAll("Physics on {0} were temporarily disabled.", lvl.name); } } @@ -63,7 +63,7 @@ namespace MCGalaxy.Commands { if (lvl == null) return; lvl.PhysicsEnabled = true; - Player.GlobalMessage("Physics on " + lvl.name + " were re-enabled."); + Chat.MessageAll("Physics on {0} were re-enabled.", lvl.name); } public override void Help(Player p) { diff --git a/Commands/World/CmdRenameLvl.cs b/Commands/World/CmdRenameLvl.cs index 07163a40f..ce588f4d4 100644 --- a/Commands/World/CmdRenameLvl.cs +++ b/Commands/World/CmdRenameLvl.cs @@ -42,7 +42,7 @@ namespace MCGalaxy.Commands.World { LevelActions.Rename(lvl.name.ToLower(), newName.ToLower()); try { Command.all.Find("load").Use(p, newName); } catch { } - Player.GlobalMessage("Renamed " + lvl.name + " to " + newName); + Chat.MessageAll("Renamed {0} to {1}", lvl.name, newName); } public override void Help(Player p) { diff --git a/Commands/World/CmdUnflood.cs b/Commands/World/CmdUnflood.cs index 2eafe1612..8cf628d5e 100644 --- a/Commands/World/CmdUnflood.cs +++ b/Commands/World/CmdUnflood.cs @@ -43,7 +43,7 @@ namespace MCGalaxy.Commands cmd.Use(p, args + " air"); CmdPhysics.SetPhysics(p.level, phys); - Player.GlobalMessage("Unflooded!"); + Chat.MessageLevel("Unflooded!"); } public override void Help(Player p) { diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index 375520616..2443a11b8 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Games { MainLoopCore(); } catch (Exception ex) { Server.ErrorLog(ex); - Player.GlobalMessage("&cZombie survival disabled due to an error."); + Chat.MessageAll("&cZombie survival disabled due to an error."); try { ResetState(); } catch (Exception ex2) { diff --git a/Games/ZombieSurvival/ZombieGame.cs b/Games/ZombieSurvival/ZombieGame.cs index 104e8efd2..d3fcb038f 100644 --- a/Games/ZombieSurvival/ZombieGame.cs +++ b/Games/ZombieSurvival/ZombieGame.cs @@ -59,7 +59,7 @@ namespace MCGalaxy.Games { CurLevel = level; } - Player.GlobalMessage("A game of zombie survival is starting on: " + CurLevelName); + Chat.MessageAll("A game of zombie survival is starting on: {0}", CurLevelName); Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { if (p.level != CurLevel) continue; diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index 184ea5a6f..a4733e479 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -649,10 +649,8 @@ return; } else { Chat.GlobalChatLevel(this, text, true); } - - //IRCBot.Say(name + ": " + text); } - catch ( Exception e ) { Server.ErrorLog(e); Player.GlobalMessage("An error occurred: " + e.Message); } + catch ( Exception e ) { Server.ErrorLog(e); Chat.MessageAll("An error occurred: {0}", e.Message); } } string HandleJoker(string text) { @@ -757,7 +755,7 @@ return; //DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla if (cmd == "pony") { if (ponycount < 2) { - GlobalMessage(color + DisplayName + " %Sjust so happens to be a proud brony! Everyone give " + color + DisplayName + " %Sa brohoof!"); + Chat.MessageAll("{0} %Sjust so happens to be a proud brony! Everyone give {0} %Sa brohoof!", ColoredName); ponycount++; } else { SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!"); @@ -765,7 +763,7 @@ return; return false; } else if (cmd == "rainbowdashlikescoolthings") { if (rdcount < 2) { - GlobalMessage("&1T&2H&3I&4S &5S&6E&7R&8V&9E&aR &bJ&cU&dS&eT &fG&0O&1T &22&30 &4P&CE&7R&DC&EE&9N&1T &5C&6O&7O&8L&9E&aR&b!"); + Chat.MessageAll("&1T&2H&3I&4S &5S&6E&7R&8V&9E&aR &bJ&cU&dS&eT &fG&0O&1T &22&30 &4P&CE&7R&DC&EE&9N&1T &5C&6O&7O&8L&9E&aR&b!"); rdcount++; } else { SendMessage("You have used this command 2 times. You cannot use it anymore! Sorry, Brony!"); diff --git a/Player/Player.Login.cs b/Player/Player.Login.cs index 7d1ddf3b1..d4aede357 100644 --- a/Player/Player.Login.cs +++ b/Player/Player.Login.cs @@ -133,7 +133,7 @@ namespace MCGalaxy { CompleteLoginProcess(); } catch (Exception e) { Server.ErrorLog(e); - Player.GlobalMessage("An error occurred: " + e.Message); + Chat.MessageAll("An error occurred: {0}", e.Message); } } @@ -379,12 +379,12 @@ namespace MCGalaxy { void CheckState() { if (Server.muted.Contains(name)) { muted = true; - GlobalMessage(DisplayName + " is still muted from the last time they went offline."); + Chat.MessageAll("{0} is still muted from the last time they went offline.", DisplayName); Player.Message(this, "!%cYou are still %8muted%c since your last login."); } if (Server.frozen.Contains(name)) { frozen = true; - GlobalMessage(DisplayName + " is still frozen from the last time they went offline."); + Chat.MessageAll("{0} is still frozen from the last time they went offline.", DisplayName); Player.Message(this, "!%cYou are still %8frozen%c since your last login."); } } diff --git a/Player/Player.cs b/Player/Player.cs index 9d15006ed..a2ad58fea 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -187,17 +187,10 @@ namespace MCGalaxy { } public static List Last50Chat = new List(); - public static void GlobalMessage(string message) { GlobalMessage(message, false); } - public static void GlobalMessage(string message, bool global) { - message = Colors.EscapeColors(message); - Player[] players = PlayerInfo.Online.Items; - foreach (Player p in players) { - if (p.ignoreAll || (global && p.ignoreGlobal)) continue; - - if (p.level.worldChat && p.Chatroom == null) - p.SendMessage(message, !global); - } - } + [Obsolete("Use Chat.MessageAll() instead")] + public static void GlobalMessage(string message) { Chat.MessageAll(message); } + [Obsolete("Use Chat.MessageAll() instead")] + public static void GlobalMessage(string message, bool global) { Chat.MessageAll(message); } public static void GlobalIRCMessage(string message) { message = Colors.EscapeColors(message); @@ -651,7 +644,7 @@ namespace MCGalaxy { muteCooldown = Server.mutespamtime; Command.all.Find("mute").Use(null, name); - Player.GlobalMessage(color + DisplayName + " %Shas been &0muted &efor spamming!"); + Chat.MessageAll("{0} %Shas been &0muted %Sfor spamming!", ColoredName); muteTimer.Elapsed += MuteTimerElapsed; muteTimer.Start(); }