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:
parent
2254df21fd
commit
f538ceb793
4 changed files with 38 additions and 2 deletions
31
TShockAPI/Handlers/EmojiHandler.cs
Normal file
31
TShockAPI/Handlers/EmojiHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue