From aeb4ac8fd8266e1efc0127a13c09e26fbe45f5a9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 3 Aug 2016 19:15:07 +1000 Subject: [PATCH] Use Player.Message in more places so things work from IRC and console. --- Commands/CPE/CmdEnvironment.cs | 6 +-- Commands/CPE/CmdTexture.cs | 16 ++++---- Commands/Fun/Cmd8Ball.cs | 2 +- Commands/Fun/CmdCountdown.cs | 47 +++++++++++----------- Commands/Fun/CmdTeam.cs | 2 +- Commands/Moderation/CmdInfoSwap.cs | 6 +-- Commands/Moderation/CmdRestoreSelection.cs | 2 +- Commands/Moderation/CmdTrust.cs | 4 +- Commands/Moderation/CmdVoice.cs | 4 +- 9 files changed, 44 insertions(+), 45 deletions(-) diff --git a/Commands/CPE/CmdEnvironment.cs b/Commands/CPE/CmdEnvironment.cs index 4e49d295e..13b9b3a34 100644 --- a/Commands/CPE/CmdEnvironment.cs +++ b/Commands/CPE/CmdEnvironment.cs @@ -187,15 +187,15 @@ namespace MCGalaxy.Commands { } static void SendPresetsMessage(Player p) { - p.SendMessage("/env preset [type] -- Uses an env preset on your current map"); - p.SendMessage("Valid types: Cartoon/Midnight/Midnight2/Noir/Normal/Trippy/Watery/Sunset/Gloomy/Cloudy"); + Player.Message(p, "/env preset [type] -- Uses an env preset on your current map"); + Player.Message(p, "Valid types: Cartoon/Midnight/Midnight2/Noir/Normal/Trippy/Watery/Sunset/Gloomy/Cloudy"); if (!Directory.Exists("presets")) return; string custom = ""; foreach (string s in Directory.GetFiles("presets/", "*.env")) custom += ", " + Path.GetFileNameWithoutExtension(s); if (custom != "") - p.SendMessage("Custom preset types: " + custom.Remove(0, 2)); + Player.Message(p, "Custom preset types: " + custom.Remove(0, 2)); } public override void Help(Player p) { diff --git a/Commands/CPE/CmdTexture.cs b/Commands/CPE/CmdTexture.cs index 5eff2a66b..60d772439 100644 --- a/Commands/CPE/CmdTexture.cs +++ b/Commands/CPE/CmdTexture.cs @@ -45,36 +45,36 @@ namespace MCGalaxy.Commands.World { return; } - string url = args[1]; + string url = args[1]; if (url.ToLower() == "normal" || url.ToLower() == "reset") { url = ""; } else if (!(url.StartsWith("http://") || url.StartsWith("https://"))) { - p.SendMessage("Please use http:// or https:// in front of your URL"); return; + Player.Message(p, "Please use http:// or https:// in front of your URL"); return; } if ((scope == "global" || scope == "level") && !(url == "" || url.EndsWith(".png"))) { - p.SendMessage("The terrain URL must end in a .png"); return; + Player.Message(p, "The terrain URL must end in a .png"); return; } if ((scope == "globalzip" || scope == "levelzip") && !(url == "" || url.EndsWith(".zip"))) { - p.SendMessage("The texture pack URL must end in a .zip"); return; + Player.Message(p, "The texture pack URL must end in a .zip"); return; } if (url.Length > 64) { p.SendMessage("The URL must be 64 characters or less."); return; } if (scope == "global") { Server.defaultTerrainUrl = url; - p.SendMessage("Set server's default terrain to " + args[1]); + Player.Message(p, "Set server's default terrain to " + args[1]); UpdateGlobally(p, false); } else if (scope == "level") { p.level.terrainUrl = url; - p.SendMessage("Set level's terrain to " + args[1]); + Player.Message(p, "Set level's terrain to " + args[1]); UpdateLevel(p, false); } else if (scope == "globalzip") { Server.defaultTextureUrl = url; - p.SendMessage("Set server's default texture pack to " + args[1]); + Player.Message(p, "Set server's default texture pack to " + args[1]); UpdateGlobally(p, true); } else if (scope == "levelzip") { p.level.texturePackUrl = url; - p.SendMessage("Set level's texture pack to " + args[1]); + Player.Message(p, "Set level's texture pack to " + args[1]); UpdateLevel(p, true); } else { Help(p); diff --git a/Commands/Fun/Cmd8Ball.cs b/Commands/Fun/Cmd8Ball.cs index 99057d7a0..4d1688e6b 100644 --- a/Commands/Fun/Cmd8Ball.cs +++ b/Commands/Fun/Cmd8Ball.cs @@ -33,7 +33,7 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } - if (Server.chatmod || p.muted) { Player.SendMessage(p, "Cannot use 8-ball while muted."); return; } + if (Server.chatmod || p.muted) { Player.Message(p, "Cannot use 8-ball while muted."); return; } if (message == "") { Help(p); return; } TimeSpan delta = nextUse - DateTime.UtcNow; diff --git a/Commands/Fun/CmdCountdown.cs b/Commands/Fun/CmdCountdown.cs index fd32d3d9a..14f41a21a 100644 --- a/Commands/Fun/CmdCountdown.cs +++ b/Commands/Fun/CmdCountdown.cs @@ -87,7 +87,7 @@ namespace MCGalaxy.Commands { HandleTutorial(p); return; } } - p.SendMessage("Sorry, you aren't a high enough rank or that wasn't a correct command addition."); + Player.Message(p, "Sorry, you aren't a high enough rank or that wasn't a correct command addition."); } void HandleJoin(Player p) { @@ -326,7 +326,7 @@ namespace MCGalaxy.Commands { case "ultimate": game.speed = 150; game.speedtype = "ultimate"; break; default: - p.SendMessage("You didn't specify a speed, resorting to 'normal'"); + Player.Message(p, "You didn't specify a speed, resorting to 'normal'"); game.speed = 650; game.speedtype = "normal"; break; } Server.Countdown.freezemode = (par2 == "freeze" || par2 == "frozen"); @@ -354,35 +354,34 @@ namespace MCGalaxy.Commands { } void HandleTutorial(Player p) { - p.SendMessage("First, generate the map using /cd generate"); - p.SendMessage("Next, type /cd enable to enable the game mode"); - p.SendMessage("Next, type /cd join to join the game and tell other players to join aswell"); - p.SendMessage("When some people have joined, type /cd start [speed] to start it"); - p.SendMessage("[speed] can be 'ultimate', 'extreme', 'fast', 'normal' or 'slow'"); - p.SendMessage("When you are done, type /cd reset [map/all]"); - p.SendMessage("use map to reset only the map and all to reset everything."); + Player.Message(p, "First, generate the map using /cd generate"); + Player.Message(p, "Next, type /cd enable to enable the game mode"); + Player.Message(p, "Next, type /cd join to join the game and tell other players to join aswell"); + Player.Message(p, "When some people have joined, type /cd start [speed] to start it"); + Player.Message(p, "[speed] can be 'ultimate', 'extreme', 'fast', 'normal' or 'slow'"); + Player.Message(p, "When you are done, type /cd reset [map/all]"); + Player.Message(p, "use map to reset only the map and all to reset everything."); } public override void Help(Player p) { - p.SendMessage("/cd join - join the game"); - p.SendMessage("/cd leave - leave the game"); - p.SendMessage("/cd goto - goto the countdown map"); - p.SendMessage("/cd players - view players currently playing"); + Player.Message(p, "/cd join - join the game"); + Player.Message(p, "/cd leave - leave the game"); + Player.Message(p, "/cd goto - goto the countdown map"); + Player.Message(p, "/cd players - view players currently playing"); if (CheckExtraPerm(p, 1)) - p.SendMessage("/cd rules - the rules of countdown. with send: all to send to all, map to send to map and have a player's name to send to a player"); + Player.Message(p, "/cd rules - the rules of countdown. with send: all to send to all, map to send to map and have a player's name to send to a player"); else - p.SendMessage("/cd rules - view the rules of countdown"); + Player.Message(p, "/cd rules - view the rules of countdown"); - if (CheckExtraPerm(p, 2)) { - p.SendMessage("/cd generate [width] [height] [length] - generates the countdown map (default size is 32x32x32)"); - p.SendMessage("/cd enable - enable the game"); - p.SendMessage("/cd disable - disable the game"); - p.SendMessage("/cd cancel - cancels a game"); - p.SendMessage("/cd start [speed] [mode] - start the game, speeds are 'slow', 'normal', 'fast', 'extreme' and 'ultimate', modes are 'normal' and 'freeze'"); - p.SendMessage("/cd reset [all/map] - reset the whole game (all) or only the map (map)"); - p.SendMessage("/cd tutorial - a tutorial on how to setup countdown"); - } + if (!CheckExtraPerm(p, 2)) return; + Player.Message(p, "/cd generate [width] [height] [length] - generates the countdown map (default size is 32x32x32)"); + Player.Message(p, "/cd enable - enable the game"); + Player.Message(p, "/cd disable - disable the game"); + Player.Message(p, "/cd cancel - cancels a game"); + Player.Message(p, "/cd start [speed] [mode] - start the game, speeds are 'slow', 'normal', 'fast', 'extreme' and 'ultimate', modes are 'normal' and 'freeze'"); + Player.Message(p, "/cd reset [all/map] - reset the whole game (all) or only the map (map)"); + Player.Message(p, "/cd tutorial - a tutorial on how to setup countdown"); } } } diff --git a/Commands/Fun/CmdTeam.cs b/Commands/Fun/CmdTeam.cs index d13763569..c583cf93f 100644 --- a/Commands/Fun/CmdTeam.cs +++ b/Commands/Fun/CmdTeam.cs @@ -126,7 +126,7 @@ namespace MCGalaxy.Commands { team = Team.FindTeam(args[1]); if (team != null) { Player.Message(p, "There is already an existing team with that name."); return; } if (args[1].Length > 8) { - Player.SendMessage(p, "Team names must be 8 characters or less."); return; + Player.Message(p, "Team names must be 8 characters or less."); return; } team = new Team(args[1], p.name); diff --git a/Commands/Moderation/CmdInfoSwap.cs b/Commands/Moderation/CmdInfoSwap.cs index aaad2c316..7bc35a5a6 100644 --- a/Commands/Moderation/CmdInfoSwap.cs +++ b/Commands/Moderation/CmdInfoSwap.cs @@ -83,9 +83,9 @@ namespace MCGalaxy.Commands { } public override void Help(Player p) { - Player.SendMessage(p, "%T/infoswap [source] [other]"); - Player.SendMessage(p, "%HSwaps all the player's info from [source] to [other]."); - Player.SendMessage(p, "%HNote that both players must be offline for this to work."); + Player.Message(p, "%T/infoswap [source] [other]"); + Player.Message(p, "%HSwaps all the player's info from [source] to [other]."); + Player.Message(p, "%HNote that both players must be offline for this to work."); } } } diff --git a/Commands/Moderation/CmdRestoreSelection.cs b/Commands/Moderation/CmdRestoreSelection.cs index 8acf4a0bb..6269f1af8 100644 --- a/Commands/Moderation/CmdRestoreSelection.cs +++ b/Commands/Moderation/CmdRestoreSelection.cs @@ -52,7 +52,7 @@ namespace MCGalaxy.Commands { static bool CopyBlocks(Player p, Level other, Vec3S32[] m) { byte[] blocks = other.blocks; if (blocks.Length != p.level.blocks.Length) { - p.SendMessage("Cant restore selection of different size maps."); + p.Sessage("Cannot restore selection of different size maps."); return false; } diff --git a/Commands/Moderation/CmdTrust.cs b/Commands/Moderation/CmdTrust.cs index a1204265d..62584d937 100644 --- a/Commands/Moderation/CmdTrust.cs +++ b/Commands/Moderation/CmdTrust.cs @@ -28,12 +28,12 @@ namespace MCGalaxy.Commands public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; } - Player who = PlayerInfo.FindMatches(p, message); if (who == null) return; + who.ignoreGrief = !who.ignoreGrief; Player.Message(p, who.ColoredName + "%S's trust status: " + who.ignoreGrief); - who.SendMessage("Your trust status was changed to: " + who.ignoreGrief); + Player.Message(who, "Your trust status was changed to: " + who.ignoreGrief); } public override void Help(Player p) { diff --git a/Commands/Moderation/CmdVoice.cs b/Commands/Moderation/CmdVoice.cs index 334db5197..9096a55f6 100644 --- a/Commands/Moderation/CmdVoice.cs +++ b/Commands/Moderation/CmdVoice.cs @@ -34,10 +34,10 @@ namespace MCGalaxy.Commands { if (who.voice) { Player.Message(p, "Removing voice status from " + who.ColoredName); - who.SendMessage("Your voice status has been revoked."); + Player.Message(who, "Your voice status has been revoked."); } else { Player.Message(p, "Giving voice status to " + who.ColoredName); - who.SendMessage("You have received voice status."); + Player.Message(who, "You have received voice status."); } who.voice = !who.voice; }