Skip to content
Permalink
Browse files

Print command usage instead of doing nothing when no arguments are pr…

…ovided to /staff, /ircstaff, or /saystaff
  • Loading branch information...
UnknownShadow200 committed Jan 4, 2018
1 parent 814656b commit 23fe2c5d06a1dd9244f40330aa61fd8f80d95db5
Showing with 45 additions and 98 deletions.
  1. +45 −98 fCraft/Commands/ChatCommands.cs
@@ -44,7 +44,34 @@ public static void Init()
Player.Moved += new EventHandler<Events.PlayerMovedEventArgs>(Player_IsBack);
}

#region Say
#region Say / Staff / IRCStaff / SayStaff

static void ChatCommandHandler(Player player, CommandReader cmd, ChatMessageType type) {
if (player.Info.IsMuted) {
player.MessageMuted();
return;
}
if (player.DetectChatSpam()) return;

string msg = cmd.NextAll().Trim();
if (msg.Length == 0) {
cmd.Descriptor.PrintUsage(player);
return;
}

switch (type) {
case ChatMessageType.Say:
Chat.SendSay(player, msg); break;
case ChatMessageType.Staff:
Chat.SendStaff(player, msg); break;
case ChatMessageType.IRC:
Chat.SendIRCStaff(player, msg); break;
case ChatMessageType.Me:
Chat.SendMe(player, msg); break;
case ChatMessageType.SayStaff:
Chat.SendStaffSay(player, msg); break;
}
}

static readonly CommandDescriptor CdSay = new CommandDescriptor
{
@@ -62,37 +89,14 @@ public static void Init()
Handler = SayHandler
};

static void SayHandler(Player player, CommandReader cmd)
{
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}

if (player.DetectChatSpam()) return;

if (player.Can(Permission.Say))
{
string msg = cmd.NextAll().Trim();
if (msg.Length > 0)
{
Chat.SendSay(player, msg);
}
else
{
CdSay.PrintUsage(player);
}
}
else
{
static void SayHandler(Player player, CommandReader cmd) {
if (!player.Can(Permission.Say)) {
player.MessageNoAccess(Permission.Say);
} else {
ChatCommandHandler(player, cmd, ChatMessageType.Say);
}
}

#endregion
#region Staff

static readonly CommandDescriptor CdStaff = new CommandDescriptor
{
Name = "Staff",
@@ -108,26 +112,10 @@ static void SayHandler(Player player, CommandReader cmd)
Handler = StaffHandler
};

static void StaffHandler(Player player, CommandReader cmd)
{
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}

if (player.DetectChatSpam()) return;

string message = cmd.NextAll().Trim(' ');
if (message.Length > 0)
{
Chat.SendStaff(player, message);
}
static void StaffHandler(Player player, CommandReader cmd) {
ChatCommandHandler(player, cmd, ChatMessageType.Staff);
}

#endregion
#region IRCStaff

static readonly CommandDescriptor CdIRCStaff = new CommandDescriptor
{
Name = "IRCStaff",
@@ -143,26 +131,10 @@ static void StaffHandler(Player player, CommandReader cmd)
Handler = IRCStaffHandler
};

static void IRCStaffHandler(Player player, CommandReader cmd)
{
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}

if (player.DetectChatSpam()) return;

string message = cmd.NextAll().Trim(' ');
if (message.Length > 0)
{
Chat.SendIRCStaff(player, message);
}
static void IRCStaffHandler(Player player, CommandReader cmd) {
ChatCommandHandler(player, cmd, ChatMessageType.IRC);
}

#endregion
#region StaffSay

static readonly CommandDescriptor CdStaffSay = new CommandDescriptor
{
Name = "StaffSay",
@@ -179,31 +151,11 @@ static void IRCStaffHandler(Player player, CommandReader cmd)
Handler = StaffSayHandler
};

static void StaffSayHandler(Player player, CommandReader cmd)
{
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}

if (player.DetectChatSpam()) return;

if (player.Can(Permission.Say))
{
string msg = cmd.NextAll().Trim();
if (msg.Length > 0)
{
Chat.SendStaffSay(player, msg);
}
else
{
CdStaffSay.PrintUsage(player);
}
}
else
{
static void StaffSayHandler(Player player, CommandReader cmd) {
if (!player.Can(Permission.Say)) {
player.MessageNoAccess(Permission.Say);
} else {
ChatCommandHandler(player, cmd, ChatMessageType.SayStaff);
}
}

@@ -425,23 +377,18 @@ static void ReviewHandler(Player player, CommandReader cmd)
Handler = MeHandler
};

static void MeHandler(Player player, CommandReader cmd)
{
if (player.Info.IsMuted)
{
static void MeHandler(Player player, CommandReader cmd) {
if (player.Info.IsMuted) {
player.MessageMuted();
return;
}

if (player.DetectChatSpam()) return;

string msg = cmd.NextAll().Trim();
if (msg.Length > 0)
{
if (msg.Length > 0) {
Chat.SendMe(player, msg);
}
else
{
} else {
CdMe.PrintUsage(player);
}
}

0 comments on commit 23fe2c5

Please sign in to comment.
You can’t perform that action at this time.