mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Make /vip and /whitelist use multi page output, also colour the names in them.
This commit is contained in:
parent
c45ebb2ebd
commit
5a2aac4573
@ -30,60 +30,63 @@ namespace MCGalaxy.Commands {
|
|||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
string[] args = message.Split(' ');
|
string[] args = message.Split(' ');
|
||||||
|
|
||||||
if (args[0].CaselessEq("add") {
|
if (args[0].CaselessEq("add")) {
|
||||||
AddVIP(p, args);
|
if (args.Length < 2) { Help(p); return; }
|
||||||
} else if (args[0].CaselessEq("remove") {
|
AddVIP(p, args[1]);
|
||||||
RemoveVIP(p, args);
|
} else if (args[0].CaselessEq("remove")) {
|
||||||
} else if (args[0].CaselessEq("list") {
|
if (args.Length < 2) { Help(p); return; }
|
||||||
|
RemoveVIP(p, args[1]);
|
||||||
|
} else if (args[0].CaselessEq("list")) {
|
||||||
ListVIPs(p, args);
|
ListVIPs(p, args);
|
||||||
|
} else if (args.Length == 1) {
|
||||||
|
AddVIP(p, args[0]);
|
||||||
} else {
|
} else {
|
||||||
Help(p);
|
Help(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddVIP(Player p, string[] args) {
|
static void AddVIP(Player p, string name) {
|
||||||
if (args.Length < 2) { Help(p); return; }
|
name = PlayerInfo.FindMatchesPreferOnline(p, name);
|
||||||
args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]);
|
if (name == null) return;
|
||||||
if (args[1] == null) return;
|
|
||||||
|
|
||||||
if (Server.vip.Contains(args[1])) {
|
if (Server.vip.Contains(name)) {
|
||||||
Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis already a VIP.");
|
Player.Message(p, PlayerInfo.GetColoredName(p, name) + " %Sis already a VIP.");
|
||||||
} else {
|
} else {
|
||||||
Server.vip.Add(args[1]);
|
Server.vip.Add(name);
|
||||||
Server.vip.Save(false);
|
Server.vip.Save(false);
|
||||||
Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis now a VIP.");
|
Player.Message(p, PlayerInfo.GetColoredName(p, name) + " %Sis now a VIP.");
|
||||||
|
|
||||||
Player who = PlayerInfo.FindExact(args[1]);
|
Player vip = PlayerInfo.FindExact(name);
|
||||||
if (who != null) Player.Message(who, "You are now a VIP!");
|
if (vip != null) Player.Message(vip, "You are now a VIP!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveVIP(Player p, string[] args) {
|
void RemoveVIP(Player p, string name) {
|
||||||
if (args.Length < 2) { Help(p); return; }
|
name = PlayerInfo.FindMatchesPreferOnline(p, name);
|
||||||
args[1] = PlayerInfo.FindMatchesPreferOnline(p, args[1]);
|
if (name == null) return;
|
||||||
if (args[1] == null) return;
|
|
||||||
|
|
||||||
if (!Server.vip.Contains(args[1])) {
|
if (!Server.vip.Contains(name)) {
|
||||||
Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis not a VIP.");
|
Player.Message(p, PlayerInfo.GetColoredName(p, name) + " %Sis not a VIP.");
|
||||||
} else {
|
} else {
|
||||||
Server.vip.Remove(args[1]);
|
Server.vip.Remove(name);
|
||||||
Server.vip.Save(false);
|
Server.vip.Save(false);
|
||||||
Player.Message(p, PlayerInfo.GetColoredName(p, args[1]) + " %Sis no longer a VIP.");
|
Player.Message(p, PlayerInfo.GetColoredName(p, name) + " %Sis no longer a VIP.");
|
||||||
|
|
||||||
Player who = PlayerInfo.FindExact(args[1]);
|
Player vip = PlayerInfo.FindExact(name);
|
||||||
if (who != null) Player.Message(who, "You are no longer a VIP!");
|
if (vip != null) Player.Message(vip, "You are no longer a VIP!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListVIPs(Player p, string[] args) {
|
static void ListVIPs(Player p, string[] args) {
|
||||||
List<string> list = Server.vip.All();
|
List<string> list = Server.vip.All();
|
||||||
string modifier = args.Length > 1 ? args[1] : "";
|
string modifier = args.Length > 1 ? args[1] : "";
|
||||||
|
|
||||||
if (list.Count == 5) {
|
if (list.Count == 0) {
|
||||||
Player.Message(p, "There are no VIPs.");
|
Player.Message(p, "There are no VIPs.");
|
||||||
} else {
|
} else {
|
||||||
Player.Message(p, "VIPs:");
|
Player.Message(p, "VIPs:");
|
||||||
MultiPageOutput.Output(p, list, (name, i) => name,
|
MultiPageOutput.Output(p, list,
|
||||||
|
(name, i) => PlayerInfo.GetColoredName(p, name),
|
||||||
"vip list", "players", modifier, false);
|
"vip list", "players", modifier, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands {
|
namespace MCGalaxy.Commands {
|
||||||
public sealed class CmdWhitelist : Command {
|
public sealed class CmdWhitelist : Command {
|
||||||
public override string name { get { return "whitelist"; } }
|
public override string name { get { return "whitelist"; } }
|
||||||
@ -27,20 +29,18 @@ namespace MCGalaxy.Commands {
|
|||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (!Server.useWhitelist) { Player.Message(p, "Whitelist is not enabled."); return; }
|
if (!Server.useWhitelist) { Player.Message(p, "Whitelist is not enabled."); return; }
|
||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
int sep = message.IndexOf(' ');
|
string[] args = message.Split(' ');
|
||||||
string action = sep >= 0 ? message.Substring(0, sep) : message;
|
|
||||||
string player = sep >= 0 ? message.Substring(sep + 1) : "";
|
|
||||||
|
|
||||||
if (action.CaselessEq("list")) {
|
if (args[0].CaselessEq("add")) {
|
||||||
string names = Server.whiteList.All().Join(", ");
|
if (args.Length < 2) { Help(p); return; }
|
||||||
Player.Message(p, "Whitelist: &f" + names); return;
|
Add(p, args[1]);
|
||||||
}
|
} else if (args[0].CaselessEq("del") || args[0].CaselessEq("remove")) {
|
||||||
if (player == "") { Add(p, action); return; }
|
if (args.Length < 2) { Help(p); return; }
|
||||||
|
Remove(p, args[1]);
|
||||||
if (action.CaselessEq("add")) {
|
} else if (args[0].CaselessEq("list")) {
|
||||||
Add(p, player);
|
List(p, args);
|
||||||
} else if (action.CaselessEq("del") || action.CaselessEq("remove")) {
|
} else if (args.Length == 1) {
|
||||||
Remove(p, player);
|
Add(p, args[0]);
|
||||||
} else {
|
} else {
|
||||||
Help(p);
|
Help(p);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
static void Add(Player p, string player) {
|
static void Add(Player p, string player) {
|
||||||
if (Server.whiteList.Contains(player)) {
|
if (Server.whiteList.Contains(player)) {
|
||||||
Player.Message(p, "&f" + player + " %Sis already on the whitelist!"); return;
|
Player.Message(p, player + " %Sis already on the whitelist!"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.whiteList.Add(player);
|
Server.whiteList.Add(player);
|
||||||
@ -60,7 +60,7 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
static void Remove(Player p, string player) {
|
static void Remove(Player p, string player) {
|
||||||
if (!Server.whiteList.Contains(player)) {
|
if (!Server.whiteList.Contains(player)) {
|
||||||
Player.Message(p, "&f" + player + " %Sis not on the whitelist!"); return;
|
Player.Message(p, player + " %Sis not on the whitelist!"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.whiteList.Remove(player);
|
Server.whiteList.Remove(player);
|
||||||
@ -70,8 +70,22 @@ namespace MCGalaxy.Commands {
|
|||||||
Server.s.Log("WHITELIST: Removed " + player);
|
Server.s.Log("WHITELIST: Removed " + player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void List(Player p, string[] args) {
|
||||||
|
List<string> list = Server.whiteList.All();
|
||||||
|
string modifier = args.Length > 1 ? args[1] : "";
|
||||||
|
|
||||||
|
if (list.Count == 0) {
|
||||||
|
Player.Message(p, "There are no whitelisted players.");
|
||||||
|
} else {
|
||||||
|
Player.Message(p, "Whitelisted players:");
|
||||||
|
MultiPageOutput.Output(p, list,
|
||||||
|
(name, i) => PlayerInfo.GetColoredName(p, name),
|
||||||
|
"whitelist list", "players", modifier, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/whitelist <add/del> [player]");
|
Player.Message(p, "%T/whitelist add/del [player]");
|
||||||
Player.Message(p, "%HAdds or removes [player] from the whitelist.");
|
Player.Message(p, "%HAdds or removes [player] from the whitelist.");
|
||||||
Player.Message(p, "%T/whitelist list");
|
Player.Message(p, "%T/whitelist list");
|
||||||
Player.Message(p, "%HLists all players who are on the whitelist.");
|
Player.Message(p, "%HLists all players who are on the whitelist.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user