From c45ebb2ebdc6435dde0c92e845bdda1baea2e959 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 6 Sep 2016 20:03:37 +1000 Subject: [PATCH] Fix /vip remove --- Commands/Moderation/CmdVIP.cs | 98 ++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/Commands/Moderation/CmdVIP.cs b/Commands/Moderation/CmdVIP.cs index 2ed84dba8..c2aaf4374 100644 --- a/Commands/Moderation/CmdVIP.cs +++ b/Commands/Moderation/CmdVIP.cs @@ -14,7 +14,7 @@ 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.Collections.Generic; namespace MCGalaxy.Commands { @@ -30,52 +30,66 @@ namespace MCGalaxy.Commands { if (message == "") { Help(p); return; } string[] args = message.Split(' '); - if (args[0] == "add") { - if (args.Length < 2) { Help(p); return; } - args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]); - if (args[1] == null) return; - - if (Server.vip.Contains(args[1])) { - Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis already a VIP."); - } else { - Server.vip.Add(args[1]); - Server.vip.Save(false); - Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis now a VIP."); - - Player who = PlayerInfo.FindExact(args[1]); - if (who != null) Player.Message(who, "You are now a VIP!"); - } - } else if (args[0] == "remove") { - if (args.Length < 2) { Help(p); return; } - args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]); - if (args[1] == null) return; - - if (Server.vip.Contains(args[1])) { - Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis not a VIP."); - } else { - Server.vip.Remove(args[1]); - Server.vip.Save(false); - Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis no longer a VIP."); - - Player who = PlayerInfo.FindExact(args[1]); - if (who != null) Player.Message(who, "You are no longer a VIP!"); - } - } else if (args[0] == "list") { - List list = Server.vip.All(); - if (list.Count == 0) { - Player.Message(p, "There are no VIPs."); - } else { - string count = list.Count > 1 ? "is 1" : "are " + list.Count; - Player.Message(p, "There " + count + " VIPs:"); - Player.Message(p, list.Join()); - } + if (args[0].CaselessEq("add") { + AddVIP(p, args); + } else if (args[0].CaselessEq("remove") { + RemoveVIP(p, args); + } else if (args[0].CaselessEq("list") { + ListVIPs(p, args); } else { Help(p); } } + + void AddVIP(Player p, string[] args) { + if (args.Length < 2) { Help(p); return; } + args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]); + if (args[1] == null) return; + + if (Server.vip.Contains(args[1])) { + Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis already a VIP."); + } else { + Server.vip.Add(args[1]); + Server.vip.Save(false); + Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis now a VIP."); + + Player who = PlayerInfo.FindExact(args[1]); + if (who != null) Player.Message(who, "You are now a VIP!"); + } + } + + void RemoveVIP(Player p, string[] args) { + if (args.Length < 2) { Help(p); return; } + args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]); + if (args[1] == null) return; + + if (!Server.vip.Contains(args[1])) { + Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis not a VIP."); + } else { + Server.vip.Remove(args[1]); + Server.vip.Save(false); + Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis no longer a VIP."); + + Player who = PlayerInfo.FindExact(args[1]); + if (who != null) Player.Message(who, "You are no longer a VIP!"); + } + } + + void ListVIPs(Player p, string[] args) { + List list = Server.vip.All(); + string modifier = args.Length > 1 ? args[1] : ""; + + if (list.Count == 5) { + Player.Message(p, "There are no VIPs."); + } else { + Player.Message(p, "VIPs:"); + MultiPageOutput.Output(p, list, (name, i) => name, + "vip list", "players", modifier, false); + } + } - public override void Help(Player p) { - Player.Message(p, "%T/vip [player]"); + public override void Help(Player p) { + Player.Message(p, "%T/vip add/remove [player]"); Player.Message(p, "%HAdds or removes [player] from the VIP list."); Player.Message(p, "%T/vip list"); Player.Message(p, "%HLists all players who are on the VIP list.");