Adding EmojiHandler to handle an exploit. Adding sendemoji permission and checks.

I know, this is not something important, but I'm going through the new packets one by one and adding events developers can work with, patching exploits, and thought this could be a core permission.
This commit is contained in:
Patrikkk 2020-06-01 15:24:02 +02:00
parent 2254df21fd
commit f538ceb793
4 changed files with 38 additions and 2 deletions

View file

@ -4,6 +4,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
## Upcoming Changes
* Add Emoji event to GetDataHandler. This packet is received when a player tries to display an emote.
* Adding EmojiHandler to handle an exploit. Adding `tshock.sendemoji` permission and checks. Added this permission to guest group by default.
## TShock 4.4.0 (Pre-release 10)
* Fix all rope coils. (@Olink)

View file

@ -65,7 +65,8 @@ namespace TShockAPI.DB
Permissions.canpartychat,
Permissions.cantalkinthird,
Permissions.canchat,
Permissions.synclocalarea));
Permissions.synclocalarea,
Permissions.sendemoji));
AddDefaultGroup("default", "guest",
string.Join(",",

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TShockAPI.Handlers
{
/// <summary>
/// Handles an exploit and checks for permissions.
/// </summary>
public class EmojiHandler
{
public void OnEmoji(object sender, GetDataHandlers.EmojiEventArgs args)
{
if (args.PlayerIndex != args.Player.Index)
{
TShock.Log.ConsoleError($"EmojiHandler: Packet is spoofing to be player ID {args.PlayerIndex}! - From [{args.Player.Index}]{args.Player.Name}");
args.Handled = true;
return;
}
if (!args.Player.HasPermission(Permissions.sendemoji))
{
args.Player.SendErrorMessage("You have no permission to send emotes!");
args.Handled = true;
return;
}
}
}
}

View file

@ -468,6 +468,9 @@ namespace TShockAPI
[Description("Player can resync themselves with server state.")]
public static readonly string synclocalarea = "tshock.synclocalarea";
[Description("Player can send emotes.")]
public static readonly string sendemoji = "tshock.sendemoji";
#endregion
/// <summary>
/// Lists all commands associated with a given permission