mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -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);
|
||||
@ -48,7 +54,7 @@ namespace MCGalaxy.Commands {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public sealed class CmdHigh5 : MessageCmd {
|
||||
public override string name { get { return "high5"; } }
|
||||
|
||||
|
@ -17,17 +17,14 @@
|
||||
*/
|
||||
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) {
|
||||
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
|
||||
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
|
||||
if (message == "list") {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
@ -50,26 +47,25 @@ 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.");
|
||||
}
|
||||
|
||||
p.RaiseONAFK();
|
||||
Player.RaiseAFK(p);
|
||||
p.RaiseONAFK();
|
||||
Player.RaiseAFK(p);
|
||||
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
|
||||
|
@ -195,8 +195,8 @@ namespace MCGalaxy {
|
||||
|
||||
int PacketSize(byte[] buffer) {
|
||||
switch (buffer[0]) {
|
||||
case (byte)'G': return -2; //For wom
|
||||
case Opcode.Handshake: return 131;
|
||||
case (byte)'G': return -2; //For wom
|
||||
case Opcode.Handshake: return 131;
|
||||
case Opcode.SetBlockClient:
|
||||
if (!loggedIn) goto default;
|
||||
return 9;
|
||||
@ -206,14 +206,13 @@ namespace MCGalaxy {
|
||||
case Opcode.Message:
|
||||
if (!loggedIn) goto default;
|
||||
return 66;
|
||||
case Opcode.CpeExtInfo: return 67;
|
||||
case Opcode.CpeExtEntry: return 69;
|
||||
case Opcode.CpeCustomBlockSupportLevel: return 2;
|
||||
case Opcode.CpeExtInfo: return 67;
|
||||
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