Fix /vip remove

This commit is contained in:
UnknownShadow200 2016-09-06 20:03:37 +10:00
parent 8b680ea217
commit c45ebb2ebd

View File

@ -30,7 +30,18 @@ namespace MCGalaxy.Commands {
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
string[] args = message.Split(' '); string[] args = message.Split(' ');
if (args[0] == "add") { 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; } if (args.Length < 2) { Help(p); return; }
args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]); args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]);
if (args[1] == null) return; if (args[1] == null) return;
@ -45,12 +56,14 @@ namespace MCGalaxy.Commands {
Player who = PlayerInfo.FindExact(args[1]); Player who = PlayerInfo.FindExact(args[1]);
if (who != null) Player.Message(who, "You are now a VIP!"); if (who != null) Player.Message(who, "You are now a VIP!");
} }
} else if (args[0] == "remove") { }
void RemoveVIP(Player p, string[] args) {
if (args.Length < 2) { Help(p); return; } if (args.Length < 2) { Help(p); return; }
args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]); args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]);
if (args[1] == null) return; if (args[1] == null) return;
if (Server.vip.Contains(args[1])) { if (!Server.vip.Contains(args[1])) {
Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis not a VIP."); Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis not a VIP.");
} else { } else {
Server.vip.Remove(args[1]); Server.vip.Remove(args[1]);
@ -60,22 +73,23 @@ namespace MCGalaxy.Commands {
Player who = PlayerInfo.FindExact(args[1]); Player who = PlayerInfo.FindExact(args[1]);
if (who != null) Player.Message(who, "You are no longer a VIP!"); if (who != null) Player.Message(who, "You are no longer a VIP!");
} }
} else if (args[0] == "list") { }
void ListVIPs(Player p, string[] args) {
List<string> list = Server.vip.All(); List<string> list = Server.vip.All();
if (list.Count == 0) { string modifier = args.Length > 1 ? args[1] : "";
if (list.Count == 5) {
Player.Message(p, "There are no VIPs."); Player.Message(p, "There are no VIPs.");
} else { } else {
string count = list.Count > 1 ? "is 1" : "are " + list.Count; Player.Message(p, "VIPs:");
Player.Message(p, "There " + count + " VIPs:"); MultiPageOutput.Output(p, list, (name, i) => name,
Player.Message(p, list.Join()); "vip list", "players", modifier, false);
}
} else {
Help(p);
} }
} }
public override void Help(Player p) { public override void Help(Player p) {
Player.Message(p, "%T/vip <add/remove> [player]"); Player.Message(p, "%T/vip add/remove [player]");
Player.Message(p, "%HAdds or removes [player] from the VIP list."); Player.Message(p, "%HAdds or removes [player] from the VIP list.");
Player.Message(p, "%T/vip list"); Player.Message(p, "%T/vip list");
Player.Message(p, "%HLists all players who are on the VIP list."); Player.Message(p, "%HLists all players who are on the VIP list.");