mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Core: Prevent using /afk to bypass /ignore.
This commit is contained in:
parent
51a2ffb677
commit
ce7077b764
@ -35,9 +35,15 @@ namespace MCGalaxy.Commands {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool TryMessage(Player p, string message) {
|
||||
if (p != null && p.muted) { Player.Message(p, "Cannot use /{0} while muted.", name); return false; }
|
||||
if (Server.chatmod && !p.voice) { Player.Message(p, "Cannot use /{0} when chat moderation is enabled.", name); return false; }
|
||||
protected bool TryMessage(Player p, string message) { return TryMessage(p, message, name); }
|
||||
|
||||
protected static bool TryMessage(Player p, string message, string cmd) {
|
||||
if (p != null && p.muted) {
|
||||
Player.Message(p, "Cannot use /{0} while muted.", cmd); return false;
|
||||
}
|
||||
if (Server.chatmod && !p.voice) {
|
||||
Player.Message(p, "Cannot use /{0} when chat moderation is enabled.", cmd); return false;
|
||||
}
|
||||
|
||||
if (p.level.worldChat) {
|
||||
Player.SendChatFrom(p, message, false);
|
||||
|
@ -17,13 +17,10 @@
|
||||
*/
|
||||
using System;
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdAfk : Command {
|
||||
public sealed class CmdAfk : MessageCmd {
|
||||
public override string name { get { return "afk"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Information; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||
public static string keywords { get { return ""; } }
|
||||
public CmdAfk() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
@ -50,8 +47,8 @@ namespace MCGalaxy.Commands {
|
||||
bool send = !Server.chatmod && !p.muted;
|
||||
if (p.IsAfk) {
|
||||
if (send) {
|
||||
Chat.MessageWhere("-{0}%S- is AFK {1}",
|
||||
pl => Entities.CanSee(pl, p), p.ColoredName, message);
|
||||
string msg = "-" + p.ColoredName + "%S- is AFK " + message;
|
||||
MessageCmd.TryMessage(p, msg, "afk");
|
||||
Player.RaisePlayerAction(p, PlayerAction.AFK, message);
|
||||
} else {
|
||||
Player.Message(p, "You are now marked as being AFK.");
|
||||
@ -62,14 +59,13 @@ namespace MCGalaxy.Commands {
|
||||
OnPlayerAFKEvent.Call(p);
|
||||
} else {
|
||||
if (send) {
|
||||
Chat.MessageWhere("-{0}%S- is no longer AFK",
|
||||
pl => Entities.CanSee(pl, p), p.ColoredName);
|
||||
string msg = "-" + p.ColoredName + "%S- is no longer AFK";
|
||||
MessageCmd.TryMessage(p, msg, "afk");
|
||||
Player.RaisePlayerAction(p, PlayerAction.UnAFK, message);
|
||||
} else {
|
||||
Player.Message(p, "You are no longer marked as being AFK.");
|
||||
}
|
||||
}
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 MCGalaxy team
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
|
@ -210,10 +210,9 @@ namespace MCGalaxy {
|
||||
case Opcode.CpeExtEntry: return 69;
|
||||
case Opcode.CpeCustomBlockSupportLevel: return 2;
|
||||
default:
|
||||
if (!dontmindme)
|
||||
if (!dontmindme) {
|
||||
Leave("Unhandled message id \"" + buffer[0] + "\"!", true);
|
||||
else
|
||||
Server.s.Log(Encoding.UTF8.GetString(buffer, 0, buffer.Length));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user