/**
  * Handles a trade request for {@code player}.
  *
  * @param player the player to handle this for.
  * @param payload the payloadfer for reading the sent data.
  */
 private void tradeRequest(Player player, MessageBuilder payload) {
   int index = payload.getShort(true, ByteOrder.LITTLE);
   Player other = World.getPlayers().get(index);
   if (other == null || !validate(player, other)) return;
   player.setSkillAction(false);
   if (!MinigameHandler.execute(player, true, m -> m.canTrade(player, other))) return;
   player.getTradeSession().request(other);
 }
  @Override
  protected void encode(ChannelHandlerContext ctx, MessageBuilder msg, ByteBuf out)
      throws Exception {

    // Generate a new encryption key using ISAAC, encode the message and
    // write it to the client.
    ByteBuf internal = msg.buffer();
    int value = internal.getByte(0) + encryptor.getKey();
    internal.setByte(0, value);
    out.writeBytes(internal);
  }