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

@ -3,7 +3,8 @@
This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large.
## Upcoming Changes ## Upcoming Changes
* Add Emoji event to GetDataHandler. This packet is received when a player tries to display an emote. * 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) ## TShock 4.4.0 (Pre-release 10)
* Fix all rope coils. (@Olink) * Fix all rope coils. (@Olink)

View file

@ -65,7 +65,8 @@ namespace TShockAPI.DB
Permissions.canpartychat, Permissions.canpartychat,
Permissions.cantalkinthird, Permissions.cantalkinthird,
Permissions.canchat, Permissions.canchat,
Permissions.synclocalarea)); Permissions.synclocalarea,
Permissions.sendemoji));
AddDefaultGroup("default", "guest", AddDefaultGroup("default", "guest",
string.Join(",", 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.")] [Description("Player can resync themselves with server state.")]
public static readonly string synclocalarea = "tshock.synclocalarea"; public static readonly string synclocalarea = "tshock.synclocalarea";
[Description("Player can send emotes.")]
public static readonly string sendemoji = "tshock.sendemoji";
#endregion #endregion
/// <summary> /// <summary>
/// Lists all commands associated with a given permission /// Lists all commands associated with a given permission