mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Prevent using /hug/high5 when chat moderation is enabled, reduce code duplication for /me.
This commit is contained in:
parent
267787b799
commit
9c34a134c1
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdMe : Command {
|
||||
public sealed class CmdMe : MessageCmd {
|
||||
public override string name { get { return "me"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Chat; } }
|
||||
@ -28,17 +28,11 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Player.Message(p, "You"); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
if (p.joker || p.muted) { Player.Message(p, "Cannot use /me while muted or jokered."); return; }
|
||||
if (Server.chatmod && !p.voice) { Player.Message(p, "Chat moderation is on, you cannot emote."); return; }
|
||||
if (p.joker) { Player.Message(p, "Cannot use /me while jokered."); return; }
|
||||
|
||||
if (!p.level.worldChat) {
|
||||
Chat.GlobalChatLevel(p, "<Level>" + p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message, false);
|
||||
} else {
|
||||
Player.SendChatFrom(p, p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message, false);
|
||||
string msg = p.color + "*" + Colors.StripColors(p.DisplayName) + " " + message;
|
||||
if (TryMessage(p, msg) && p.level.worldChat)
|
||||
Player.RaisePlayerAction(p, PlayerAction.Me, message);
|
||||
}
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -30,13 +30,14 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
string giver = (p == null) ? "(console)" : p.ColoredName;
|
||||
if (!TryMessage(p, string.Format(message, giver, who.ColoredName))) return false;
|
||||
if (messageWho)
|
||||
if (messageWho && !who.listignored.Contains(giver))
|
||||
Player.Message(who, string.Format(message, giver, "you"));
|
||||
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; }
|
||||
|
||||
if (p.level.worldChat) {
|
||||
Player.SendChatFrom(p, message, false);
|
||||
|
@ -61,6 +61,7 @@ namespace MCGalaxy {
|
||||
public string theme = "Normal";
|
||||
[ConfigBool("Unload", "General", null, true)]
|
||||
public bool unload = true;
|
||||
/// <summary> true if this map sees server-wide chat, false if this map has level-only/isolated chat </summary>
|
||||
[ConfigBool("WorldChat", "General", null, true)]
|
||||
public bool worldChat = true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user