From db2bbf92460a7ef4bb69db67e000a71dc66de868 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 2 Dec 2017 21:43:19 +1100 Subject: [PATCH] For consistency with pretty much all other server software, /ban kicks player too if online --- MCGalaxy/Commands/Moderation/CmdBan.cs | 7 +++-- MCGalaxy/Commands/Moderation/CmdKickban.cs | 36 ---------------------- MCGalaxy/CorePlugin/ModActionHandler.cs | 7 ++++- MCGalaxy/MCGalaxy_.csproj | 1 - 4 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 MCGalaxy/Commands/Moderation/CmdKickban.cs diff --git a/MCGalaxy/Commands/Moderation/CmdBan.cs b/MCGalaxy/Commands/Moderation/CmdBan.cs index 7f4065cc9..21cf3fe55 100644 --- a/MCGalaxy/Commands/Moderation/CmdBan.cs +++ b/MCGalaxy/Commands/Moderation/CmdBan.cs @@ -23,7 +23,10 @@ namespace MCGalaxy.Commands.Moderation { public override string name { get { return "Ban"; } } public override string type { get { return CommandTypes.Moderation; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - + public override CommandAlias[] Aliases { + get { return new CommandAlias[] { new CommandAlias("KickBan"), new CommandAlias("kb") }; } + } + public override void Use(Player p, string message) { if (message.Length == 0) { Help(p); return; } @@ -57,7 +60,7 @@ 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, "%HBans a player (and kicks them if online)."); Player.Message(p, "%HFor , @number can be used as a shortcut for that rule."); } } diff --git a/MCGalaxy/Commands/Moderation/CmdKickban.cs b/MCGalaxy/Commands/Moderation/CmdKickban.cs deleted file mode 100644 index f60384e40..000000000 --- a/MCGalaxy/Commands/Moderation/CmdKickban.cs +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/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. -*/ -namespace MCGalaxy.Commands.Moderation { - public sealed class CmdKickban : Command { - public override string name { get { return "KickBan"; } } - public override string shortcut { get { return "kb"; } } - public override string type { get { return CommandTypes.Moderation; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - - public override void Use(Player p, string message) { - if (message.Length == 0) { Help(p); return; } - Command.all.FindByName("Ban").Use(p, message); - Command.all.FindByName("Kick").Use(p, message); - } - - public override void Help(Player p) { - Player.Message(p, "%T/KickBan [player] "); - Player.Message(p, "%HKicks and bans a player with an optional message."); - } - } -} diff --git a/MCGalaxy/CorePlugin/ModActionHandler.cs b/MCGalaxy/CorePlugin/ModActionHandler.cs index 57aaef02a..4ed2490e2 100644 --- a/MCGalaxy/CorePlugin/ModActionHandler.cs +++ b/MCGalaxy/CorePlugin/ModActionHandler.cs @@ -138,7 +138,7 @@ namespace MCGalaxy.Core { if (e.Duration.Ticks != 0) { string banner = e.Actor == null ? "(console)" : e.Actor.truename; - DateTime end = DateTime.UtcNow.Add(e.Duration); + DateTime end = DateTime.UtcNow.Add(e.Duration); Server.tempBans.AddOrReplace(e.Target, Ban.PackTempBanData(e.Reason, banner, end)); Server.tempBans.Save(); @@ -148,6 +148,11 @@ namespace MCGalaxy.Core { Ban.DeleteBan(e.Target); Ban.BanPlayer(e.Actor, e.Target, e.Reason, !e.Announce, e.TargetGroup.Name); ModActionCmd.ChangeRank(e.Target, e.targetGroup, Group.BannedRank, who); + + if (who != null) { + string msg = e.Reason.Length == 0 ? ServerConfig.DefaultBanMessage : e.Reason; + who.Kick("Banned by " + e.ActorName + ": " + msg); + } } } diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 5ed7971a4..b636b6f24 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -300,7 +300,6 @@ -