mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Don't repatrol players who were patrolled within last 15 seconds. Fixes #363.
This commit is contained in:
parent
3caa6bde36
commit
ff534860ec
@ -36,12 +36,10 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
|
|
||||||
List<Player> candidates = GetPatrolCandidates(p);
|
List<Player> candidates = GetPatrolCandidates(p);
|
||||||
if (candidates.Count == 0) {
|
if (candidates.Count == 0) {
|
||||||
LevelPermission perm = CommandExtraPerms.MinPerm(name);
|
Player.Message(p, "&cNo players to patrol.");
|
||||||
Player.Message(p, "No {0}players ranked {1} %Sor below are online.",
|
|
||||||
p.Rank <= perm ? "other " : "", // in case we can patrol ourselves
|
|
||||||
Group.GetColoredName(perm));
|
|
||||||
} else {
|
} else {
|
||||||
Player target = candidates[new Random().Next(candidates.Count)];
|
Player target = candidates[new Random().Next(candidates.Count)];
|
||||||
|
target.LastPatrol = DateTime.UtcNow;
|
||||||
Command.all.FindByName("TP").Use(p, target.name);
|
Command.all.FindByName("TP").Use(p, target.name);
|
||||||
Player.Message(p, "Now visiting " + target.ColoredName + "%S.");
|
Player.Message(p, "Now visiting " + target.ColoredName + "%S.");
|
||||||
}
|
}
|
||||||
@ -51,9 +49,11 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
List<Player> candidates = new List<Player>();
|
List<Player> candidates = new List<Player>();
|
||||||
LevelPermission perm = CommandExtraPerms.MinPerm(name);
|
LevelPermission perm = CommandExtraPerms.MinPerm(name);
|
||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
|
DateTime cutoff = DateTime.UtcNow.AddSeconds(-15);
|
||||||
|
|
||||||
foreach (Player target in online) {
|
foreach (Player target in online) {
|
||||||
if (target.Rank > perm || target == p || !Entities.CanSee(p, target)) continue;
|
if (target.Rank > perm || target == p || !Entities.CanSee(p, target)) continue;
|
||||||
|
if (target.LastPatrol > cutoff) continue;
|
||||||
candidates.Add(target);
|
candidates.Add(target);
|
||||||
}
|
}
|
||||||
return candidates;
|
return candidates;
|
||||||
@ -62,8 +62,8 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/Patrol");
|
Player.Message(p, "%T/Patrol");
|
||||||
LevelPermission perm = CommandExtraPerms.MinPerm(name);
|
LevelPermission perm = CommandExtraPerms.MinPerm(name);
|
||||||
Player.Message(p, "%HTeleports you to a random {0} %Sor lower",
|
Player.Message(p, "%HTeleports you to a random {0} %Hor lower", Group.GetColoredName(perm));
|
||||||
Group.GetColoredName(perm));
|
Player.Message(p, "%HPlayers patrolled within the last 15 seconds are ignored");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace MCGalaxy.Commands.Misc {
|
|||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (message.Length > 0) { Help(p); return; }
|
if (message.Length > 0) { Help(p); return; }
|
||||||
int code = p.random.Next(int.MinValue, int.MaxValue);
|
int code = new Random().Next(int.MinValue, int.MaxValue);
|
||||||
p.Leave("Server crash! Error code 0x" + Convert.ToString(code, 16).ToUpper());
|
p.Leave("Server crash! Error code 0x" + Convert.ToString(code, 16).ToUpper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ namespace MCGalaxy {
|
|||||||
pl.SendMapMotd();
|
pl.SendMapMotd();
|
||||||
} else {
|
} else {
|
||||||
LevelActions.ReloadMap(p, pl, false);
|
LevelActions.ReloadMap(p, pl, false);
|
||||||
if (pl.HasCpeExt(CpeExt.HackControl)) pl.Send(Hacks.MakeHackControl(pl));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,8 +230,7 @@ namespace MCGalaxy {
|
|||||||
public DateTime lastchatroomglobal;
|
public DateTime lastchatroomglobal;
|
||||||
|
|
||||||
public WarpList Waypoints = new WarpList();
|
public WarpList Waypoints = new WarpList();
|
||||||
|
public DateTime LastPatrol;
|
||||||
public Random random = new Random();
|
|
||||||
public LevelPermission Rank { get { return group.Permission; } }
|
public LevelPermission Rank { get { return group.Permission; } }
|
||||||
|
|
||||||
public bool loggedIn;
|
public bool loggedIn;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user