diff --git a/MCGalaxy/Commands/Moderation/CmdBan.cs b/MCGalaxy/Commands/Moderation/CmdBan.cs index a34555ad1..0b686273d 100644 --- a/MCGalaxy/Commands/Moderation/CmdBan.cs +++ b/MCGalaxy/Commands/Moderation/CmdBan.cs @@ -28,12 +28,7 @@ namespace MCGalaxy.Commands.Moderation { public override void Use(Player p, string message) { if (message == "") { Help(p); return; } - - bool stealth = message[0] == '#'; - if (stealth) { - message = message.Remove(0, 1); - Server.s.Log("Stealth ban Attempted by " + (p == null ? "Console" : p.ColoredName)); - } + string[] args = message.SplitSpaces(2); string reason = args.Length > 1 ? args[1] : ""; string target = ModActionCmd.FindName(p, "ban", "ban", "", args[0], ref reason); @@ -49,7 +44,6 @@ namespace MCGalaxy.Commands.Moderation { ModAction action = new ModAction(who.name, p, ModActionType.Ban, reason); action.targetGroup = group; - action.Metadata = stealth && who != null; OnModActionEvent.Call(action); } @@ -66,7 +60,6 @@ namespace MCGalaxy.Commands.Moderation { public override void Help(Player p) { Player.Message(p, "%T/ban [player] "); Player.Message(p, "%HBans a player without kicking them."); - Player.Message(p, "%HAdd # before name to stealth ban."); Player.Message(p, "%HFor , @number can be used as a shortcut for that rule."); } } diff --git a/MCGalaxy/CorePlugin/ModActionHandler.cs b/MCGalaxy/CorePlugin/ModActionHandler.cs index e8042e136..6e5c9c83e 100644 --- a/MCGalaxy/CorePlugin/ModActionHandler.cs +++ b/MCGalaxy/CorePlugin/ModActionHandler.cs @@ -41,9 +41,9 @@ namespace MCGalaxy.Core { static void LogAction(ModAction e, Player who, string action) { if (who != null) { - Chat.MessageGlobal(who, e.FormatMessage(action), false); + Chat.MessageGlobal(who, e.FormatMessage(e.TargetName, action), false); } else { - Chat.MessageGlobal(e.FormatMessage(action)); + Chat.MessageGlobal(e.FormatMessage(e.TargetName, action)); } action = Colors.StripColors(action); @@ -121,39 +121,28 @@ namespace MCGalaxy.Core { static void DoBan(ModAction e) { Player who = PlayerInfo.FindExact(e.Target); + LogAction(e, who, "&8banned"); + if (e.Duration.Ticks != 0) { string banner = e.Actor == null ? "(console)" : e.Actor.truename; DateTime end = DateTime.UtcNow.Add(e.Duration); Server.tempBans.AddOrReplace(e.Target, Ban.PackTempBanData(e.Reason, banner, end)); Server.tempBans.Save(); - - LogAction(e, who, "&8banned"); + if (who != null) who.Kick("Banned for " + e.Duration.Shorten(true) + "." + e.ReasonSuffixed); - return; - } - - bool banSealth = e.Metadata != null && (bool)e.Metadata; - if (banSealth) { - string msg = e.TargetName + " %Swas STEALTH &8banned %Sby " + e.ActorName + "%S." + e.ReasonSuffixed; - Chat.MessageOps(msg); } else { - LogAction(e, who, "&8banned"); + if (who != null) who.color = ""; + Ban.DeleteBan(e.Target); + Ban.BanPlayer(e.Actor, e.Target, e.Reason, false, e.TargetGroup.name); + ModActionCmd.ChangeRank(e.Target, e.targetGroup, Group.BannedRank, who); } - - if (who != null) who.color = ""; - Ban.DeleteBan(e.Target); - Ban.BanPlayer(e.Actor, e.Target, e.Reason, banSealth, e.TargetGroup.name); - ModActionCmd.ChangeRank(e.Target, e.targetGroup, Group.BannedRank, who); - Server.s.Log("BANNED: " + e.Target + " by " + e.ActorName); } static void DoBanIP(ModAction e) { - LevelPermission seeIPperm = CommandExtraPerms.MinPerm("whois"); - Chat.MessageWhere("An IP was &8banned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed, - pl => pl.Rank < seeIPperm); - Chat.MessageWhere(e.Target + " was &8IP banned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed, - pl => pl.Rank >= seeIPperm); + LevelPermission perm = CommandExtraPerms.MinPerm("whois"); + Chat.MessageWhere(e.FormatMessage("An IP", "&8IP banned"), pl => pl.Rank < perm); + Chat.MessageWhere(e.FormatMessage(e.TargetName, "&8IP banned"), pl => pl.Rank >= perm); Server.s.Log("IP-BANNED: " + e.Target + " by " + e.ActorName + "."); Server.bannedIP.Add(e.Target); @@ -161,11 +150,9 @@ namespace MCGalaxy.Core { } static void DoUnbanIP(ModAction e) { - LevelPermission seeIPperm = CommandExtraPerms.MinPerm("whois"); - Chat.MessageWhere("An IP was &8unbanned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed, - pl => pl.Rank < seeIPperm); - Chat.MessageWhere(e.Target + " was &8IP unbanned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed, - pl => pl.Rank >= seeIPperm); + LevelPermission perm = CommandExtraPerms.MinPerm("whois"); + Chat.MessageWhere(e.FormatMessage("An IP", "&8IP unbanned"), pl => pl.Rank < perm); + Chat.MessageWhere(e.FormatMessage(e.TargetName, "&8IP unbanned"), pl => pl.Rank >= perm); Server.s.Log("IP-UNBANNED: " + e.Target + " by " + e.ActorName + "."); Server.bannedIP.Remove(e.Target); diff --git a/MCGalaxy/Network/IRCPlugin/IRCPlugin.cs b/MCGalaxy/Network/IRCPlugin/IRCPlugin.cs index f5c2524e2..fa43e6c6d 100644 --- a/MCGalaxy/Network/IRCPlugin/IRCPlugin.cs +++ b/MCGalaxy/Network/IRCPlugin/IRCPlugin.cs @@ -46,29 +46,19 @@ namespace MCGalaxy.Network { void HandleModerationAction(ModAction e) { if (!Server.IRC.Enabled) return; switch (e.Type) { - case ModActionType.Warned: Bot.Say(e.FormatMessage("&ewarned")); break; - case ModActionType.Ban: LogBan(e); break; - case ModActionType.BanIP: LogBanIP(e); break; - case ModActionType.UnbanIP: LogUnbanIP(e); break; + case ModActionType.Warned: + Bot.Say(e.FormatMessage(e.TargetName, "&ewarned")); break; + case ModActionType.Ban: + Bot.Say(e.FormatMessage(e.TargetName, "&8banned")); break; + case ModActionType.BanIP: + Bot.Say(e.FormatMessage(e.TargetName, "&8IP banned"), true); + Bot.Say(e.FormatMessage("An IP", "&8IP banned")); break; + case ModActionType.UnbanIP: + Bot.Say(e.FormatMessage(e.TargetName, "&8IP unbanned"), true); + Bot.Say(e.FormatMessage("An IP", "&8IP unbanned")); break; } } - void LogBan(ModAction e) { - bool banSealth = e.Metadata != null && (bool)e.Metadata; - Bot.Say(e.FormatMessage("&8banned"), banSealth); - } - - void LogBanIP(ModAction e) { - Bot.Say("An IP was &8banned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed); - Bot.Say(e.Target + " was &8IP banned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed, true); - } - - void LogUnbanIP(ModAction e) { - Bot.Say("An IP was &8unbanned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed); - Bot.Say(e.Target + " was &8IP unbanned %Sby " + e.ActorName + "%S. " + e.ReasonSuffixed, true); - } - - void Player_PlayerAction(Player p, PlayerAction action, string message, bool stealth) { if (!Server.IRC.Enabled) return; diff --git a/MCGalaxy/Plugins/Events/ModActionEvent.cs b/MCGalaxy/Plugins/Events/ModActionEvent.cs index b7014e97e..6ba5b383d 100644 --- a/MCGalaxy/Plugins/Events/ModActionEvent.cs +++ b/MCGalaxy/Plugins/Events/ModActionEvent.cs @@ -63,12 +63,12 @@ namespace MCGalaxy.Events { } /// Returns a formatted moderation action message. - public string FormatMessage(string action) { + public string FormatMessage(string target, string action) { string suffix = "%S"; if (Duration.Ticks != 0) suffix += " for " + Duration.Shorten(); suffix += "." + ReasonSuffixed; - return e.TargetName + " %Swas " + action + " %Sby " + e.ActorName + suffix; + return target + " %Swas " + action + " %Sby " + ActorName + suffix; }