private void InitTrade(TSPlayer player, IChest chest, ProtectionEntry protection)
        {
            TradeChestMetadata tradeChestData = protection.TradeChestData;
              Item sellItem = new Item();
              sellItem.netDefaults(tradeChestData.ItemToSellId);
              sellItem.stack = tradeChestData.ItemToSellAmount;
              Item payItem = new Item();
              payItem.netDefaults(tradeChestData.ItemToPayId);
              payItem.stack = tradeChestData.ItemToPayAmount;

              player.SendMessage($"This is a trade chest owned by {TShock.Utils.ColorTag(GetUserName(protection.Owner), Color.Red)}.", Color.LightGray);

              Inventory chestInventory = new Inventory(chest.Items, specificPrefixes: false);
              int stock = chestInventory.Amount(sellItem.netID);
              if (stock < sellItem.stack) {
            player.SendMessage($"It was trading {TShock.Utils.ItemTag(sellItem)} for {TShock.Utils.ItemTag(payItem)} but it is out of stock.", Color.LightGray);
            return;
              }

              player.SendMessage($"Click again to purchase {TShock.Utils.ItemTag(sellItem)} for {TShock.Utils.ItemTag(payItem)}", Color.LightGray);

              CommandInteraction interaction = this.StartOrResetCommandInteraction(player);

              interaction.ChestOpenCallback += (playerLocal, chestLocation) => {
            bool complete;

            bool wasThisChestHit = (chestLocation == chest.Location);
            if (wasThisChestHit) {
              // this is important to check, otherwise players could use trade chests to easily duplicate items
              if (!this.IsChestInUse(playerLocal, chest))
            this.PerformTrade(player, protection, chestInventory, sellItem, payItem);
              else
            player.SendErrorMessage("Another player is currently viewing the content of this chest.");

              complete = false;
            } else {
              this.HandleChestGetContents(playerLocal, chestLocation, skipInteractions: true);
              complete = true;
            }

            playerLocal.SendTileSquare(chest.Location);
            return new CommandInteractionResult {IsHandled = true, IsInteractionCompleted = complete};
              };
        }