mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Fix /vip remove
This commit is contained in:
parent
8b680ea217
commit
c45ebb2ebd
@ -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<string> 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<string> 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 <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, "%T/vip list");
|
||||
Player.Message(p, "%HLists all players who are on the VIP list.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user