mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fix last commit
This commit is contained in:
parent
8d86e6a397
commit
efd8370388
@ -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 MCGalaxy.Events;
|
||||
using System;
|
||||
|
||||
@ -29,24 +29,31 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
string[] args = message.SplitSpaces(3);
|
||||
if (args.Length < 2) { Help(p); return; }
|
||||
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
|
||||
if (who == null) return;
|
||||
if (p != null && p == who) { Player.Message(p, "Cannot freeze yourself."); return; }
|
||||
if (p != null && who.Rank >= p.Rank) { MessageTooHighRank(p, "freeze", false); return; }
|
||||
|
||||
TimeSpan duration = TimeSpan.Zero;
|
||||
if (!CommandParser.GetTimespan(p, args[1], ref duration, "freeze for", 'm')) return;
|
||||
|
||||
string reason = args.Length > 2 ? args[2] : "";
|
||||
reason = ModActionCmd.ExpandReason(p, reason);
|
||||
if (reason == null) return;
|
||||
|
||||
ModActionType actionType = who.frozen ? ModActionType.Unfrozen : ModActionType.Frozen;
|
||||
ModAction action = new ModAction(who.name, p, actionType, reason, duration);
|
||||
OnModActionEvent.Call(action);
|
||||
if (who.frozen) {
|
||||
string reason = args.Length > 1 ? args[1] : "";
|
||||
reason = ModActionCmd.ExpandReason(p, reason);
|
||||
if (reason == null) return;
|
||||
|
||||
ModAction action = new ModAction(who.name, p, ModActionType.Unfrozen, reason);
|
||||
OnModActionEvent.Call(action);
|
||||
} else {
|
||||
if (args.Length < 2) { Help(p); return; }
|
||||
TimeSpan duration = TimeSpan.Zero;
|
||||
if (!CommandParser.GetTimespan(p, args[1], ref duration, "freeze for", 'm')) return;
|
||||
|
||||
string reason = args.Length > 2 ? args[2] : "";
|
||||
reason = ModActionCmd.ExpandReason(p, reason);
|
||||
if (reason == null) return;
|
||||
|
||||
ModAction action = new ModAction(who.name, p, ModActionType.Frozen, reason, duration);
|
||||
OnModActionEvent.Call(action);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -53,8 +53,8 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
Command mute = Command.all.Find("mute");
|
||||
|
||||
if (!Server.jailed.Contains(who.name)) {
|
||||
if (!who.muted) mute.Use(p, message);
|
||||
if (!who.frozen) freeze.Use(p, message);
|
||||
if (!who.muted) mute.Use(p, message + " 10000d");
|
||||
if (!who.frozen) freeze.Use(p, message + " 10000d");
|
||||
|
||||
PlayerActions.ChangeMap(who, xjailMap);
|
||||
who.BlockUntilLoad(10);
|
||||
|
@ -250,9 +250,18 @@ namespace MCGalaxy.Core {
|
||||
|
||||
static string FormatModTaskData(ModAction e) {
|
||||
long assign = DateTime.UtcNow.ToUnixTime();
|
||||
DateTime expiryTime = DateTime.UtcNow.Add(e.Duration);
|
||||
if (e.Duration == TimeSpan.Zero)
|
||||
DateTime expiryTime;
|
||||
|
||||
if (e.Duration == TimeSpan.Zero) {
|
||||
expiryTime = DateTime.MaxValue;
|
||||
} else {
|
||||
try {
|
||||
expiryTime = DateTime.UtcNow.Add(e.Duration);
|
||||
} catch (ArgumentOutOfRangeException) {
|
||||
// user provided extreme expiry time
|
||||
expiryTime = DateTime.MaxValue;
|
||||
}
|
||||
}
|
||||
|
||||
long expiry = expiryTime.ToUnixTime();
|
||||
string assigner = e.Actor == null ? "(console)" : e.Actor.name;
|
||||
|
@ -115,18 +115,20 @@ namespace MCGalaxy.Tasks {
|
||||
}
|
||||
|
||||
int GetWaitTime() {
|
||||
int wait = int.MaxValue;
|
||||
long wait = int.MaxValue;
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
lock (taskLock) {
|
||||
foreach (SchedulerTask task in tasks) {
|
||||
int remaining = (int)(task.NextRun - now).TotalMilliseconds;
|
||||
long remaining = (long)(task.NextRun - now).TotalMilliseconds;
|
||||
if (remaining > int.MaxValue) remaining = int.MaxValue;
|
||||
|
||||
// minimum wait time is 1 millisecond
|
||||
remaining = Math.Max(1, remaining);
|
||||
wait = Math.Min(wait, remaining);
|
||||
}
|
||||
}
|
||||
return wait == int.MaxValue ? -1 : wait;
|
||||
return wait == int.MaxValue ? -1 : (int)wait;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user