From 9dff07e6c2cc113dd07c0c7d76639d4147fb75ab Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 2 Jun 2020 19:18:43 +0930 Subject: [PATCH 1/2] Refactor EmojiHandler to implement IPacketHandler --- TShockAPI/Handlers/EmojiHandler.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/TShockAPI/Handlers/EmojiHandler.cs b/TShockAPI/Handlers/EmojiHandler.cs index b21cd53e..f32993d1 100644 --- a/TShockAPI/Handlers/EmojiHandler.cs +++ b/TShockAPI/Handlers/EmojiHandler.cs @@ -1,17 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using static TShockAPI.GetDataHandlers; namespace TShockAPI.Handlers { /// /// Handles emoji packets and checks for validity and permissions /// - public class EmojiHandler + public class EmojiHandler : IPacketHandler { - public void OnReceiveEmoji(object sender, GetDataHandlers.EmojiEventArgs args) + /// + /// Invoked when an emoji is sent in chat. Rejects the emoji packet if the player is spoofing IDs or does not have emoji permissions + /// + /// + /// + public void OnReceive(object sender, EmojiEventArgs args) { if (args.PlayerIndex != args.Player.Index) { From 7c98a7b19a419f42ede883b69780347a70433ba5 Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 2 Jun 2020 19:19:49 +0930 Subject: [PATCH 2/2] Missed a refactor --- TShockAPI/Bouncer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index b9bb2e05..f4fa4053 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -38,7 +38,7 @@ namespace TShockAPI { internal Handlers.SendTileSquareHandler STSHandler { get; set; } internal Handlers.NetModules.NetModulePacketHandler NetModuleHandler { get; set; } - internal Handlers.EmojiHandler EmojiHandler { get; set; } + internal Handlers.EmojiHandler EmojiHandler { get; set; } /// Constructor call initializes Bouncer and related functionality. /// A new Bouncer. @@ -51,7 +51,7 @@ namespace TShockAPI GetDataHandlers.ReadNetModule += NetModuleHandler.OnReceive; EmojiHandler = new Handlers.EmojiHandler(); - GetDataHandlers.Emoji += EmojiHandler.OnReceiveEmoji; + GetDataHandlers.Emoji += EmojiHandler.OnReceive; // Setup hooks GetDataHandlers.GetSection += OnGetSection;