using System.IO; using System.IO.Streams; using Terraria.GameContent; using static Terraria.GameContent.NetModules.NetTeleportPylonModule; namespace TShockAPI.Handlers.NetModules { /// /// Handles a pylon net module /// public class PylonHandler : INetModuleHandler { /// /// Event occurring /// public SubPacketType PylonEventType { get; set; } /// /// Tile X coordinate of the pylon /// public short TileX { get; set; } /// /// Tile Y coordinate of the pylon /// public short TileY { get; set; } /// /// Type of Pylon /// public TeleportPylonType PylonType { get; set; } /// /// Reads the pylon data from the net module /// /// public void Deserialize(MemoryStream data) { PylonEventType = (SubPacketType)data.ReadInt8(); TileX = data.ReadInt16(); TileY = data.ReadInt16(); PylonType = (TeleportPylonType)data.ReadInt8(); } /// /// Rejects a pylon teleport request if the player does not have permission /// /// /// public void HandlePacket(TSPlayer player, out bool rejectPacket) { if (PylonEventType == SubPacketType.PlayerRequestsTeleport) { if (!player.HasPermission(Permissions.pylon)) { rejectPacket = true; player.SendErrorMessage("You do not have permission to teleport using pylons."); return; } } rejectPacket = false; } } }