mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Validate the name in RankCmd.FindName too, also do the same thing for /ban.
This commit is contained in:
parent
f2a7aafbc2
commit
f0d13f61d1
@ -27,26 +27,27 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
|
||||
bool stealth = false;
|
||||
if (message[0] == '#') {
|
||||
message = message.Remove(0, 1).Trim();
|
||||
stealth = true;
|
||||
bool stealth = message[0] == '#';
|
||||
if (stealth) {
|
||||
message = message.Remove(0, 1);
|
||||
Server.s.Log("Stealth ban Attempted by " + (p == null ? "Console" : p.ColoredName));
|
||||
}
|
||||
|
||||
string[] args = message.SplitSpaces(2);
|
||||
string reason = args.Length > 1 ? args[1] : Server.defaultBanMessage;
|
||||
string reason = args.Length > 1 ? args[1] : "";
|
||||
|
||||
string target = RankCmd.FindName(p, "ban", "", args[0], ref reason);
|
||||
if (target == null) return;
|
||||
Player who = PlayerInfo.FindExact(target);
|
||||
|
||||
if (reason == "") reason = Server.defaultBanMessage;
|
||||
if (reason == "-") reason = "&c-";
|
||||
reason = GetReason(p, reason);
|
||||
if (reason == null) return;
|
||||
string banReason = reason == "-" ? "" : " (" + reason + ")";
|
||||
|
||||
Player who = PlayerInfo.Find(args[0]);
|
||||
string target = who == null ? args[0] : who.name;
|
||||
if (!Formatter.ValidName(p, target, "player")) return;
|
||||
if (reason == null) return;
|
||||
Group group = who == null ? Group.findPlayerGroup(args[0]) : who.group;
|
||||
if (!CheckPerms(target, group, p)) return;
|
||||
|
||||
|
||||
string banReason = reason == "-" ? "" : " (" + reason + ")";
|
||||
string banner = p == null ? "(console)" : p.ColoredName;
|
||||
string banMsg = null;
|
||||
if (who == null) {
|
||||
|
@ -45,19 +45,20 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
|
||||
internal static string FindName(Player p, string action, string cmdArgs,
|
||||
string name, ref string reason) {
|
||||
if (!Formatter.ValidName(p, name, "player")) return null;
|
||||
string match = MatchName(p, ref name);
|
||||
string confirmed = IsConfirmed(reason);
|
||||
if (confirmed != null) reason = confirmed;
|
||||
if (confirmed != null) reason = confirmed;
|
||||
|
||||
if (match != null) {
|
||||
if (match.CaselessEq(name)) return match;
|
||||
// Not an exact match, may be wanting to ban an offline account
|
||||
// Not an exact match, may be wanting to ban a non-existent account
|
||||
Player.Message(p, "1 player matches \"{0}\": {1}", name, match);
|
||||
}
|
||||
|
||||
if (confirmed != null) return name;
|
||||
string msgReason = String.IsNullOrEmpty(reason) ? "" : " " + reason;
|
||||
Player.Message(p, "If you still want to {0} {1}, use %T/{0} {1}{2} confirm {3}",
|
||||
Player.Message(p, "If you still want to {0} \"{1}\", use %T/{0} {1}{2} confirm {3}",
|
||||
action, name, cmdArgs, msgReason);
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user