mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-28 07:56:20 -04:00
Allow providing a reason for tempbans.
This commit is contained in:
parent
c99e68530b
commit
a571905259
@ -26,10 +26,11 @@ namespace MCGalaxy.Commands {
|
|||||||
public override string type { get { return CommandTypes.Moderation; } }
|
public override string type { get { return CommandTypes.Moderation; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
public override bool museumUsable { get { return true; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||||
|
static char[] trimChars = {' '};
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
string[] args = message.Split(' ');
|
string[] args = message.Split(trimChars, 3);
|
||||||
Player who = PlayerInfo.Find(args[0]);
|
Player who = PlayerInfo.Find(args[0]);
|
||||||
|
|
||||||
string target = who == null ? args[0] : who.name;
|
string target = who == null ? args[0] : who.name;
|
||||||
@ -48,15 +49,20 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
Server.TempBan tBan;
|
Server.TempBan tBan;
|
||||||
tBan.name = target;
|
tBan.name = target;
|
||||||
tBan.expiryTime = DateTime.Now.AddMinutes(minutes);
|
tBan.reason = args.Length > 2 ? args[2] : "";
|
||||||
|
tBan.expiryTime = DateTime.UtcNow.AddMinutes(minutes);
|
||||||
Server.tempBans.Add(tBan);
|
Server.tempBans.Add(tBan);
|
||||||
if (who != null)
|
|
||||||
who.Kick("Banned for " + minutes + " minutes!");
|
if (who != null) {
|
||||||
|
string reason = String.IsNullOrEmpty(tBan.reason) ? ""
|
||||||
|
: " - (" + tBan.reason + ")";
|
||||||
|
who.Kick("Banned for " + minutes + " minutes!" + reason);
|
||||||
|
}
|
||||||
Player.SendMessage(p, "Temp banned " + target + " for " + minutes + " minutes.");
|
Player.SendMessage(p, "Temp banned " + target + " for " + minutes + " minutes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.SendMessage(p, "/tempban <name> <minutes> - Bans <name> for <minutes>");
|
Player.SendMessage(p, "/tempban <name> <minutes> [reason] - Bans <name> for <minutes>");
|
||||||
Player.SendMessage(p, "Max time is 1440 (1 day). Default is 60");
|
Player.SendMessage(p, "Max time is 1440 (1 day). Default is 60");
|
||||||
Player.SendMessage(p, "Temp bans will reset on server restart");
|
Player.SendMessage(p, "Temp bans will reset on server restart");
|
||||||
}
|
}
|
||||||
|
@ -309,10 +309,12 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Server.TempBan tBan = Server.tempBans.Find(tB => tB.name.ToLower() == name.ToLower());
|
Server.TempBan tBan = Server.tempBans.Find(tB => tB.name.ToLower() == name.ToLower());
|
||||||
if (tBan.expiryTime < DateTime.Now) {
|
if (tBan.expiryTime < DateTime.UtcNow) {
|
||||||
Server.tempBans.Remove(tBan);
|
Server.tempBans.Remove(tBan);
|
||||||
} else {
|
} else {
|
||||||
Kick("You're still banned (temporary ban)!", true);
|
string reason = String.IsNullOrEmpty(tBan.reason) ? "" :
|
||||||
|
" (" + tBan.reason + ")";
|
||||||
|
Kick("You're still temp banned!" + reason, true);
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ namespace MCGalaxy
|
|||||||
public static List<string> Opstats { get { return new List<string>(opstats); } }
|
public static List<string> Opstats { get { return new List<string>(opstats); } }
|
||||||
|
|
||||||
public static List<TempBan> tempBans = new List<TempBan>();
|
public static List<TempBan> tempBans = new List<TempBan>();
|
||||||
public struct TempBan { public string name; public DateTime expiryTime; }
|
public struct TempBan { public string name, reason; public DateTime expiryTime; }
|
||||||
|
|
||||||
public static PerformanceCounter PCCounter = null;
|
public static PerformanceCounter PCCounter = null;
|
||||||
public static PerformanceCounter ProcessCounter = null;
|
public static PerformanceCounter ProcessCounter = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user